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/oleutil"
  23. "io"
  24. "io/ioutil"
  25. //"math"
  26. "math/rand"
  27. "net/http"
  28. "net/url"
  29. "os"
  30. "path/filepath"
  31. "regexp"
  32. "strconv"
  33. "strings"
  34. "syscall"
  35. "time"
  36. "unsafe"
  37. )
  38. type HisApiController struct {
  39. controllers.BaseAuthAPIController
  40. }
  41. func HisManagerApiRegistRouters() {
  42. //挂号
  43. beego.Router("/api/register/get", &HisApiController{}, "get:GetRegisterInfo")
  44. //上传就诊信息-上传明细-结算
  45. beego.Router("/api/upload/get", &HisApiController{}, "get:GetUploadInfo")
  46. //查询
  47. beego.Router("/api/settle/query", &HisApiController{}, "get:GetSettleAccounts")
  48. //对总账
  49. beego.Router("/api/checkaccount/get", &HisApiController{}, "get:GetCheckAccount")
  50. //对明细
  51. beego.Router("/api/checkdetailaccount/get", &HisApiController{}, "get:GetCheckDetailAccount")
  52. //退费,退明细
  53. beego.Router("/api/refund/post", &HisApiController{}, "get:Refund")
  54. //退号
  55. beego.Router("/api/refundnumber/post", &HisApiController{}, "get:RefundNumber")
  56. //退明细
  57. beego.Router("/api/refunddetail/post", &HisApiController{}, "get:RefundDetail")
  58. //上传就诊信息-上传明细-预结算
  59. beego.Router("/api/presettle/get", &HisApiController{}, "get:GetPreUploadInfo")
  60. //beego.Router("/api/treatment/check", &HisApiController{}, "get:CheckTreatment")
  61. beego.Router("/api/org/info", &HisApiController{}, "get:GetOrgInfo")
  62. beego.Router("/api/readcard", &HisApiController{}, "get:ReadCard")
  63. beego.Router("/api/310", &HisApiController{}, "get:Check310")
  64. beego.Router("/api/390", &HisApiController{}, "get:Check390")
  65. beego.Router("/api/patient/info", &HisApiController{}, "get:GetPatientInfo")
  66. beego.Router("/api/checkcode/get", &HisApiController{}, "get:GetCheckCode")
  67. beego.Router("/api/uncheckcode/get", &HisApiController{}, "get:UnCheckCode")
  68. beego.Router("/api/psn/putonrecord", &HisApiController{}, "get:PsnPutOnRecord")
  69. beego.Router("/api/psn/unputonrecord", &HisApiController{}, "get:PsnUnPutOnRecord")
  70. beego.Router("/api/psn/ncds/putonrecord", &HisApiController{}, "get:PsnPutNCDSOnRecord")
  71. beego.Router("/api/psn/ncds/unputonrecord", &HisApiController{}, "get:PsnPutUnNCDSOnRecord")
  72. beego.Router("/api/reversal", &HisApiController{}, "get:ReversalData")
  73. beego.Router("/api/reversal/other", &HisApiController{}, "get:ReversalOtherData")
  74. beego.Router("/api/settlelist/get", &HisApiController{}, "get:GetSettleList")
  75. beego.Router("/api/settlelisthosptial/get", &HisApiController{}, "get:GetSettleListHospital")
  76. beego.Router("/api/pwd/check", &HisApiController{}, "get:CheckCardPWD")
  77. beego.Router("/api/insutype/check", &HisApiController{}, "get:CheckInsutype")
  78. //beego.Router("/api/batchsettlelist/get", &HisApiController{}, "get:GetBatchSettleList")
  79. beego.Router("/api/psn/info", &HisApiController{}, "get:GetPsnNcdsInfo")
  80. beego.Router("/api/allopatry/refund", &HisApiController{}, "post:RefundAllopatry")
  81. beego.Router("/api/check", &HisApiController{}, "get:Check")
  82. //beego.Router("/api/check3101", &HisApiController{}, "get:Check3101")
  83. //beego.Router("/api/check3102", &HisApiController{}, "get:Check3102")
  84. beego.Router("/90990", &HisApiController{}, "get:CheckCardPWDTwo")
  85. beego.Router("/9001", &HisApiController{}, "get:Get9001")
  86. //beego.Router("/api/readelecard", &HisApiController{}, "get:ReadEleCard")
  87. beego.Router("/api/3202", &HisApiController{}, "get:Post3202")
  88. beego.Router("/api/3202b", &HisApiController{}, "get:Post3202b")
  89. beego.Router("/api/1608", &HisApiController{}, "get:Post1608")
  90. beego.Router("/api/5302", &HisApiController{}, "get:Post5302")
  91. beego.Router("/api/3501", &HisApiController{}, "post:Post3501")
  92. beego.Router("/api/readele", &HisApiController{}, "get:ReadEleToken")
  93. beego.Router("/api/2505", &HisApiController{}, "get:Get2505")
  94. beego.Router("/api/4201A", &HisApiController{}, "get:Get4201A")
  95. beego.Router("/api/4202", &HisApiController{}, "get:Get4202")
  96. beego.Router("/api/4203", &HisApiController{}, "get:Get4203")
  97. beego.Router("/api/4205", &HisApiController{}, "get:Get4205")
  98. beego.Router("/api/4207", &HisApiController{}, "get:Get4207")
  99. beego.Router("/api/4208", &HisApiController{}, "get:Get4208")
  100. beego.Router("/api/4209", &HisApiController{}, "get:Get4209")
  101. beego.Router("/api/allopatry/get", &HisApiController{}, "get:GetAllopatry")
  102. //beego.Router("/api/comfirmallopatry/post", &HisApiController{}, "post:ComfirmAllopatry")
  103. beego.Router("/api/allopatry/refund", &HisApiController{}, "get:RefundAllopatry")
  104. beego.Router("/api/settle/query/batch", &HisApiController{}, "get:GetBatchSettleAccounts")
  105. beego.Router("/api/bl4201A", &HisApiController{}, "get:GetBL4201A")
  106. beego.Router("/api/bl4201A", &HisApiController{}, "get:GetBL4201A")
  107. beego.Router("/api/CFYLJG001", &HisApiController{}, "get:GetCFYLJG001")
  108. beego.Router("/api/CFYLJG002", &HisApiController{}, "get:GetCFYLJG002")
  109. beego.Router("/api/CFYLJG003", &HisApiController{}, "get:GetCFYLJG003")
  110. beego.Router("/api/CFYLJG004", &HisApiController{}, "get:GetCFYLJG004")
  111. beego.Router("/api/CFYLJG005", &HisApiController{}, "get:GetCFYLJG005")
  112. beego.Router("/api/CFYLJG006", &HisApiController{}, "get:GetCFYLJG006")
  113. beego.Router("/api/CFYLJG007", &HisApiController{}, "get:GetCFYLJG007")
  114. beego.Router("/api/CFYLJG008", &HisApiController{}, "get:GetCFYLJG008")
  115. //beego.Router("/api/CFYLJG009", &HisApiController{}, "get:GetCFYLJG009")
  116. //beego.Router("/api/2205", &HisApiController{}, "get:Get2205")
  117. beego.Router("/api/3260", &HisApiController{}, "get:Get3260")
  118. beego.Router("/api/3261", &HisApiController{}, "get:Get3261")
  119. beego.Router("/api/3262", &HisApiController{}, "get:Get3262")
  120. beego.Router("/api/3263", &HisApiController{}, "get:Get3263")
  121. beego.Router("/api/3264", &HisApiController{}, "get:Get3264")
  122. beego.Router("/api/3265", &HisApiController{}, "get:Get3265")
  123. beego.Router("/api/3266", &HisApiController{}, "get:Get3266")
  124. beego.Router("/api/3267", &HisApiController{}, "get:Get3267")
  125. beego.Router("/api/3268", &HisApiController{}, "get:Get3268")
  126. beego.Router("/api/3269", &HisApiController{}, "get:Get3269")
  127. beego.Router("/api/3270", &HisApiController{}, "get:Get3270")
  128. beego.Router("/api/3271", &HisApiController{}, "get:Get3271")
  129. beego.Router("/api/3272", &HisApiController{}, "get:Get3272")
  130. beego.Router("/api/3273", &HisApiController{}, "get:Get3273")
  131. beego.Router("/api/3274", &HisApiController{}, "get:Get3274")
  132. beego.Router("/api/3275", &HisApiController{}, "get:Get3275")
  133. beego.Router("/api/3276", &HisApiController{}, "get:Get3276")
  134. beego.Router("/api/3277", &HisApiController{}, "get:Get3277")
  135. beego.Router("/api/comfirm/upload", &HisApiController{}, "get:Get4102")
  136. beego.Router("/api/batch/check_drug", &HisApiController{}, "get:Drugscheck")
  137. beego.Router("/api/batch/check_good", &HisApiController{}, "get:Goodcheck")
  138. beego.Router("/api/batch/check_project", &HisApiController{}, "get:Projectcheck")
  139. beego.Router("/api/querydata", &HisApiController{}, "get:Getquerydata")
  140. //beego.Router("/api/5267", &HisApiController{}, "get:Get5267")
  141. //beego.Router("/api/1312a", &HisApiController{}, "get:Get1312a")
  142. //beego.Router("/api/cancledia/get", &HisApiController{}, "get:CancleDia")
  143. beego.Router("/api/4105", &HisApiController{}, "get:Get4105")
  144. beego.Router("/api/4104", &HisApiController{}, "get:Get4104")
  145. beego.Router("/api/2406", &HisApiController{}, "get:Get2406")
  146. beego.Router("/api/2503", &HisApiController{}, "get:Get2503")
  147. beego.Router("/api/1318", &HisApiController{}, "get:Get1318")
  148. beego.Router("/api/readelebyface", &HisApiController{}, "get:ReadEleFace")
  149. beego.Router("/api/settlelist/get/batch", &HisApiController{}, "get:GetbatchSettleList")
  150. //库盘和变更
  151. beego.Router("/api/pc_bg", &HisApiController{}, "get:FJ3501AND3502")
  152. //删除库盘和变更
  153. beego.Router("/api/delete_pc_bg", &HisApiController{}, "get:DeletePCandBG")
  154. beego.Router("/api/delete_xs_bg", &HisApiController{}, "get:DeleteXSandBG")
  155. //药品变更
  156. beego.Router("/api/changedrug", &HisApiController{}, "get:ChangeDrug")
  157. }
  158. func (c *HisApiController) FJ3501AND3502() {
  159. ids := c.GetString("ids")
  160. admin_user_id, _ := c.GetInt64("admin_user_id")
  161. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  162. id_arr := strings.Split(ids, ",")
  163. drugs, _ := service.GetNewDrugWarehouseInfo(id_arr)
  164. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  165. //库盘
  166. var errs []string
  167. for _, drug := range drugs {
  168. if drug.IsPc == 0 && drug.IsBg == 0 {
  169. var res2 ResultSix
  170. var res3 ResultSix
  171. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(drug.ID, 10) + "-" + "3501"
  172. var struct3501 models.Struct3501
  173. struct3501.OrgName = miConfig.OrgName
  174. struct3501.AccessKey = miConfig.AccessKey
  175. struct3501.Opter = roles.UserName
  176. struct3501.RequestUrl = miConfig.Url
  177. struct3501.Url = miConfig.Url
  178. struct3501.AppId = miConfig.Cainfo
  179. struct3501.AppSecret = miConfig.AppSecret
  180. struct3501.Enckey = miConfig.EncKey
  181. struct3501.SignKey = miConfig.SignKey
  182. struct3501.SecretKey = miConfig.SecretKey
  183. struct3501.MedListCodg = drug.BaseDrugLib.MedicalInsuranceNumber
  184. struct3501.FixmedinsHilistId = miConfig.Code
  185. struct3501.FixmedinsHilistName = miConfig.OrgName
  186. struct3501.RxFlag = "0"
  187. struct3501.Invdate = time.Unix(drug.Ctime, 0).Format("2006-01-02")
  188. struct3501.ManuDate = time.Unix(drug.ProductDate, 0).Format("2006-01-02")
  189. struct3501.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  190. struct3501.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  191. struct3501.InvCnt = strconv.FormatInt(drug.StockMaxNumber, 10)
  192. struct3501.ExpyEnd = time.Unix(drug.ExpiryDate, 0).Format("2006-01-02")
  193. struct3501.FixmedinsBchno = number
  194. memo := make(map[string]interface{})
  195. memo["pric"] = drug.Price
  196. bytesData, _ := json.Marshal(memo)
  197. struct3501.Memo = string(bytesData)
  198. result1, result2, _ := service.FJyb3501(struct3501)
  199. saveLog(result1, result2, "3501", "3501")
  200. //saveLog(result, requestLog, "2201", "挂号")
  201. var respJSON2 map[string]interface{}
  202. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  203. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  204. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  205. return
  206. }
  207. userJSONBytes2, _ := json.Marshal(respJSON2)
  208. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  209. utils.ErrorLog("解析失败:%v", err)
  210. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  211. return
  212. }
  213. if res2.Infcode != -1 {
  214. drug.IsPc = 1
  215. drug.Bchno = number
  216. drug.PcDate = time.Now().Format("2006-01-02")
  217. err := service.SaveW(drug)
  218. if err == nil {
  219. var struct3502 models.Struct3502
  220. struct3502.MedListCodg = drug.BaseDrugLib.MedicalInsuranceNumber
  221. struct3502.FixmedinsHilistId = miConfig.Code
  222. struct3502.FixmedinsHilistName = miConfig.OrgName
  223. struct3502.FixmedinsCode = miConfig.Code
  224. struct3502.RxFlag = "0"
  225. struct3502.InvChgTime = time.Now().Format("2006-01-02")
  226. struct3502.OrgName = miConfig.OrgName
  227. struct3501.Opter = roles.UserName
  228. struct3502.AccessKey = miConfig.AccessKey
  229. struct3502.RequestUrl = miConfig.Url
  230. struct3502.SecretKey = miConfig.SecretKey
  231. struct3502.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  232. struct3502.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  233. struct3502.Url = miConfig.Url
  234. struct3502.AppId = miConfig.Cainfo
  235. struct3502.AppSecret = miConfig.AppSecret
  236. struct3502.Enckey = miConfig.EncKey
  237. struct3502.SignKey = miConfig.SignKey
  238. struct3502.SecretKey = miConfig.SecretKey
  239. struct3502.Memo = ""
  240. struct3502.InvChgType = "108"
  241. struct3502.FixmedinsBchno = drug.Bchno
  242. struct3502.Cnt = strconv.FormatInt(drug.WarehousingCount, 10)
  243. struct3502.Pric = fmt.Sprintf("%.2f", drug.BaseDrugLib.RetailPrice)
  244. result11, result22, _ := service.FJyb3502(struct3502)
  245. saveLog(result11, result22, "3502", "3502")
  246. var respJSON3 map[string]interface{}
  247. if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  248. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  249. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  250. return
  251. }
  252. userJSONBytes3, _ := json.Marshal(respJSON3)
  253. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  254. utils.ErrorLog("解析失败:%v", err)
  255. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  256. return
  257. }
  258. if res3.Infcode == -1 {
  259. errs = append(errs, "变更"+drug.BaseDrugLib.DrugName+",出错:"+res3.ErrMsg)
  260. c.ServeSuccessJSON(map[string]interface{}{
  261. "failed_code": -10,
  262. "msg": res3.ErrMsg,
  263. })
  264. } else {
  265. drug.IsBg = 1
  266. service.SaveW(drug)
  267. }
  268. }
  269. } else {
  270. errs = append(errs, "盘存"+drug.BaseDrugLib.DrugName+",出错:"+res2.ErrMsg)
  271. }
  272. }
  273. //变更
  274. if drug.IsPc == 1 && drug.IsBg == 0 {
  275. var res3 ResultSix
  276. var struct3502 models.Struct3502
  277. struct3502.MedListCodg = drug.BaseDrugLib.MedicalInsuranceNumber
  278. struct3502.FixmedinsHilistId = miConfig.Code
  279. struct3502.FixmedinsHilistName = miConfig.OrgName
  280. struct3502.FixmedinsCode = miConfig.Code
  281. struct3502.Opter = roles.UserName
  282. struct3502.RxFlag = "0"
  283. struct3502.InvChgTime = time.Unix(drug.Ctime, 0).Format("2006-01-02 15:04:05")
  284. struct3502.OrgName = miConfig.OrgName
  285. struct3502.AccessKey = miConfig.AccessKey
  286. struct3502.RequestUrl = miConfig.Url
  287. struct3502.SecretKey = miConfig.SecretKey
  288. struct3502.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  289. struct3502.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  290. struct3502.InvChgType = "108"
  291. struct3502.Url = miConfig.Url
  292. struct3502.AppId = miConfig.Cainfo
  293. struct3502.AppSecret = miConfig.AppSecret
  294. struct3502.Enckey = miConfig.EncKey
  295. struct3502.SignKey = miConfig.SignKey
  296. struct3502.SecretKey = miConfig.SecretKey
  297. struct3502.FixmedinsBchno = drug.Bchno
  298. struct3502.Cnt = strconv.FormatInt(drug.WarehousingCount, 10)
  299. struct3502.Pric = fmt.Sprintf("%.2f", drug.BaseDrugLib.RetailPrice)
  300. result1, result2, _ := service.FJyb3502(struct3502)
  301. saveLog(result1, result2, "3502", "3502")
  302. var respJSON3 map[string]interface{}
  303. if err := json.Unmarshal([]byte(string(result1)), &respJSON3); err != nil {
  304. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  305. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  306. return
  307. }
  308. userJSONBytes3, _ := json.Marshal(respJSON3)
  309. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  310. utils.ErrorLog("解析失败:%v", err)
  311. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  312. return
  313. }
  314. if res3.Infcode == -1 {
  315. errs = append(errs, "变更"+drug.BaseDrugLib.DrugName+",出错:"+res3.ErrMsg)
  316. } else {
  317. drug.IsBg = 1
  318. //drug.Bchno = number
  319. //drug.PcDate = time.Now().Format("2006-01-02")
  320. service.SaveW(drug)
  321. }
  322. }
  323. }
  324. if len(errs) == 0 {
  325. c.ServeSuccessJSON(map[string]interface{}{
  326. "msg": "盘存变更成功",
  327. })
  328. } else {
  329. c.ServeSuccessJSON(map[string]interface{}{
  330. "failed_code": -10,
  331. "msg": errs,
  332. })
  333. }
  334. }
  335. func (c *HisApiController) DeletePCandBG() {
  336. ids := c.GetString("ids")
  337. id_arr := strings.Split(ids, ",")
  338. admin_user_id, _ := c.GetInt64("admin_user_id")
  339. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  340. drugs, _ := service.GetNewDrugWarehouseInfo(id_arr)
  341. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  342. var err []string
  343. for _, item := range drugs {
  344. if item.IsPc == 1 && item.IsBg == 1 {
  345. var res FJ3507Result
  346. var res2 FJ3507Result
  347. var struct3507 models.Struct3507
  348. struct3507.FixmedinsBchno = item.Bchno
  349. struct3507.InvDataType = "1"
  350. struct3507.Opter = roles.UserName
  351. struct3507.OrgName = miConfig.OrgName
  352. struct3507.AccessKey = miConfig.AccessKey
  353. struct3507.RequestUrl = miConfig.Url
  354. struct3507.SecretKey = miConfig.SecretKey
  355. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  356. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  357. struct3507.Url = miConfig.Url
  358. struct3507.AppId = miConfig.Cainfo
  359. struct3507.AppSecret = miConfig.AppSecret
  360. struct3507.Enckey = miConfig.EncKey
  361. struct3507.SignKey = miConfig.SignKey
  362. struct3507.SecretKey = miConfig.SecretKey
  363. result, result1, _ := service.FJyb3507(struct3507)
  364. saveLog(result, result1, "3507", "3507")
  365. var respJSON2 map[string]interface{}
  366. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  367. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  368. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  369. return
  370. }
  371. userJSONBytes2, _ := json.Marshal(respJSON2)
  372. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  373. utils.ErrorLog("解析失败:%v", err)
  374. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  375. return
  376. }
  377. if res.Infcode != -1 {
  378. item.IsPc = 0
  379. err2 := service.SaveW(item)
  380. if err2 == nil {
  381. var struct3507_2 models.Struct3507
  382. struct3507_2.OrgName = miConfig.OrgName
  383. struct3507_2.AccessKey = miConfig.AccessKey
  384. struct3507_2.RequestUrl = miConfig.Url
  385. struct3507_2.Opter = roles.UserName
  386. struct3507_2.SecretKey = miConfig.SecretKey
  387. struct3507_2.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  388. struct3507_2.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  389. struct3507_2.Url = miConfig.Url
  390. struct3507_2.AppId = miConfig.Cainfo
  391. struct3507_2.AppSecret = miConfig.AppSecret
  392. struct3507_2.Enckey = miConfig.EncKey
  393. struct3507_2.SignKey = miConfig.SignKey
  394. struct3507_2.SecretKey = miConfig.SecretKey
  395. struct3507_2.FixmedinsBchno = item.Bchno
  396. struct3507_2.InvDataType = "2"
  397. result11, result22, _ := service.FJyb3507(struct3507_2)
  398. saveLog(result11, result22, "3507", "3507")
  399. var respJSON3 map[string]interface{}
  400. if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  401. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  402. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  403. return
  404. }
  405. userJSONBytes3, _ := json.Marshal(respJSON3)
  406. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  407. utils.ErrorLog("解析失败:%v", err)
  408. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  409. return
  410. }
  411. if res2.Infcode != -1 {
  412. item.IsBg = 0
  413. item.Bchno = ""
  414. item.PcDate = ""
  415. service.SaveW(item)
  416. } else {
  417. err = append(err, "删除"+item.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  418. }
  419. }
  420. } else {
  421. err = append(err, "删除"+item.BaseDrugLib.DrugName+"盘存失败,失败原因:"+res.ErrMsg)
  422. }
  423. }
  424. if item.IsPc == 1 && item.IsBg == 0 {
  425. var res FJ3507Result
  426. var struct3507 models.Struct3507
  427. struct3507.FixmedinsBchno = item.Bchno
  428. struct3507.InvDataType = "2"
  429. struct3507.Opter = roles.UserName
  430. struct3507.OrgName = miConfig.OrgName
  431. struct3507.AccessKey = miConfig.AccessKey
  432. struct3507.RequestUrl = miConfig.Url
  433. struct3507.SecretKey = miConfig.SecretKey
  434. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  435. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  436. struct3507.Url = miConfig.Url
  437. struct3507.AppId = miConfig.Cainfo
  438. struct3507.AppSecret = miConfig.AppSecret
  439. struct3507.Enckey = miConfig.EncKey
  440. struct3507.SignKey = miConfig.SignKey
  441. struct3507.SecretKey = miConfig.SecretKey
  442. result, result1, _ := service.FJyb3507(struct3507)
  443. saveLog(result, result1, "3507", "3507")
  444. var respJSON3 map[string]interface{}
  445. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  446. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  447. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  448. return
  449. }
  450. userJSONBytes3, _ := json.Marshal(respJSON3)
  451. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  452. utils.ErrorLog("解析失败:%v", err)
  453. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  454. return
  455. }
  456. if res.Infcode != -1 {
  457. item.IsBg = 0
  458. item.Bchno = ""
  459. item.PcDate = ""
  460. service.SaveW(item)
  461. } else {
  462. err = append(err, "删除"+item.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  463. }
  464. }
  465. }
  466. if len(err) == 0 {
  467. c.ServeSuccessJSON(map[string]interface{}{
  468. "msg": "删除盘存变更成功",
  469. })
  470. } else {
  471. c.ServeSuccessJSON(map[string]interface{}{
  472. "failed_code": -10,
  473. "msg": err,
  474. })
  475. }
  476. }
  477. func (c *HisApiController) DeleteXSandBG() {
  478. ids := c.GetString("ids")
  479. id_arr := strings.Split(ids, ",")
  480. admin_user_id, _ := c.GetInt64("admin_user_id")
  481. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  482. drugs, _ := service.GetNewDrugWarehouseInfo(id_arr)
  483. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  484. for _, item := range drugs {
  485. if item.IsPc == 1 && item.IsBg == 1 {
  486. var struct3507 models.Struct3507
  487. struct3507.FixmedinsBchno = ""
  488. struct3507.InvDataType = "1"
  489. struct3507.Opter = roles.UserName
  490. struct3507.OrgName = miConfig.OrgName
  491. struct3507.AccessKey = miConfig.AccessKey
  492. struct3507.RequestUrl = miConfig.Url
  493. struct3507.SecretKey = miConfig.SecretKey
  494. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  495. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  496. struct3507.Url = miConfig.Url
  497. struct3507.AppId = miConfig.Cainfo
  498. struct3507.AppSecret = miConfig.AppSecret
  499. struct3507.Enckey = miConfig.EncKey
  500. struct3507.SignKey = miConfig.SignKey
  501. struct3507.SecretKey = miConfig.SecretKey
  502. struct3507.FixmedinsBchno = ""
  503. struct3507.InvDataType = "1"
  504. service.FJyb3507(struct3507)
  505. var struct3507_2 models.Struct3507
  506. struct3507_2.OrgName = miConfig.OrgName
  507. struct3507_2.AccessKey = miConfig.AccessKey
  508. struct3507_2.RequestUrl = miConfig.Url
  509. struct3507_2.SecretKey = miConfig.SecretKey
  510. struct3507_2.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  511. struct3507_2.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  512. struct3507_2.FixmedinsBchno = ""
  513. struct3507_2.InvDataType = "2"
  514. struct3507_2.Url = miConfig.Url
  515. struct3507_2.AppId = miConfig.Cainfo
  516. struct3507_2.AppSecret = miConfig.AppSecret
  517. struct3507_2.Enckey = miConfig.EncKey
  518. struct3507_2.SignKey = miConfig.SignKey
  519. struct3507_2.SecretKey = miConfig.SecretKey
  520. struct3507_2.FixmedinsBchno = ""
  521. struct3507_2.InvDataType = "1"
  522. service.FJyb3507(struct3507_2)
  523. }
  524. if item.IsPc == 1 && item.IsBg == 0 {
  525. var struct3507 models.Struct3507
  526. struct3507.OrgName = miConfig.OrgName
  527. struct3507.AccessKey = miConfig.AccessKey
  528. struct3507.RequestUrl = miConfig.Url
  529. struct3507.SecretKey = miConfig.SecretKey
  530. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  531. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  532. struct3507.FixmedinsBchno = ""
  533. struct3507.InvDataType = "1"
  534. service.FJyb3507(struct3507)
  535. }
  536. }
  537. }
  538. func (c *HisApiController) ChangeDrug() {
  539. ids := c.GetString("ids")
  540. id_arr := strings.Split(ids, ",")
  541. flows, _ := service.GetNewDrugFlowInfo(id_arr)
  542. admin_user_id, _ := c.GetInt64("admin_user_id")
  543. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  544. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  545. for _, item := range flows {
  546. if item.ConsumableType == 3 { //3为自动出库 7为自动退库
  547. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  548. if prescription.OrderStatus == 2 { //已经结算
  549. //判断是否已经销售
  550. if item.IsSale == 1 { //是否已经销售,1是 0否
  551. //是否已经变更 1是 0否
  552. if item.IsChange == 0 { //没变更,进行变更操作
  553. ChangeStock(item.Count, item.HisDoctorAdviceInfo, miConfig, "102", roles)
  554. }
  555. } else { //没销售,
  556. //进行商品销售接口
  557. SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item.HisDoctorAdviceInfo, miConfig, "", roles)
  558. if item.IsChange == 0 { //没变更,进行变更操作
  559. ChangeStock(item.Count, item.HisDoctorAdviceInfo, miConfig, "102", roles)
  560. }
  561. }
  562. } else { //还没结算
  563. if item.IsChange == 0 { //没变更,进行变更操作
  564. ChangeStock(item.Count, item.HisDoctorAdviceInfo, miConfig, "102", roles)
  565. }
  566. }
  567. } else if item.ConsumableType == 7 {
  568. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  569. order := service.GetHisOrderByNumber(prescription.BatchNumber)
  570. if order.OrderStatus == 2 || order.OrderStatus == 1 { //已经结算
  571. //判断是否已经销售
  572. if item.IsSale == 1 { //是否已经销售,1是 0否
  573. //是否已经变更 1是 0否
  574. if item.IsChange == 0 { //没变更,进行变更操作
  575. ChangeStock(item.Count, item.HisDoctorAdviceInfo, miConfig, "102", roles)
  576. }
  577. } else { //没销售,
  578. //进行商品销售退货接口
  579. CancleSaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item.HisDoctorAdviceInfo, miConfig, "")
  580. if item.IsChange == 0 { //没变更,进行变更操作
  581. ChangeStock(item.Count, item.HisDoctorAdviceInfo, miConfig, "102", roles)
  582. }
  583. }
  584. } else { //还没结算
  585. if item.IsChange == 0 { //没变更,进行变更操作
  586. ChangeStock(item.Count, item.HisDoctorAdviceInfo, miConfig, "102", roles)
  587. }
  588. }
  589. } else { //其他方式
  590. if item.IsChange == 0 { //没变更,进行变更操作
  591. ChangeStock(item.Count, item.HisDoctorAdviceInfo, miConfig, "102", roles)
  592. }
  593. }
  594. }
  595. }
  596. func ChangeStock(count int64, drug models.HisDoctorAdviceInfo, miConfig models.MedicalInsuranceOrgConfig, chgType string, role models.UserAdminRole) {
  597. var struct3502 models.Struct3502
  598. struct3502.MedListCodg = drug.BaseDrugLib.MedicalInsuranceNumber
  599. struct3502.FixmedinsHilistId = miConfig.Code
  600. struct3502.FixmedinsHilistName = miConfig.OrgName
  601. struct3502.FixmedinsCode = miConfig.Code
  602. struct3502.Opter = role.UserName
  603. struct3502.RxFlag = "0"
  604. struct3502.InvChgTime = time.Unix(drug.CreatedTime, 0).Format("2006-01-02 15:04:05")
  605. struct3502.OrgName = miConfig.OrgName
  606. struct3502.AccessKey = miConfig.AccessKey
  607. struct3502.RequestUrl = miConfig.Url
  608. struct3502.SecretKey = miConfig.SecretKey
  609. struct3502.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  610. struct3502.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  611. struct3502.Url = miConfig.Url
  612. struct3502.AppId = miConfig.Cainfo
  613. struct3502.AppSecret = miConfig.AppSecret
  614. struct3502.Enckey = miConfig.EncKey
  615. struct3502.SignKey = miConfig.SignKey
  616. struct3502.SecretKey = miConfig.SecretKey
  617. struct3502.InvChgType = chgType
  618. struct3502.FixmedinsBchno = ""
  619. struct3502.Cnt = strconv.FormatInt(count, 10)
  620. struct3502.Pric = fmt.Sprintf("%.2f", drug.Price)
  621. result1, result2, result3 := service.FJyb3502(struct3502)
  622. fmt.Println(result1)
  623. fmt.Println(result2)
  624. fmt.Println(result3)
  625. }
  626. func SaleStock(org_id int64, pre models.HisPrescription, drug models.HisDoctorAdviceInfo, miConfig models.MedicalInsuranceOrgConfig, chgType string, role models.UserAdminRole) {
  627. var struct3505 models.Struct3505
  628. struct3505.MedListCodg = drug.BaseDrugLib.MedicalInsuranceNumber
  629. struct3505.FixmedinsHilistId = miConfig.Code
  630. struct3505.FixmedinsHilistName = miConfig.OrgName
  631. struct3505.FixmedinsCode = miConfig.Code
  632. struct3505.FixmedinsBchno = ""
  633. roles, _ := service.GetAdminUserInfoByID(org_id, pre.Creator)
  634. struct3505.PrscDrName = roles.UserName
  635. struct3505.PharName = ""
  636. struct3505.PharPracCertNo = ""
  637. order := service.GetHisOrderByNumber(pre.BatchNumber)
  638. struct3505.SetlId = order.SetlId
  639. struct3505.MdtrtSn = order.MdtrtId
  640. struct3505.ManuLotnum = ""
  641. struct3505.ManuDate = ""
  642. struct3505.ExpyEnd = ""
  643. struct3505.RxFlag = "0"
  644. struct3505.TrdnFlag = "1"
  645. struct3505.Url = miConfig.Url
  646. struct3505.AppId = miConfig.Cainfo
  647. struct3505.AppSecret = miConfig.AppSecret
  648. struct3505.Enckey = miConfig.EncKey
  649. struct3505.SignKey = miConfig.SignKey
  650. struct3505.SecretKey = miConfig.SecretKey
  651. struct3505.RtalDocno = order.Number
  652. strValue := fmt.Sprintf("%.2f", drug.PrescribingNumber)
  653. struct3505.SelRetnCnt = strValue
  654. struct3505.SelRetnTime = time.Unix(drug.CreatedTime, 0).Format("2006-01-02 15:04:05")
  655. roles_two, _ := service.GetAdminUserInfoByID(org_id, order.Creator)
  656. struct3505.SelRetnOpterName = roles_two.UserName
  657. if order.IsMedicineInsurance == 1 {
  658. struct3505.MdtrtSetlType = "1"
  659. } else {
  660. struct3505.MdtrtSetlType = "2"
  661. }
  662. struct3505.OrgName = miConfig.OrgName
  663. struct3505.AccessKey = miConfig.AccessKey
  664. struct3505.RequestUrl = miConfig.Url
  665. struct3505.SecretKey = miConfig.SecretKey
  666. struct3505.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  667. struct3505.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  668. result1, result2, result3 := service.FJyb3505(struct3505)
  669. fmt.Println(result1)
  670. fmt.Println(result2)
  671. fmt.Println(result3)
  672. }
  673. func CancleSaleStock(org_id int64, pre models.HisPrescription, drug models.HisDoctorAdviceInfo, miConfig models.MedicalInsuranceOrgConfig, chgType string) {
  674. var struct3506 models.Struct3506
  675. struct3506.MedListCodg = drug.BaseDrugLib.MedicalInsuranceNumber
  676. struct3506.FixmedinsHilistId = miConfig.Code
  677. struct3506.FixmedinsHilistName = miConfig.OrgName
  678. struct3506.FixmedinsCode = miConfig.Code
  679. struct3506.FixmedinsBchno = ""
  680. order := service.GetHisOrderByNumber(pre.BatchNumber)
  681. //roles, _ := service.GetAdminUserInfoByID(org_id, pre.Creator)
  682. struct3506.ManuLotnum = ""
  683. struct3506.ManuDate = ""
  684. struct3506.MdtrtSn = order.MdtrtId
  685. struct3506.ExpyEnd = ""
  686. struct3506.RxFlag = "0"
  687. struct3506.TrdnFlag = "1"
  688. strValue := fmt.Sprintf("%.2f", drug.PrescribingNumber)
  689. struct3506.SelRetnCnt = strValue
  690. struct3506.SelRetnTime = time.Unix(drug.CreatedTime, 0).Format("2006-01-02 15:04:05")
  691. roles_two, _ := service.GetAdminUserInfoByID(org_id, order.Creator)
  692. struct3506.SelRetnOpterName = roles_two.UserName
  693. struct3506.OrgName = miConfig.OrgName
  694. struct3506.AccessKey = miConfig.AccessKey
  695. struct3506.RequestUrl = miConfig.Url
  696. struct3506.SecretKey = miConfig.SecretKey
  697. struct3506.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  698. struct3506.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  699. struct3506.Url = miConfig.Url
  700. struct3506.AppId = miConfig.Cainfo
  701. struct3506.AppSecret = miConfig.AppSecret
  702. struct3506.Enckey = miConfig.EncKey
  703. struct3506.SignKey = miConfig.SignKey
  704. struct3506.SecretKey = miConfig.SecretKey
  705. result1, result2, result3 := service.FJyb3506(struct3506)
  706. fmt.Println(result1)
  707. fmt.Println(result2)
  708. fmt.Println(result3)
  709. }
  710. func (c *HisApiController) Get1318() {
  711. adminUser := c.GetAdminUserInfo()
  712. admin_user_id, _ := c.GetInt64("admin_user_id")
  713. code := c.GetString("code")
  714. code = ""
  715. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  716. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  717. api := ""
  718. if miConfig.MdtrtareaAdmvs == "320921" {
  719. api = "http://192.168.2.3:9532/" + "jsyb/1318?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  720. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&h_code=" + code
  721. } else {
  722. api = "http://192.168.5.251:9532/" + "jsyb/1318?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  723. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&h_code=" + code
  724. }
  725. resp, requestErr := http.Get(api)
  726. if requestErr != nil {
  727. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  728. return
  729. }
  730. body, ioErr := ioutil.ReadAll(resp.Body)
  731. if ioErr != nil {
  732. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  733. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  734. return
  735. }
  736. var respJSON map[string]interface{}
  737. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  738. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  739. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  740. return
  741. }
  742. //var res Result2406
  743. /*respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  744. result, _ := json.Marshal(respJSON)
  745. if err := json.Unmarshal([]byte(result), &res); err != nil {
  746. utils.ErrorLog("解析失败:%v", err)
  747. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  748. return
  749. }
  750. if res.Infcode == "0" {
  751. c.ServeSuccessJSON(map[string]interface{}{
  752. "result": "",
  753. })
  754. } else {
  755. c.ServeSuccessJSON(map[string]interface{}{
  756. "failed_code": -10,
  757. "msg": res.ErrMsg,
  758. })
  759. */return
  760. //}
  761. }
  762. func (c *HisApiController) Get2503() {
  763. adminUser := c.GetAdminUserInfo()
  764. admin_user_id, _ := c.GetInt64("admin_user_id")
  765. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  766. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  767. service.Gxyb2503(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.MdtrtareaAdmvs, miConfig.InsuplcAdmdvs, "", admin_user_id)
  768. }
  769. func (c *HisApiController) Get2406() {
  770. id, _ := c.GetInt64("id")
  771. record_time := c.GetString("record_time")
  772. his_patient_id, _ := c.GetInt64("his_patient_id")
  773. admin_user_id, _ := c.GetInt64("admin_user_id")
  774. diagnosis_id := c.GetString("diagnosis")
  775. timeLayout := "2006-01-02"
  776. loc, _ := time.LoadLocation("Local")
  777. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  778. if err != nil {
  779. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  780. return
  781. }
  782. recordDateTime := theTime.Unix()
  783. adminUser := c.GetAdminUserInfo()
  784. diagnosis_ids := strings.Split(diagnosis_id, ",")
  785. var config []*models.HisXtDiagnoseConfig
  786. for _, item := range diagnosis_ids {
  787. id, _ := strconv.ParseInt(item, 10, 64)
  788. diagnosisConfig, _ := service.FindDiagnoseById(id)
  789. config = append(config, &diagnosisConfig)
  790. }
  791. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  792. fmt.Println(his_patient_id)
  793. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  794. //timestamp := time.Now().Unix()
  795. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  796. var patientPrescription models.HisPrescriptionInfo
  797. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  798. if patientPrescription.ID == 0 {
  799. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  800. }
  801. var res2 Result2406
  802. if miConfig.MdtrtareaAdmvs == "341203" {
  803. data := make(map[string]interface{})
  804. client := &http.Client{}
  805. data["psn_no"] = his.PsnNo
  806. data["mdtrt_id"] = his.Number
  807. data["operator"] = roles.UserName
  808. data["cert_no"] = his.IdCardNo
  809. data["org_name"] = miConfig.OrgName
  810. data["psn_name"] = his.Name
  811. data["ipt_otp_no"] = his.IptOtpNo
  812. data["ipt_psn_sp_flag_type"] = "0901"
  813. data["ipt_psn_sp_flag"] = "1"
  814. data["fixmedins_code"] = miConfig.Code
  815. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  816. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  817. data["url"] = miConfig.Url
  818. utils.ErrorLog("接口返回数据解析JSON失败: %v", data)
  819. bytesData, _ := json.Marshal(data)
  820. var req *http.Request
  821. utils.ErrorLog("接口返回数据解析JSON失败: %v", miConfig.SecretKey)
  822. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2406", bytes.NewReader(bytesData))
  823. resp, _ := client.Do(req)
  824. defer resp.Body.Close()
  825. body, ioErr := ioutil.ReadAll(resp.Body)
  826. if ioErr != nil {
  827. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  828. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  829. return
  830. }
  831. var respJSON map[string]interface{}
  832. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  833. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  834. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  835. return
  836. }
  837. status := respJSON["data"].(map[string]interface{})["status"].(string)
  838. if status == "0" {
  839. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  840. c.ServeSuccessJSON(map[string]interface{}{
  841. "failed_code": -10,
  842. "msg": err_msg,
  843. })
  844. return
  845. }
  846. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  847. userJSONBytes, _ := json.Marshal(respJSON)
  848. fmt.Println("log")
  849. fmt.Println(string(userJSONBytes))
  850. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  851. utils.ErrorLog("解析失败:%v", err)
  852. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  853. return
  854. }
  855. }
  856. if res2.Infcode != 0 {
  857. adminUser := c.GetAdminUserInfo()
  858. errlog := &models.HisOrderError{
  859. UserOrgId: adminUser.CurrentOrgId,
  860. Ctime: time.Now().Unix(),
  861. Mtime: time.Now().Unix(),
  862. ErrMsg: res2.ErrMsg,
  863. Status: 1,
  864. PatientId: id,
  865. RecordTime: recordDateTime,
  866. Stage: 3,
  867. }
  868. service.CreateErrMsgLog(errlog)
  869. c.ServeSuccessJSON(map[string]interface{}{
  870. "failed_code": -10,
  871. "msg": res2.ErrMsg,
  872. })
  873. return
  874. } else {
  875. c.ServeSuccessJSON(map[string]interface{}{
  876. "msg": "上传成功",
  877. })
  878. return
  879. }
  880. }
  881. func (c *HisApiController) Get4105() {
  882. }
  883. func (c *HisApiController) Post5302() {
  884. patient_id, _ := c.GetInt64("id")
  885. admin_user_id, _ := c.GetInt64("admin_user_id")
  886. p, _ := service.GetHisPatientById(patient_id)
  887. adminUser := c.GetAdminUserInfo()
  888. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  889. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  890. service.Gxyb5302(p.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  891. }
  892. func (c *HisApiController) Get4104() {
  893. }
  894. type Output struct {
  895. CertNo string `json:"certno"`
  896. PsnName string `json:"psn_name"`
  897. CardNo string `json:"card_no"`
  898. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  899. CardSN string `json:"card_sn"`
  900. PsnCertType string `json:"psn_cert_type"`
  901. MdtrtCertNo string `json:"mdtrt_cert_no"`
  902. MdtrtCertType string `json:"mdtrt_cert_type"`
  903. QRCode string `json:"qrCode"`
  904. EcToken string `json:"ecToken"`
  905. }
  906. type AHResponse struct {
  907. Body AHBody `json:"body"`
  908. Code int `json:"code"`
  909. CSBCode int `json:"csbCode"`
  910. Message string `json:"message"`
  911. RequestID string `json:"requestId"`
  912. State struct{} `json:"state"`
  913. }
  914. type AHBody struct {
  915. ErrMsg string `json:"err_msg"`
  916. InfRefMsgID string `json:"inf_refmsgid"`
  917. InfCode int `json:"infcode"`
  918. Output struct {
  919. Result []struct {
  920. BasMednFlag string `json:"bas_medn_flag"`
  921. ChldMedcFlag string `json:"chld_medc_flag"`
  922. ChrgitmLv string `json:"chrgitm_lv"`
  923. Cnt float64 `json:"cnt"`
  924. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  925. DrtReimFlag string `json:"drt_reim_flag"`
  926. FeedetlSn string `json:"feedetl_sn"`
  927. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  928. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  929. InscpScpAmt float64 `json:"inscp_scp_amt"`
  930. ListSpItemFlag string `json:"list_sp_item_flag"`
  931. LmtUsedFlag string `json:"lmt_used_flag"`
  932. MedChrgitmType string `json:"med_chrgitm_type"`
  933. Memo string `json:"memo"`
  934. OverlmtAmt float64 `json:"overlmt_amt"`
  935. PreselfpayAmt float64 `json:"preselfpay_amt"`
  936. Pric float64 `json:"pric"`
  937. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  938. SelfpayProp float64 `json:"selfpay_prop"`
  939. } `json:"result"`
  940. } `json:"output"`
  941. }
  942. type Response struct {
  943. Output Output `json:"output"`
  944. Infcode int `json:"infcode"`
  945. InfRefMsgID string `json:"inf_refmsgid"`
  946. RefMsgTime string `json:"refmsg_time"`
  947. RespondTime string `json:"respond_time"`
  948. ErrMsg string `json:"err_msg"`
  949. WarnMsg string `json:"warn_msg"`
  950. SignType string `json:"signtype"`
  951. CAInfo string `json:"cainfo"`
  952. }
  953. func (c *HisApiController) Getquerydata() {
  954. query_type, _ := c.GetInt64("type")
  955. refd_setl_flag := c.GetString("refd_setl_flag")
  956. med_type := c.GetString("med_type")
  957. //admin_user_id,_ := c.GetInt64("admin_user_id")
  958. cert_no := c.GetString("cert_no")
  959. psn_no := c.GetString("psn_no")
  960. start_time := c.GetString("start_time")
  961. end_time := c.GetString("end_time")
  962. page, _ := c.GetInt64("page")
  963. limit, _ := c.GetInt64("limit")
  964. var bp models.BusinessParams5262
  965. bp.RefdSetlFlag = refd_setl_flag
  966. bp.MedType = med_type
  967. bp.Certno = cert_no
  968. bp.Psnno = psn_no
  969. bp.QBegntime = start_time
  970. bp.QEndtime = end_time
  971. if query_type == 1 { //本地
  972. Post5262(c, bp, page, limit)
  973. } else { //异地
  974. Post5267(c, bp, page, limit)
  975. }
  976. }
  977. func (c *HisApiController) Drugscheck() {
  978. admin_user_id, _ := c.GetInt64("admin_user_id")
  979. adminUser := c.GetAdminUserInfo()
  980. var queryResult []QueryResult
  981. drugs, _ := service.GetBatchDrugListtw(adminUser.CurrentOrgId)
  982. for _, item := range drugs {
  983. result := QueryResult{
  984. ID: item.ID,
  985. Name: item.DrugName,
  986. Code: item.MedicalInsuranceNumber,
  987. List_type_code: "101",
  988. }
  989. queryResult = append(queryResult, result)
  990. }
  991. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  992. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  993. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  994. for _, item := range queryResult {
  995. 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)
  996. }
  997. }
  998. func (c *HisApiController) Goodcheck() {
  999. admin_user_id, _ := c.GetInt64("admin_user_id")
  1000. adminUser := c.GetAdminUserInfo()
  1001. var queryResult []QueryResult
  1002. goods, _ := service.GetBatchGoodInformationListtwo(adminUser.CurrentOrgId)
  1003. for _, item := range goods {
  1004. result := QueryResult{
  1005. ID: item.ID,
  1006. Name: item.GoodName,
  1007. Code: item.SocialSecurityDirectoryCode,
  1008. List_type_code: "301",
  1009. }
  1010. queryResult = append(queryResult, result)
  1011. }
  1012. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  1013. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  1014. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  1015. for _, item := range queryResult {
  1016. 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)
  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. }
  1019. }
  1020. func (c *HisApiController) Projectcheck() {
  1021. admin_user_id, _ := c.GetInt64("admin_user_id")
  1022. adminUser := c.GetAdminUserInfo()
  1023. var queryResult []QueryResult
  1024. projects, _ := service.GetBathchMyPorjecgListtwo(adminUser.CurrentOrgId)
  1025. for _, item := range projects {
  1026. result := QueryResult{
  1027. ID: item.ID,
  1028. Name: item.ProjectName,
  1029. Code: item.MedicalCode,
  1030. List_type_code: "201",
  1031. }
  1032. queryResult = append(queryResult, result)
  1033. }
  1034. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  1035. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  1036. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  1037. for _, item := range queryResult {
  1038. 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)
  1039. }
  1040. }
  1041. //func (c *HisApiController)CancleDia(){
  1042. //
  1043. // id, _ := c.GetInt64("id")
  1044. // record_time := c.GetString("record_time")
  1045. // his_patient_id, _ := c.GetInt64("his_patient_id")
  1046. //
  1047. // admin_user_id, _ := c.GetInt64("admin_user_id")
  1048. //
  1049. // diagnosis_id := c.GetString("diagnosis")
  1050. // sick_type, _ := c.GetInt64("sick_type")
  1051. // reg_type, _ := c.GetInt64("p_type")
  1052. // begin_time := c.GetString("begin_time")
  1053. // acct_used_flag_num, _ := c.GetInt64("acct_used_flag")
  1054. //
  1055. //
  1056. // acct_used_flag := strconv.FormatInt(acct_used_flag_num, 10)
  1057. //
  1058. // fmt.Println(acct_used_flag)
  1059. //
  1060. //
  1061. // timeLayout := "2006-01-02"
  1062. // loc, _ := time.LoadLocation("Local")
  1063. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  1064. // if err != nil {
  1065. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1066. // return
  1067. // }
  1068. // recordDateTime := theTime.Unix()
  1069. // adminUser := c.GetAdminUserInfo()
  1070. //
  1071. //
  1072. //
  1073. //
  1074. //
  1075. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  1076. // his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  1077. // var patientPrescription models.HisPrescriptionInfo
  1078. // patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  1079. // if patientPrescription.ID == 0 {
  1080. // patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  1081. // }
  1082. // //if patientPrescription.Do
  1083. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  1084. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  1085. //
  1086. // doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  1087. //
  1088. // diagnosis_ids := strings.Split(diagnosis_id, ",")
  1089. //
  1090. // var config []*models.HisXtDiagnoseConfig
  1091. // for _, item := range diagnosis_ids {
  1092. // id, _ := strconv.ParseInt(item, 10, 64)
  1093. // diagnosisConfig, _ := service.FindDiagnoseById(id)
  1094. // config = append(config, &diagnosisConfig)
  1095. // }
  1096. //
  1097. // sickConfig, _ := service.FindSickById(sick_type)
  1098. //
  1099. //
  1100. // data := make(map[string]interface{})
  1101. // client := &http.Client{}
  1102. // data["psn_no"] = his.PsnNo
  1103. // data["mdtrt_id"] = his.Number
  1104. // data["doctor"] = roles.UserName
  1105. // data["department"] = department.Name
  1106. // data["org_name"] = miConfig.OrgName
  1107. // data["med_type"] = strconv.FormatInt(reg_type, 10)
  1108. // data["doctor_id"] = doctor_info.DoctorNumber
  1109. // data["new_doctor_name"] = doctor_info.UserName
  1110. // data["fixmedins_code"] = miConfig.Code
  1111. // data["insuplc_admdvs"] = his.InsuplcAdmdvs
  1112. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  1113. // data["secret_key"] = miConfig.SecretKey
  1114. // data["sick_code"] = sickConfig.CountryCode
  1115. // data["sick_name"] = sickConfig.ClassName
  1116. // data["url"] = miConfig.Url
  1117. // data["ak"] = miConfig.AccessKey
  1118. // data["begin_time"] = begin_time
  1119. // data["cainfo"] = miConfig.Cainfo
  1120. // data["is_vaild"] = "0"
  1121. //
  1122. // data["dept"] = strconv.FormatInt(department.ID, 10)
  1123. // data["config"] = config
  1124. // bytesData, _ := json.Marshal(data)
  1125. //
  1126. // var req *http.Request
  1127. // req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2203C", bytes.NewReader(bytesData))
  1128. // resp, _ := client.Do(req)
  1129. // defer resp.Body.Close()
  1130. // body, ioErr := ioutil.ReadAll(resp.Body)
  1131. // if ioErr != nil {
  1132. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1133. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1134. // return
  1135. // }
  1136. // var respJSON map[string]interface{}
  1137. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1138. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1139. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1140. // return
  1141. // }
  1142. //
  1143. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1144. // userJSONBytes, _ := json.Marshal(respJSON)
  1145. // fmt.Println("log")
  1146. // fmt.Println(string(userJSONBytes))
  1147. //
  1148. // if err := json.Unmarshal(userJSONBytes, &ressix10265); err != nil {
  1149. // utils.ErrorLog("解析失败:%v", err)
  1150. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1151. // return
  1152. // }
  1153. // res2.InfRefmsgid = ressix10265.InfRefmsgid
  1154. // res2.Output = ressix10265.Output
  1155. // res2.ErrMsg = ressix10265.ErrMsg
  1156. // res2.Cainfo = ressix10265.Cainfo
  1157. // res2.WarnMsg = ressix10265.WarnMsg
  1158. // infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  1159. // res2.Infcode = infocode
  1160. //
  1161. //}
  1162. func (c *HisApiController) Get4102() {
  1163. order_id, _ := c.GetInt64("order_id")
  1164. admin_user_id, _ := c.GetInt64("admin_user_id")
  1165. stas_type := c.GetString("stas_type")
  1166. order, _ := service.GetHisOrderByIDTwo(order_id)
  1167. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1168. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1169. var pp models.PublicParams
  1170. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1171. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1172. pp.FixmedinsName = miConfig.OrgName
  1173. pp.FixmedinsCode = miConfig.Code
  1174. pp.RequestUrl = miConfig.Url
  1175. pp.Cainfo = miConfig.Cainfo
  1176. pp.SecretKey = miConfig.SecretKey
  1177. pp.AccessKey = miConfig.AccessKey
  1178. pp.OpterName = curRoles.UserName
  1179. if miConfig.MdtrtareaAdmvs == "350500" {
  1180. result, request, _ := service.Fjyb4102(order.PsnNo, order.SetlId, pp, stas_type)
  1181. //result, request := service.Jxyb4103(order.PsnNo,order.SetlId,pp)
  1182. saveLog(result, request, "4102", "清单确认")
  1183. var dat map[string]interface{}
  1184. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1185. fmt.Println(dat)
  1186. } else {
  1187. fmt.Println(err)
  1188. }
  1189. var empty ResultFourteen
  1190. userJSONBytes, _ := json.Marshal(dat)
  1191. if err := json.Unmarshal(userJSONBytes, &empty); err != nil {
  1192. utils.ErrorLog("解析失败:%v", err)
  1193. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1194. return
  1195. }
  1196. if empty.Infcode == 0 {
  1197. c.ServeSuccessJSON(map[string]interface{}{
  1198. "msg": "确认成功",
  1199. })
  1200. return
  1201. }
  1202. } else {
  1203. result, request := service.Jxyb4102(order.PsnNo, order.SetlId, pp, stas_type)
  1204. result2, request2 := service.Jxyb4103(order.PsnNo, order.SetlId, pp)
  1205. result3, request3 := service.Jxyb4105(pp)
  1206. saveLog(result, request, "4102", "清单确认")
  1207. saveLog(result2, request2, "4103", "清单确认")
  1208. saveLog(result3, request3, "4105", "清单统计")
  1209. var dat map[string]interface{}
  1210. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1211. fmt.Println(dat)
  1212. } else {
  1213. fmt.Println(err)
  1214. }
  1215. var empty ResultFourteen
  1216. userJSONBytes, _ := json.Marshal(dat)
  1217. if err := json.Unmarshal(userJSONBytes, &empty); err != nil {
  1218. utils.ErrorLog("解析失败:%v", err)
  1219. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1220. return
  1221. }
  1222. if empty.Infcode == 0 {
  1223. c.ServeSuccessJSON(map[string]interface{}{
  1224. "msg": "确认成功",
  1225. })
  1226. return
  1227. }
  1228. }
  1229. }
  1230. // 对账权限查询
  1231. func (c *HisApiController) Get3260() {
  1232. admin_user_id, _ := c.GetInt64("admin_user_id")
  1233. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1234. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1235. var api string
  1236. var res models.JSResult3260
  1237. if miConfig.MdtrtareaAdmvs == "320921" {
  1238. api = "http://192.168.2.3:9532/" + "jsyb/3260?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  1239. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  1240. } else {
  1241. api = "http://192.168.5.251:9532/" + "jsyb/3260?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  1242. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  1243. }
  1244. resp, requestErr := http.Get(api)
  1245. if requestErr != nil {
  1246. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1247. return
  1248. }
  1249. body, ioErr := ioutil.ReadAll(resp.Body)
  1250. if ioErr != nil {
  1251. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1252. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1253. return
  1254. }
  1255. var respJSON map[string]interface{}
  1256. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  1257. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1258. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1259. return
  1260. }
  1261. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1262. result, _ := json.Marshal(respJSON)
  1263. if err := json.Unmarshal([]byte(result), &res); err != nil {
  1264. utils.ErrorLog("解析失败:%v", err)
  1265. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1266. return
  1267. }
  1268. if res.Infcode == "0" {
  1269. c.ServeSuccessJSON(map[string]interface{}{
  1270. "result": res.Output.Data,
  1271. })
  1272. } else {
  1273. c.ServeSuccessJSON(map[string]interface{}{
  1274. "failed_code": -10,
  1275. "msg": res.ErrMsg,
  1276. })
  1277. return
  1278. }
  1279. }
  1280. func (c *HisApiController) Get3261() {
  1281. admin_user_id, _ := c.GetInt64("admin_user_id")
  1282. //month := c.GetString("month")
  1283. startTime := c.GetString("start_time")
  1284. //endTime, _ := c.GetString("end_time")
  1285. times := strings.Split(startTime, "-")
  1286. stmt_mon := times[0] + times[1]
  1287. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1288. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1289. var api string
  1290. var res models.JSResult3261
  1291. //var res10265 Result5301For10265
  1292. if miConfig.MdtrtareaAdmvs == "320921" {
  1293. api = "http://192.168.2.3:9532/" + "jsyb/3261?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  1294. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + stmt_mon
  1295. } else {
  1296. api = "http://192.168.5.251:9532/" + "jsyb/3261?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  1297. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + stmt_mon
  1298. }
  1299. resp, requestErr := http.Get(api)
  1300. if requestErr != nil {
  1301. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1302. return
  1303. }
  1304. body, ioErr := ioutil.ReadAll(resp.Body)
  1305. if ioErr != nil {
  1306. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1307. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1308. return
  1309. }
  1310. var respJSON map[string]interface{}
  1311. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  1312. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1313. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1314. return
  1315. }
  1316. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1317. result, _ := json.Marshal(respJSON)
  1318. if err := json.Unmarshal([]byte(result), &res); err != nil {
  1319. utils.ErrorLog("解析失败:%v", err)
  1320. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1321. return
  1322. }
  1323. if res.Infcode == "0" {
  1324. c.ServeSuccessJSON(map[string]interface{}{
  1325. "result": res.Output,
  1326. })
  1327. } else {
  1328. c.ServeSuccessJSON(map[string]interface{}{
  1329. "failed_code": -10,
  1330. "msg": res.ErrMsg,
  1331. })
  1332. return
  1333. }
  1334. }
  1335. type TempFun struct {
  1336. FundKey string
  1337. FundCode string
  1338. }
  1339. func (c *HisApiController) Get3262() {
  1340. admin_user_id, _ := c.GetInt64("admin_user_id")
  1341. startTime := c.GetString("start_time")
  1342. endTime := c.GetString("end_time")
  1343. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1344. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1345. //timeLayout := "2006-01-02"
  1346. //loc, _ := time.LoadLocation("Local")
  1347. //var theStartTIme int64
  1348. //if len(startTime) > 0 {
  1349. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", startTime+" 00:00:00", loc)
  1350. // if err != nil {
  1351. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1352. // return
  1353. // }
  1354. // theStartTIme = theTime.Unix()
  1355. //}
  1356. //var theEndtTIme int64
  1357. //if len(endTime) > 0 {
  1358. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", endTime+" 23:59:59", loc)
  1359. // if err != nil {
  1360. // utils.ErrorLog(err.Error())
  1361. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1362. // return
  1363. // }
  1364. // theEndtTIme = theTime.Unix()
  1365. //}
  1366. datas, _ := service.GetOrderByTimeTen(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId)
  1367. datas_two, _ := service.GetOrderByTimeTentwo(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId)
  1368. for _, team := range datas {
  1369. fmt.Println(team.PsnTime)
  1370. for _, team_two := range datas_two {
  1371. fmt.Println(team_two.PsnTime)
  1372. if team.FundKey == team_two.FundKey {
  1373. fmt.Println(team_two.PsnTime)
  1374. team.PsnTime = team.PsnTime + team_two.PsnTime*2
  1375. fmt.Println(team.PsnTime)
  1376. }
  1377. }
  1378. }
  1379. fmt.Println("1111")
  1380. fmt.Println(datas)
  1381. fmt.Println("1111")
  1382. var twos []models.FixMonRecDetailFileInTwo
  1383. for _, team := range datas {
  1384. var two models.FixMonRecDetailFileInTwo
  1385. two.MedType = team.MedType
  1386. two.Insutype = team.Insutype
  1387. two.PsnType = team.PsnType
  1388. two.MedType = team.MedType
  1389. two.FixBlngAdmdvs = "999999"
  1390. two.InsuAdmdvs = "555555"
  1391. two.PsnTime = team.PsnTime
  1392. two.PsnCnt = team.PsnCnt
  1393. two.FundKey = team.FundKey
  1394. ms, _ := strconv.ParseFloat(team.Sumamt, 64)
  1395. fps, _ := strconv.ParseFloat(team.Fund, 64)
  1396. ia, _ := strconv.ParseFloat(team.Amt, 64)
  1397. two.MedfeeSumAmt = ms
  1398. two.InscpAmt = ia
  1399. two.FundPaySumAmt = fps
  1400. twos = append(twos, two)
  1401. }
  1402. //startTime := c.GetString("start_time")
  1403. //endTime, _ := c.GetString("end_time")
  1404. times := strings.Split(startTime, "-")
  1405. stmt_mon := times[0] + times[1]
  1406. var funs []models.FundDetail
  1407. for _, item := range datas {
  1408. fun, _ := service.GetOrderDetailByTimeTen(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId, item.FundKey)
  1409. funs = append(funs, fun...)
  1410. }
  1411. var funInfos []models.Fund
  1412. //for _, item := range funs {
  1413. // var rf []models.FundInfo
  1414. // json.Unmarshal([]byte(item.SetlDetail), &rf)
  1415. // for _, subitem := range rf {
  1416. // var fund models.Fund
  1417. // fund.FundCode = subitem.FundPayType
  1418. // fund.FundName = subitem.FundPayTypeName
  1419. // fund.FundAmt = subitem.FundPayAmt
  1420. // fund.FundKey = item.FundKey
  1421. // fund.InsuAdmdvs = "555555"
  1422. // fund.FixBlngAdmdvs = "999999"
  1423. // funInfos = append(funInfos, fund)
  1424. // }
  1425. //}
  1426. var tempFuns []TempFun
  1427. for _, funInfo := range funInfos {
  1428. var tempFun TempFun
  1429. tempFun.FundKey = funInfo.FundKey
  1430. tempFun.FundCode = funInfo.FundCode
  1431. tempFuns = append(tempFuns, tempFun)
  1432. }
  1433. tempFuns = RemoveRepeatedFunElement(tempFuns)
  1434. fmt.Println(tempFuns)
  1435. var funInfosTwo []models.Fund
  1436. decimal.DivisionPrecision = 2
  1437. for _, item := range tempFuns {
  1438. var fund models.Fund
  1439. for _, subItem := range funInfos {
  1440. if item.FundKey == subItem.FundKey && item.FundCode == subItem.FundCode {
  1441. fund.FundKey = subItem.FundKey
  1442. fund.InsuAdmdvs = subItem.InsuAdmdvs
  1443. fund.FixBlngAdmdvs = subItem.FixBlngAdmdvs
  1444. fund.FundName = subItem.FundName
  1445. fund.FundCode = subItem.FundCode
  1446. fund.FundAmt, _ = decimal.NewFromFloat(fund.FundAmt).Add(decimal.NewFromFloat(subItem.FundAmt)).Float64()
  1447. }
  1448. }
  1449. funInfosTwo = append(funInfosTwo, fund)
  1450. }
  1451. fmt.Println("funInfosTwo")
  1452. fmt.Println(funInfosTwo)
  1453. var upld_btch string
  1454. var empty models.JSResultEmpty
  1455. data := make(map[string]interface{})
  1456. data["org_name"] = miConfig.OrgName
  1457. data["doctor"] = curRoles.UserName
  1458. data["doctor_name"] = curRoles.UserName
  1459. data["fixmedins_code"] = miConfig.Code
  1460. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  1461. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  1462. data["secret_key"] = miConfig.SecretKey
  1463. data["url"] = miConfig.Url
  1464. data["ak"] = miConfig.AccessKey
  1465. data["cainfo"] = miConfig.Cainfo
  1466. data["datas"] = twos
  1467. data["fund"] = funInfosTwo
  1468. fmt.Println(twos)
  1469. month := time.Unix(1557042972, 0).Format("1")
  1470. year := time.Now().Format("2006")
  1471. month = time.Now().Format("01")
  1472. day := time.Now().Format("02")
  1473. hour := time.Now().Format("15")
  1474. min := time.Now().Format("04")
  1475. sec := time.Now().Format("05")
  1476. fix_fill_date := year + month + day + hour + min + sec
  1477. data["fix_fill_dept"] = miConfig.OrgName
  1478. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  1479. data["fix_fill_psn"] = curRoles.UserName
  1480. data["fix_fill_date"] = fix_fill_date
  1481. data["stmt_loc"] = "2"
  1482. data["setl_mon"] = stmt_mon
  1483. upld_btch = "0"
  1484. data["upld_btch"] = upld_btch
  1485. //fmt.Println(data)
  1486. client := &http.Client{}
  1487. bytesData, _ := json.Marshal(data)
  1488. var req *http.Request
  1489. if miConfig.MdtrtareaAdmvs == "320921" {
  1490. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3262", bytes.NewReader(bytesData))
  1491. } else {
  1492. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3262", bytes.NewReader(bytesData))
  1493. }
  1494. resp, _ := client.Do(req)
  1495. defer resp.Body.Close()
  1496. body, ioErr := ioutil.ReadAll(resp.Body)
  1497. if ioErr != nil {
  1498. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1499. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1500. }
  1501. var respJSON map[string]interface{}
  1502. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1503. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1504. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1505. }
  1506. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1507. //fmt.Println(respJSON)
  1508. result, _ := json.Marshal(respJSON)
  1509. //fmt.Println(result)
  1510. if err := json.Unmarshal([]byte(result), &empty); err != nil {
  1511. utils.ErrorLog("解析失败:%v", err)
  1512. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1513. }
  1514. if empty.Infcode != "0" {
  1515. c.ServeSuccessJSON(map[string]interface{}{
  1516. "failed_code": -10,
  1517. "msg": empty.ErrMsg,
  1518. })
  1519. return
  1520. } else {
  1521. c.ServeSuccessJSON(map[string]interface{}{
  1522. "msg": "上传成功",
  1523. })
  1524. return
  1525. }
  1526. }
  1527. func RemoveRepeatedFunElement(arr []TempFun) (newArr []TempFun) {
  1528. newArr = make([]TempFun, 0)
  1529. for i := 0; i < len(arr); i++ {
  1530. repeat := false
  1531. for j := i + 1; j < len(arr); j++ {
  1532. if arr[i].FundKey == arr[j].FundKey && arr[i].FundCode == arr[j].FundCode {
  1533. repeat = true
  1534. break
  1535. }
  1536. }
  1537. if !repeat {
  1538. newArr = append(newArr, arr[i])
  1539. }
  1540. }
  1541. return
  1542. }
  1543. func (c *HisApiController) Get3263() {
  1544. admin_user_id, _ := c.GetInt64("admin_user_id")
  1545. startTime := c.GetString("start_time")
  1546. //endTime, _ := c.GetString("end_time")
  1547. times := strings.Split(startTime, "-")
  1548. setl_mon := times[0] + times[1]
  1549. upld_btch := "0"
  1550. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1551. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1552. var result3263 models.JSResult3263
  1553. data := make(map[string]interface{})
  1554. data["org_name"] = miConfig.OrgName
  1555. data["doctor"] = curRoles.UserName
  1556. data["doctor_name"] = curRoles.UserName
  1557. data["fixmedins_code"] = miConfig.Code
  1558. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  1559. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  1560. data["secret_key"] = miConfig.SecretKey
  1561. data["url"] = miConfig.Url
  1562. data["ak"] = miConfig.AccessKey
  1563. data["cainfo"] = miConfig.Cainfo
  1564. data["setl_mon"] = setl_mon
  1565. data["stmt_loc"] = "2"
  1566. data["upld_btch"] = upld_btch
  1567. client := &http.Client{}
  1568. bytesData, _ := json.Marshal(data)
  1569. var req *http.Request
  1570. if miConfig.MdtrtareaAdmvs == "320921" {
  1571. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3263", bytes.NewReader(bytesData))
  1572. } else {
  1573. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3263", bytes.NewReader(bytesData))
  1574. }
  1575. resp, _ := client.Do(req)
  1576. defer resp.Body.Close()
  1577. body, ioErr := ioutil.ReadAll(resp.Body)
  1578. if ioErr != nil {
  1579. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1580. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1581. }
  1582. var respJSON map[string]interface{}
  1583. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1584. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1585. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1586. }
  1587. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1588. fmt.Println(respJSON)
  1589. result, _ := json.Marshal(respJSON)
  1590. fmt.Println(result)
  1591. if err := json.Unmarshal([]byte(result), &result3263); err != nil {
  1592. utils.ErrorLog("解析失败:%v", err)
  1593. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1594. }
  1595. if result3263.Infcode != "0" {
  1596. c.ServeSuccessJSON(map[string]interface{}{
  1597. "failed_code": -10,
  1598. "msg": result3263.ErrMsg,
  1599. })
  1600. return
  1601. } else {
  1602. c.ServeSuccessJSON(map[string]interface{}{
  1603. "list": result3263.Output,
  1604. })
  1605. return
  1606. }
  1607. }
  1608. func (c *HisApiController) Get3264() {
  1609. admin_user_id, _ := c.GetInt64("admin_user_id")
  1610. startTime := c.GetString("start_time")
  1611. //endTime, _ := c.GetString("end_time")
  1612. times := strings.Split(startTime, "-")
  1613. setl_mon := times[0] + times[1]
  1614. upld_btch := "0"
  1615. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1616. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1617. //solidify_id := []
  1618. var result3263 models.JSResult3263
  1619. data := make(map[string]interface{})
  1620. data["org_name"] = miConfig.OrgName
  1621. data["doctor"] = curRoles.UserName
  1622. data["doctor_name"] = curRoles.UserName
  1623. data["fixmedins_code"] = miConfig.Code
  1624. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  1625. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  1626. data["secret_key"] = miConfig.SecretKey
  1627. data["url"] = miConfig.Url
  1628. data["ak"] = miConfig.AccessKey
  1629. data["cainfo"] = miConfig.Cainfo
  1630. data["setl_mon"] = setl_mon
  1631. data["stmt_loc"] = "2"
  1632. data["upld_btch"] = upld_btch
  1633. client := &http.Client{}
  1634. bytesData, _ := json.Marshal(data)
  1635. var req3263 *http.Request
  1636. if miConfig.MdtrtareaAdmvs == "320921" {
  1637. req3263, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3263", bytes.NewReader(bytesData))
  1638. } else {
  1639. req3263, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3263", bytes.NewReader(bytesData))
  1640. }
  1641. resp, _ := client.Do(req3263)
  1642. defer resp.Body.Close()
  1643. body, ioErr := ioutil.ReadAll(resp.Body)
  1644. if ioErr != nil {
  1645. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1646. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1647. }
  1648. var respJSON3263 map[string]interface{}
  1649. if err := json.Unmarshal([]byte(body), &respJSON3263); err != nil {
  1650. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1651. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1652. }
  1653. respJSON3263 = respJSON3263["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1654. fmt.Println(respJSON3263)
  1655. result, _ := json.Marshal(respJSON3263)
  1656. fmt.Println(result)
  1657. if err := json.Unmarshal([]byte(result), &result3263); err != nil {
  1658. utils.ErrorLog("解析失败:%v", err)
  1659. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1660. }
  1661. var ids []string
  1662. for _, item := range result3263.Output {
  1663. ids = append(ids, item.SolidifyID)
  1664. }
  1665. var empty models.JSResultEmpty
  1666. data2 := make(map[string]interface{})
  1667. data2["org_name"] = miConfig.OrgName
  1668. data2["doctor"] = curRoles.UserName
  1669. data2["doctor_name"] = curRoles.UserName
  1670. data2["fixmedins_code"] = miConfig.Code
  1671. data2["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  1672. data2["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  1673. data2["secret_key"] = miConfig.SecretKey
  1674. data2["url"] = miConfig.Url
  1675. data2["ak"] = miConfig.AccessKey
  1676. data2["cainfo"] = miConfig.Cainfo
  1677. data2["setl_mon"] = setl_mon
  1678. data2["stmt_loc"] = "2"
  1679. data2["upld_btch"] = upld_btch
  1680. data2["solidify_id"] = ids
  1681. client2 := &http.Client{}
  1682. bytesData2, _ := json.Marshal(data2)
  1683. var req *http.Request
  1684. if miConfig.MdtrtareaAdmvs == "320921" {
  1685. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3264", bytes.NewReader(bytesData2))
  1686. } else {
  1687. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3264", bytes.NewReader(bytesData2))
  1688. }
  1689. resp2, _ := client2.Do(req)
  1690. defer resp.Body.Close()
  1691. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  1692. if ioErr2 != nil {
  1693. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  1694. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1695. }
  1696. var respJSON map[string]interface{}
  1697. if err := json.Unmarshal([]byte(body2), &respJSON); err != nil {
  1698. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1699. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1700. }
  1701. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  1702. fmt.Println(respJSON)
  1703. result2, _ := json.Marshal(respJSON)
  1704. fmt.Println(result2)
  1705. if err := json.Unmarshal([]byte(result2), &empty); err != nil {
  1706. utils.ErrorLog("解析失败:%v", err)
  1707. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1708. }
  1709. if empty.Infcode != "0" {
  1710. c.ServeSuccessJSON(map[string]interface{}{
  1711. "failed_code": -10,
  1712. "msg": empty.ErrMsg,
  1713. })
  1714. return
  1715. } else {
  1716. c.ServeSuccessJSON(map[string]interface{}{
  1717. "msg": "",
  1718. })
  1719. return
  1720. }
  1721. }
  1722. func (c *HisApiController) Get3265() {
  1723. admin_user_id, _ := c.GetInt64("admin_user_id")
  1724. startTime := c.GetString("start_time")
  1725. //endTime, _ := c.GetString("end_time")
  1726. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1727. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1728. times := strings.Split(startTime, "-")
  1729. setl_mon := times[0] + times[1]
  1730. var upld_btch string
  1731. upld_btch = "0"
  1732. //var empty models.JSResultEmpty
  1733. var result3265 models.JSResult3264
  1734. var result3263 models.JSResult3263
  1735. data2 := make(map[string]interface{})
  1736. data2["org_name"] = miConfig.OrgName
  1737. data2["doctor"] = curRoles.UserName
  1738. data2["doctor_name"] = curRoles.UserName
  1739. data2["fixmedins_code"] = miConfig.Code
  1740. data2["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  1741. data2["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  1742. data2["secret_key"] = miConfig.SecretKey
  1743. data2["url"] = miConfig.Url
  1744. data2["ak"] = miConfig.AccessKey
  1745. data2["cainfo"] = miConfig.Cainfo
  1746. data2["setl_mon"] = setl_mon
  1747. data2["stmt_loc"] = "2"
  1748. data2["upld_btch"] = upld_btch
  1749. client2 := &http.Client{}
  1750. bytesData2, _ := json.Marshal(data2)
  1751. var req3263 *http.Request
  1752. if miConfig.MdtrtareaAdmvs == "320921" {
  1753. req3263, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3263", bytes.NewReader(bytesData2))
  1754. } else {
  1755. req3263, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3263", bytes.NewReader(bytesData2))
  1756. }
  1757. resp2, _ := client2.Do(req3263)
  1758. defer resp2.Body.Close()
  1759. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  1760. if ioErr2 != nil {
  1761. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  1762. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1763. }
  1764. var respJSON3263 map[string]interface{}
  1765. if err := json.Unmarshal([]byte(body2), &respJSON3263); err != nil {
  1766. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1767. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1768. }
  1769. respJSON3263 = respJSON3263["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1770. fmt.Println(respJSON3263)
  1771. result2, _ := json.Marshal(respJSON3263)
  1772. fmt.Println(result2)
  1773. if err := json.Unmarshal([]byte(result2), &result3263); err != nil {
  1774. utils.ErrorLog("解析失败:%v", err)
  1775. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1776. }
  1777. var ids []string
  1778. for _, item := range result3263.Output {
  1779. ids = append(ids, item.SolidifyID)
  1780. }
  1781. data := make(map[string]interface{})
  1782. data["org_name"] = miConfig.OrgName
  1783. data["doctor"] = curRoles.UserName
  1784. data["doctor_name"] = curRoles.UserName
  1785. data["fixmedins_code"] = miConfig.Code
  1786. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  1787. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  1788. data["secret_key"] = miConfig.SecretKey
  1789. data["url"] = miConfig.Url
  1790. data["ak"] = miConfig.AccessKey
  1791. data["cainfo"] = miConfig.Cainfo
  1792. data["setl_mon"] = setl_mon
  1793. data["solidify_id"] = ids
  1794. month := time.Unix(1557042972, 0).Format("1")
  1795. year := time.Now().Format("2006")
  1796. month = time.Now().Format("01")
  1797. day := time.Now().Format("02")
  1798. hour := time.Now().Format("15")
  1799. min := time.Now().Format("04")
  1800. sec := time.Now().Format("05")
  1801. fix_fill_date := year + month + day + hour + min + sec
  1802. data["fix_fill_dept"] = miConfig.OrgName
  1803. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  1804. data["fix_fill_psn"] = curRoles.UserName
  1805. data["fix_fill_date"] = fix_fill_date
  1806. data["stmt_loc"] = "2"
  1807. data["upld_btch"] = upld_btch
  1808. client := &http.Client{}
  1809. bytesData, _ := json.Marshal(data)
  1810. var req *http.Request
  1811. if miConfig.MdtrtareaAdmvs == "320921" {
  1812. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3265", bytes.NewReader(bytesData))
  1813. } else {
  1814. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3265", bytes.NewReader(bytesData))
  1815. }
  1816. resp, _ := client.Do(req)
  1817. defer resp.Body.Close()
  1818. body, ioErr := ioutil.ReadAll(resp.Body)
  1819. if ioErr != nil {
  1820. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1821. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1822. }
  1823. var respJSON map[string]interface{}
  1824. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1825. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1826. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1827. }
  1828. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1829. fmt.Println(respJSON)
  1830. result, _ := json.Marshal(respJSON)
  1831. fmt.Println(result)
  1832. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  1833. utils.ErrorLog("解析失败:%v", err)
  1834. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1835. }
  1836. if result3265.Infcode != "0" {
  1837. c.ServeSuccessJSON(map[string]interface{}{
  1838. "failed_code": -10,
  1839. "msg": result3265.ErrMsg,
  1840. })
  1841. return
  1842. } else {
  1843. c.ServeSuccessJSON(map[string]interface{}{
  1844. "info": result3265.Output,
  1845. })
  1846. return
  1847. }
  1848. }
  1849. func (c *HisApiController) Get3266() {
  1850. admin_user_id, _ := c.GetInt64("admin_user_id")
  1851. startTime := c.GetString("start_time")
  1852. //endTime, _ := c.GetString("end_time")
  1853. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1854. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1855. times := strings.Split(startTime, "-")
  1856. stmt_mon := times[0] + times[1]
  1857. var upld_btch string
  1858. //var empty models.JSResultEmpty
  1859. var result3265 models.JSResult3264
  1860. data := make(map[string]interface{})
  1861. data["org_name"] = miConfig.OrgName
  1862. data["doctor"] = curRoles.UserName
  1863. data["doctor_name"] = curRoles.UserName
  1864. data["fixmedins_code"] = miConfig.Code
  1865. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  1866. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  1867. data["secret_key"] = miConfig.SecretKey
  1868. data["url"] = miConfig.Url
  1869. data["ak"] = miConfig.AccessKey
  1870. data["cainfo"] = miConfig.Cainfo
  1871. data["setl_mon"] = stmt_mon
  1872. month := time.Unix(1557042972, 0).Format("1")
  1873. year := time.Now().Format("2006")
  1874. month = time.Now().Format("01")
  1875. day := time.Now().Format("02")
  1876. hour := time.Now().Format("15")
  1877. min := time.Now().Format("04")
  1878. sec := time.Now().Format("05")
  1879. fix_fill_date := year + month + day + hour + min + sec
  1880. data["fix_fill_dept"] = miConfig.OrgName
  1881. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  1882. data["fix_fill_psn"] = curRoles.UserName
  1883. data["fix_fill_date"] = fix_fill_date
  1884. data["stmt_loc"] = "2"
  1885. upld_btch = "0"
  1886. data["upld_btch"] = upld_btch
  1887. client := &http.Client{}
  1888. bytesData, _ := json.Marshal(data)
  1889. var req *http.Request
  1890. if miConfig.MdtrtareaAdmvs == "320921" {
  1891. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3266", bytes.NewReader(bytesData))
  1892. } else {
  1893. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3266", bytes.NewReader(bytesData))
  1894. }
  1895. resp, _ := client.Do(req)
  1896. defer resp.Body.Close()
  1897. body, ioErr := ioutil.ReadAll(resp.Body)
  1898. if ioErr != nil {
  1899. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1900. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1901. }
  1902. var respJSON map[string]interface{}
  1903. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1904. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1905. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1906. }
  1907. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1908. fmt.Println(respJSON)
  1909. result, _ := json.Marshal(respJSON)
  1910. fmt.Println(result)
  1911. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  1912. utils.ErrorLog("解析失败:%v", err)
  1913. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1914. }
  1915. if result3265.Infcode != "0" {
  1916. c.ServeSuccessJSON(map[string]interface{}{
  1917. "failed_code": -10,
  1918. "msg": result3265.ErrMsg,
  1919. })
  1920. return
  1921. } else {
  1922. c.ServeSuccessJSON(map[string]interface{}{
  1923. "info": result3265.Output,
  1924. })
  1925. return
  1926. }
  1927. }
  1928. func (c *HisApiController) Get3267() {
  1929. admin_user_id, _ := c.GetInt64("admin_user_id")
  1930. startTime := c.GetString("start_time")
  1931. //endTime, _ := c.GetString("end_time")
  1932. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1933. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1934. times := strings.Split(startTime, "-")
  1935. setl_mon := times[0] + times[1]
  1936. var upld_btch string
  1937. //var empty models.JSResultEmpty
  1938. var result3265 models.JSResult3264
  1939. upld_btch = "0"
  1940. data := make(map[string]interface{})
  1941. data["org_name"] = miConfig.OrgName
  1942. data["doctor"] = curRoles.UserName
  1943. data["doctor_name"] = curRoles.UserName
  1944. data["fixmedins_code"] = miConfig.Code
  1945. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  1946. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  1947. data["secret_key"] = miConfig.SecretKey
  1948. data["url"] = miConfig.Url
  1949. data["ak"] = miConfig.AccessKey
  1950. data["cainfo"] = miConfig.Cainfo
  1951. data["setl_mon"] = setl_mon
  1952. data["stmt_loc"] = "2"
  1953. data["upld_btch"] = upld_btch
  1954. client := &http.Client{}
  1955. bytesData, _ := json.Marshal(data)
  1956. var req *http.Request
  1957. if miConfig.MdtrtareaAdmvs == "320921" {
  1958. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3267", bytes.NewReader(bytesData))
  1959. } else {
  1960. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3267", bytes.NewReader(bytesData))
  1961. }
  1962. resp, _ := client.Do(req)
  1963. defer resp.Body.Close()
  1964. body, ioErr := ioutil.ReadAll(resp.Body)
  1965. if ioErr != nil {
  1966. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1967. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1968. }
  1969. var respJSON map[string]interface{}
  1970. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1971. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1972. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1973. }
  1974. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1975. fmt.Println(respJSON)
  1976. result, _ := json.Marshal(respJSON)
  1977. fmt.Println(result)
  1978. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  1979. utils.ErrorLog("解析失败:%v", err)
  1980. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1981. }
  1982. if result3265.Infcode != "0" {
  1983. c.ServeSuccessJSON(map[string]interface{}{
  1984. "failed_code": -10,
  1985. "msg": result3265.ErrMsg,
  1986. })
  1987. return
  1988. } else {
  1989. c.ServeSuccessJSON(map[string]interface{}{
  1990. "info": result3265.Output.Data,
  1991. })
  1992. return
  1993. }
  1994. }
  1995. func (c *HisApiController) Get3268() {
  1996. admin_user_id, _ := c.GetInt64("admin_user_id")
  1997. startTime := c.GetString("start_time")
  1998. endTime := c.GetString("end_time")
  1999. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2000. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2001. times := strings.Split(startTime, "-")
  2002. setl_mon := times[0] + times[1]
  2003. datas, _ := service.GetOrderByTimeTen(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId)
  2004. var twos []models.FixMonRecDetailFileInTwo
  2005. var funs []models.FundDetail
  2006. for _, item := range datas {
  2007. fun, _ := service.GetOrderDetailByTimeTen(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId, item.FundKey)
  2008. funs = append(funs, fun...)
  2009. }
  2010. var funInfos []models.Fund
  2011. //for _, item := range funs {
  2012. // var rf []models.FundInfo
  2013. // json.Unmarshal([]byte(item.SetlDetail), &rf)
  2014. // for _, subitem := range rf {
  2015. // var fund models.Fund
  2016. // fund.FundCode = subitem.FundPayType
  2017. // fund.FundName = subitem.FundPayTypeName
  2018. // fund.FundAmt = subitem.FundPayAmt
  2019. // fund.FundKey = item.FundKey
  2020. // fund.InsuAdmdvs = "555555"
  2021. // fund.FixBlngAdmdvs = miConfig.MdtrtareaAdmvs
  2022. // funInfos = append(funInfos, fund)
  2023. // }
  2024. //}
  2025. for _, team := range datas {
  2026. var two models.FixMonRecDetailFileInTwo
  2027. two.SetlDate = time.Now().Format("2006-01-02")
  2028. two.MedType = team.MedType
  2029. two.Insutype = team.Insutype
  2030. two.PsnType = team.PsnType
  2031. two.MedType = team.MedType
  2032. two.FixBlngAdmdvs = team.FixBlngAdmdvs
  2033. two.InsuAdmdvs = team.InsuAdmdvs
  2034. two.PsnTime = team.PsnTime
  2035. two.PsnCnt = team.PsnCnt
  2036. two.FundKey = team.FundKey
  2037. ms, _ := strconv.ParseFloat(team.Sumamt, 64)
  2038. fps, _ := strconv.ParseFloat(team.Fund, 64)
  2039. ia, _ := strconv.ParseFloat(team.Amt, 64)
  2040. two.MedfeeSumAmt = ms
  2041. two.InscpAmt = ia
  2042. two.FundPaySumAmt = fps
  2043. twos = append(twos, two)
  2044. }
  2045. var upld_btch string
  2046. upld_btch = "0"
  2047. var empty models.JSResultEmpty
  2048. data := make(map[string]interface{})
  2049. data["org_name"] = miConfig.OrgName
  2050. data["doctor"] = curRoles.UserName
  2051. data["doctor_name"] = curRoles.UserName
  2052. data["fixmedins_code"] = miConfig.Code
  2053. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  2054. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  2055. data["secret_key"] = miConfig.SecretKey
  2056. data["url"] = miConfig.Url
  2057. data["ak"] = miConfig.AccessKey
  2058. data["cainfo"] = miConfig.Cainfo
  2059. data["datas"] = twos
  2060. data["fund"] = funInfos
  2061. data["setl_mon"] = setl_mon
  2062. month := time.Unix(1557042972, 0).Format("1")
  2063. year := time.Now().Format("2006")
  2064. month = time.Now().Format("01")
  2065. day := time.Now().Format("02")
  2066. hour := time.Now().Format("15")
  2067. min := time.Now().Format("04")
  2068. sec := time.Now().Format("05")
  2069. fix_fill_date := year + month + day + hour + min + sec
  2070. data["fix_fill_dept"] = miConfig.OrgName
  2071. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  2072. data["fix_fill_psn"] = curRoles.UserName
  2073. data["fix_fill_date"] = fix_fill_date
  2074. data["stmt_loc"] = "2"
  2075. data["upld_btch"] = upld_btch
  2076. client := &http.Client{}
  2077. bytesData, _ := json.Marshal(data)
  2078. var req *http.Request
  2079. if miConfig.MdtrtareaAdmvs == "320921" {
  2080. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3268", bytes.NewReader(bytesData))
  2081. } else {
  2082. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3268", bytes.NewReader(bytesData))
  2083. }
  2084. resp, _ := client.Do(req)
  2085. defer resp.Body.Close()
  2086. body, ioErr := ioutil.ReadAll(resp.Body)
  2087. if ioErr != nil {
  2088. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2089. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2090. }
  2091. var respJSON map[string]interface{}
  2092. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2093. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2094. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2095. }
  2096. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2097. fmt.Println(respJSON)
  2098. result, _ := json.Marshal(respJSON)
  2099. fmt.Println(result)
  2100. if err := json.Unmarshal([]byte(result), &empty); err != nil {
  2101. utils.ErrorLog("解析失败:%v", err)
  2102. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2103. }
  2104. if empty.Infcode != "0" {
  2105. c.ServeSuccessJSON(map[string]interface{}{
  2106. "failed_code": -10,
  2107. "msg": empty.ErrMsg,
  2108. })
  2109. return
  2110. } else {
  2111. c.ServeSuccessJSON(map[string]interface{}{
  2112. "msg": "上传成功",
  2113. })
  2114. return
  2115. }
  2116. }
  2117. func (c *HisApiController) Get3269() {
  2118. admin_user_id, _ := c.GetInt64("admin_user_id")
  2119. startTime := c.GetString("start_time")
  2120. //endTime, _ := c.GetString("end_time")
  2121. times := strings.Split(startTime, "-")
  2122. setl_mon := times[0] + times[1]
  2123. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2124. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2125. var result3263 models.JSResult3263
  2126. data := make(map[string]interface{})
  2127. data["org_name"] = miConfig.OrgName
  2128. data["doctor"] = curRoles.UserName
  2129. data["doctor_name"] = curRoles.UserName
  2130. data["fixmedins_code"] = miConfig.Code
  2131. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  2132. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  2133. data["secret_key"] = miConfig.SecretKey
  2134. data["url"] = miConfig.Url
  2135. data["ak"] = miConfig.AccessKey
  2136. data["cainfo"] = miConfig.Cainfo
  2137. data["setl_mon"] = setl_mon
  2138. data["stmt_loc"] = "2"
  2139. client := &http.Client{}
  2140. bytesData, _ := json.Marshal(data)
  2141. var req *http.Request
  2142. if miConfig.MdtrtareaAdmvs == "320921" {
  2143. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3269", bytes.NewReader(bytesData))
  2144. } else {
  2145. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3269", bytes.NewReader(bytesData))
  2146. }
  2147. resp, _ := client.Do(req)
  2148. defer resp.Body.Close()
  2149. body, ioErr := ioutil.ReadAll(resp.Body)
  2150. if ioErr != nil {
  2151. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2152. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2153. }
  2154. var respJSON map[string]interface{}
  2155. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2156. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2157. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2158. }
  2159. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2160. fmt.Println(respJSON)
  2161. result, _ := json.Marshal(respJSON)
  2162. fmt.Println(result)
  2163. if err := json.Unmarshal([]byte(result), &result3263); err != nil {
  2164. utils.ErrorLog("解析失败:%v", err)
  2165. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2166. }
  2167. if result3263.Infcode != "0" {
  2168. c.ServeSuccessJSON(map[string]interface{}{
  2169. "failed_code": -10,
  2170. "msg": result3263.ErrMsg,
  2171. })
  2172. return
  2173. } else {
  2174. c.ServeSuccessJSON(map[string]interface{}{
  2175. "msg": "上传成功",
  2176. })
  2177. return
  2178. }
  2179. }
  2180. func (c *HisApiController) Get3270() {
  2181. admin_user_id, _ := c.GetInt64("admin_user_id")
  2182. startTime := c.GetString("start_time")
  2183. //endTime, _ := c.GetString("end_time")
  2184. times := strings.Split(startTime, "-")
  2185. setl_mon := times[0] + times[1]
  2186. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2187. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2188. var result3263 models.JSResult3263
  2189. data2 := make(map[string]interface{})
  2190. data2["org_name"] = miConfig.OrgName
  2191. data2["doctor"] = curRoles.UserName
  2192. data2["doctor_name"] = curRoles.UserName
  2193. data2["fixmedins_code"] = miConfig.Code
  2194. data2["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  2195. data2["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  2196. data2["secret_key"] = miConfig.SecretKey
  2197. data2["url"] = miConfig.Url
  2198. data2["ak"] = miConfig.AccessKey
  2199. data2["cainfo"] = miConfig.Cainfo
  2200. data2["setl_mon"] = setl_mon
  2201. data2["stmt_loc"] = "2"
  2202. client2 := &http.Client{}
  2203. bytesData2, _ := json.Marshal(data2)
  2204. var req3263 *http.Request
  2205. if miConfig.MdtrtareaAdmvs == "320921" {
  2206. req3263, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3269", bytes.NewReader(bytesData2))
  2207. } else {
  2208. req3263, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3269", bytes.NewReader(bytesData2))
  2209. }
  2210. resp2, _ := client2.Do(req3263)
  2211. defer resp2.Body.Close()
  2212. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  2213. if ioErr2 != nil {
  2214. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  2215. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2216. }
  2217. var respJSON3263 map[string]interface{}
  2218. if err := json.Unmarshal([]byte(body2), &respJSON3263); err != nil {
  2219. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2220. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2221. }
  2222. respJSON3263 = respJSON3263["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2223. fmt.Println(respJSON3263)
  2224. result2, _ := json.Marshal(respJSON3263)
  2225. fmt.Println(result2)
  2226. if err := json.Unmarshal([]byte(result2), &result3263); err != nil {
  2227. utils.ErrorLog("解析失败:%v", err)
  2228. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2229. }
  2230. var ids []string
  2231. for _, item := range result3263.Output {
  2232. ids = append(ids, item.SolidifyID)
  2233. }
  2234. var result3264 models.JSResult3264
  2235. data := make(map[string]interface{})
  2236. data["org_name"] = miConfig.OrgName
  2237. data["doctor"] = curRoles.UserName
  2238. data["doctor_name"] = curRoles.UserName
  2239. data["fixmedins_code"] = miConfig.Code
  2240. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  2241. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  2242. data["secret_key"] = miConfig.SecretKey
  2243. data["url"] = miConfig.Url
  2244. data["ak"] = miConfig.AccessKey
  2245. data["cainfo"] = miConfig.Cainfo
  2246. data["setl_mon"] = setl_mon
  2247. data["stmt_loc"] = "2"
  2248. data["solidify_id"] = ids
  2249. client := &http.Client{}
  2250. bytesData, _ := json.Marshal(data)
  2251. var req *http.Request
  2252. if miConfig.MdtrtareaAdmvs == "320921" {
  2253. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3270", bytes.NewReader(bytesData))
  2254. } else {
  2255. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3270", bytes.NewReader(bytesData))
  2256. }
  2257. resp, _ := client.Do(req)
  2258. defer resp.Body.Close()
  2259. body, ioErr := ioutil.ReadAll(resp.Body)
  2260. if ioErr != nil {
  2261. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2262. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2263. }
  2264. var respJSON map[string]interface{}
  2265. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2266. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2267. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2268. }
  2269. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2270. fmt.Println(respJSON)
  2271. result, _ := json.Marshal(respJSON)
  2272. fmt.Println(result)
  2273. if err := json.Unmarshal([]byte(result), &result3264); err != nil {
  2274. utils.ErrorLog("解析失败:%v", err)
  2275. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2276. }
  2277. if result3264.Infcode != "0" {
  2278. c.ServeSuccessJSON(map[string]interface{}{
  2279. "failed_code": -10,
  2280. "msg": result3264.ErrMsg,
  2281. })
  2282. return
  2283. } else {
  2284. c.ServeSuccessJSON(map[string]interface{}{
  2285. "info": result3264.Output,
  2286. })
  2287. return
  2288. }
  2289. }
  2290. func (c *HisApiController) Get3271() {
  2291. admin_user_id, _ := c.GetInt64("admin_user_id")
  2292. startTime := c.GetString("start_time")
  2293. //endTime, _ := c.GetString("end_time")
  2294. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2295. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2296. times := strings.Split(startTime, "-")
  2297. setl_mon := times[0] + times[1]
  2298. //var empty models.JSResultEmpty
  2299. var result3265 models.JSResult3264
  2300. var result3263 models.JSResult3263
  2301. data2 := make(map[string]interface{})
  2302. data2["org_name"] = miConfig.OrgName
  2303. data2["doctor"] = curRoles.UserName
  2304. data2["doctor_name"] = curRoles.UserName
  2305. data2["fixmedins_code"] = miConfig.Code
  2306. data2["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  2307. data2["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  2308. data2["secret_key"] = miConfig.SecretKey
  2309. data2["url"] = miConfig.Url
  2310. data2["ak"] = miConfig.AccessKey
  2311. data2["cainfo"] = miConfig.Cainfo
  2312. data2["setl_mon"] = setl_mon
  2313. data2["stmt_loc"] = "2"
  2314. client2 := &http.Client{}
  2315. bytesData2, _ := json.Marshal(data2)
  2316. var req3263 *http.Request
  2317. if miConfig.MdtrtareaAdmvs == "320921" {
  2318. req3263, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3269", bytes.NewReader(bytesData2))
  2319. } else {
  2320. req3263, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3269", bytes.NewReader(bytesData2))
  2321. }
  2322. resp2, _ := client2.Do(req3263)
  2323. defer resp2.Body.Close()
  2324. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  2325. if ioErr2 != nil {
  2326. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  2327. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2328. }
  2329. var respJSON3263 map[string]interface{}
  2330. if err := json.Unmarshal([]byte(body2), &respJSON3263); err != nil {
  2331. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2332. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2333. }
  2334. respJSON3263 = respJSON3263["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2335. fmt.Println(respJSON3263)
  2336. result2, _ := json.Marshal(respJSON3263)
  2337. fmt.Println(result2)
  2338. if err := json.Unmarshal([]byte(result2), &result3263); err != nil {
  2339. utils.ErrorLog("解析失败:%v", err)
  2340. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2341. }
  2342. var ids []string
  2343. for _, item := range result3263.Output {
  2344. ids = append(ids, item.SolidifyID)
  2345. }
  2346. data := make(map[string]interface{})
  2347. data["org_name"] = miConfig.OrgName
  2348. data["doctor"] = curRoles.UserName
  2349. data["doctor_name"] = curRoles.UserName
  2350. data["fixmedins_code"] = miConfig.Code
  2351. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  2352. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  2353. data["secret_key"] = miConfig.SecretKey
  2354. data["url"] = miConfig.Url
  2355. data["ak"] = miConfig.AccessKey
  2356. data["cainfo"] = miConfig.Cainfo
  2357. data["setl_mon"] = setl_mon
  2358. data["solidify_id"] = ids
  2359. month := time.Unix(1557042972, 0).Format("1")
  2360. year := time.Now().Format("2006")
  2361. month = time.Now().Format("01")
  2362. day := time.Now().Format("02")
  2363. hour := time.Now().Format("15")
  2364. min := time.Now().Format("04")
  2365. sec := time.Now().Format("05")
  2366. fix_fill_date := year + month + day + hour + min + sec
  2367. data["fix_fill_dept"] = miConfig.OrgName
  2368. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  2369. data["fix_fill_psn"] = curRoles.UserName
  2370. data["fix_fill_date"] = fix_fill_date
  2371. data["stmt_loc"] = "2"
  2372. client := &http.Client{}
  2373. bytesData, _ := json.Marshal(data)
  2374. var req *http.Request
  2375. if miConfig.MdtrtareaAdmvs == "320921" {
  2376. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3271", bytes.NewReader(bytesData))
  2377. } else {
  2378. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3271", bytes.NewReader(bytesData))
  2379. }
  2380. resp, _ := client.Do(req)
  2381. defer resp.Body.Close()
  2382. body, ioErr := ioutil.ReadAll(resp.Body)
  2383. if ioErr != nil {
  2384. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2385. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2386. }
  2387. var respJSON map[string]interface{}
  2388. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2389. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2390. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2391. }
  2392. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2393. fmt.Println(respJSON)
  2394. result, _ := json.Marshal(respJSON)
  2395. fmt.Println(result)
  2396. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  2397. utils.ErrorLog("解析失败:%v", err)
  2398. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2399. }
  2400. if result3265.Infcode != "0" {
  2401. c.ServeSuccessJSON(map[string]interface{}{
  2402. "failed_code": -10,
  2403. "msg": result3265.ErrMsg,
  2404. })
  2405. return
  2406. } else {
  2407. c.ServeSuccessJSON(map[string]interface{}{
  2408. "info": result3265.Output.Data,
  2409. })
  2410. return
  2411. }
  2412. }
  2413. func (c *HisApiController) Get3272() {
  2414. admin_user_id, _ := c.GetInt64("admin_user_id")
  2415. startTime := c.GetString("start_time")
  2416. //endTime, _ := c.GetString("end_time")
  2417. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2418. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2419. times := strings.Split(startTime, "-")
  2420. setl_mon := times[0] + times[1]
  2421. var upld_btch string
  2422. //var empty models.JSResultEmpty
  2423. var result3265 models.JSResult3264
  2424. data := make(map[string]interface{})
  2425. data["org_name"] = miConfig.OrgName
  2426. data["doctor"] = curRoles.UserName
  2427. data["doctor_name"] = curRoles.UserName
  2428. data["fixmedins_code"] = miConfig.Code
  2429. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  2430. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  2431. data["secret_key"] = miConfig.SecretKey
  2432. data["url"] = miConfig.Url
  2433. data["ak"] = miConfig.AccessKey
  2434. data["cainfo"] = miConfig.Cainfo
  2435. data["setl_mon"] = setl_mon
  2436. month := time.Unix(1557042972, 0).Format("1")
  2437. year := time.Now().Format("2006")
  2438. month = time.Now().Format("01")
  2439. day := time.Now().Format("02")
  2440. hour := time.Now().Format("15")
  2441. min := time.Now().Format("04")
  2442. sec := time.Now().Format("05")
  2443. fix_fill_date := year + month + day + hour + min + sec
  2444. data["fix_fill_dept"] = miConfig.OrgName
  2445. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  2446. data["fix_fill_psn"] = curRoles.UserName
  2447. data["fix_fill_date"] = fix_fill_date
  2448. data["stmt_loc"] = "2"
  2449. data["upld_btch"] = upld_btch
  2450. client := &http.Client{}
  2451. bytesData, _ := json.Marshal(data)
  2452. var req *http.Request
  2453. if miConfig.MdtrtareaAdmvs == "320921" {
  2454. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3272", bytes.NewReader(bytesData))
  2455. } else {
  2456. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3272", bytes.NewReader(bytesData))
  2457. }
  2458. resp, _ := client.Do(req)
  2459. defer resp.Body.Close()
  2460. body, ioErr := ioutil.ReadAll(resp.Body)
  2461. if ioErr != nil {
  2462. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2463. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2464. }
  2465. var respJSON map[string]interface{}
  2466. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2467. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2468. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2469. }
  2470. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2471. fmt.Println(respJSON)
  2472. result, _ := json.Marshal(respJSON)
  2473. fmt.Println(result)
  2474. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  2475. utils.ErrorLog("解析失败:%v", err)
  2476. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2477. }
  2478. if result3265.Infcode != "0" {
  2479. c.ServeSuccessJSON(map[string]interface{}{
  2480. "failed_code": -10,
  2481. "msg": result3265.ErrMsg,
  2482. })
  2483. return
  2484. } else {
  2485. c.ServeSuccessJSON(map[string]interface{}{
  2486. "info": result3265.Output,
  2487. })
  2488. return
  2489. }
  2490. }
  2491. func (c *HisApiController) Get3273() {
  2492. admin_user_id, _ := c.GetInt64("admin_user_id")
  2493. startTime := c.GetString("start_time")
  2494. //endTime, _ := c.GetString("end_time")
  2495. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2496. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2497. times := strings.Split(startTime, "-")
  2498. setl_mon := times[0] + times[1]
  2499. var result3265 models.JSResult3264
  2500. data := make(map[string]interface{})
  2501. data["org_name"] = miConfig.OrgName
  2502. data["doctor"] = curRoles.UserName
  2503. data["doctor_name"] = curRoles.UserName
  2504. data["fixmedins_code"] = miConfig.Code
  2505. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  2506. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  2507. data["secret_key"] = miConfig.SecretKey
  2508. data["url"] = miConfig.Url
  2509. data["ak"] = miConfig.AccessKey
  2510. data["cainfo"] = miConfig.Cainfo
  2511. data["setl_mon"] = setl_mon
  2512. data["stmt_loc"] = "2"
  2513. client := &http.Client{}
  2514. bytesData, _ := json.Marshal(data)
  2515. var req *http.Request
  2516. if miConfig.MdtrtareaAdmvs == "320921" {
  2517. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3273", bytes.NewReader(bytesData))
  2518. } else {
  2519. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3273", bytes.NewReader(bytesData))
  2520. }
  2521. resp, _ := client.Do(req)
  2522. defer resp.Body.Close()
  2523. body, ioErr := ioutil.ReadAll(resp.Body)
  2524. if ioErr != nil {
  2525. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2526. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2527. }
  2528. var respJSON map[string]interface{}
  2529. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2530. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2531. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2532. }
  2533. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  2534. fmt.Println(respJSON)
  2535. result, _ := json.Marshal(respJSON)
  2536. fmt.Println(result)
  2537. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  2538. utils.ErrorLog("解析失败:%v", err)
  2539. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2540. }
  2541. if result3265.Infcode != "0" {
  2542. c.ServeSuccessJSON(map[string]interface{}{
  2543. "failed_code": -10,
  2544. "msg": result3265.ErrMsg,
  2545. })
  2546. return
  2547. } else {
  2548. c.ServeSuccessJSON(map[string]interface{}{
  2549. "info": result3265.Output.Data,
  2550. })
  2551. return
  2552. }
  2553. }
  2554. func (c *HisApiController) Get3274() {
  2555. //if miConfig.MdtrtareaAdmvs == "320921" {
  2556. // api = "http://192.168.2.3:9532/" + "jsyb/3274?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  2557. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  2558. // "&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
  2559. //
  2560. //} else {
  2561. // api = "http://192.168.5.251:9532/" + "jsyb/3274?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  2562. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  2563. // "&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
  2564. //
  2565. //}
  2566. }
  2567. func (c *HisApiController) Get3275() {
  2568. //if miConfig.MdtrtareaAdmvs == "320921" {
  2569. // api = "http://192.168.2.3:9532/" + "jsyb/3275?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  2570. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  2571. // "&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
  2572. //
  2573. //} else {
  2574. // api = "http://192.168.5.251:9532/" + "jsyb/3275?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  2575. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  2576. // "&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
  2577. //
  2578. //}
  2579. }
  2580. func (c *HisApiController) Get3276() {
  2581. //admin_user_id, _ := c.GetInt64("admin_user_id")
  2582. //month := c.GetString("month")
  2583. //
  2584. //curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2585. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2586. //var api string
  2587. //var res Result5301
  2588. //
  2589. //if miConfig.MdtrtareaAdmvs == "320921" {
  2590. // api = "http://192.168.2.3:9532/" + "jsyb/3276?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  2591. // "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + month
  2592. //} else {
  2593. // api = "http://192.168.5.251:9532/" + "jsyb/3264?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  2594. // "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + month
  2595. //}
  2596. //
  2597. //resp, requestErr := http.Get(api)
  2598. //if requestErr != nil {
  2599. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2600. // return
  2601. //}
  2602. //
  2603. //body, ioErr := ioutil.ReadAll(resp.Body)
  2604. //if ioErr != nil {
  2605. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2606. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2607. // return
  2608. //}
  2609. //var respJSON map[string]interface{}
  2610. //if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  2611. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2612. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2613. // return
  2614. //}
  2615. //
  2616. //respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2617. //result, _ := json.Marshal(respJSON)
  2618. //if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  2619. // utils.ErrorLog("解析失败:%v", err)
  2620. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2621. // return
  2622. //}
  2623. }
  2624. func (c *HisApiController) Get3277() {
  2625. //admin_user_id, _ := c.GetInt64("admin_user_id")
  2626. //month := c.GetString("month")
  2627. //
  2628. //curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2629. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2630. //var api string
  2631. //var res Result5301
  2632. //
  2633. //if miConfig.MdtrtareaAdmvs == "320921" {
  2634. // api = "http://192.168.2.3:9532/" + "jsyb/3264?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  2635. // "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + month
  2636. //} else {
  2637. // api = "http://192.168.5.251:9532/" + "jsyb/3264?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  2638. // "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + month
  2639. //}
  2640. //
  2641. //resp, requestErr := http.Get(api)
  2642. //if requestErr != nil {
  2643. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2644. // return
  2645. //}
  2646. //
  2647. //body, ioErr := ioutil.ReadAll(resp.Body)
  2648. //if ioErr != nil {
  2649. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2650. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2651. // return
  2652. //}
  2653. //var respJSON map[string]interface{}
  2654. //if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  2655. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2656. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2657. // return
  2658. //}
  2659. //
  2660. //respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2661. //result, _ := json.Marshal(respJSON)
  2662. //if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  2663. // utils.ErrorLog("解析失败:%v", err)
  2664. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2665. // return
  2666. //}
  2667. }
  2668. func (c *HisApiController) GetCFYLJG001() {
  2669. admin_user_id, _ := c.GetInt64("admin_user_id")
  2670. patient_id, _ := c.GetInt64("patient_id")
  2671. his_patient_id, _ := c.GetInt64("his_patient_id")
  2672. record_time := c.GetString("record_time")
  2673. admin_user_id = 3626
  2674. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  2675. psn, _ := service.GetPsnByPatientId(patient_id)
  2676. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2677. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2678. var cFYLJG001 models.CFYLJG001
  2679. timeLayout := "2006-01-02"
  2680. loc, _ := time.LoadLocation("Local")
  2681. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  2682. if err != nil {
  2683. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  2684. return
  2685. }
  2686. recordDateTime := theTime.Unix()
  2687. prescriptions, _ := service.GetHisPrescriptionForMedType(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  2688. info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  2689. //info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  2690. doctor_info, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, info.DoctorId)
  2691. //dept, _ := service.GetDepartMentDetail(info.Departments)
  2692. for _, item := range prescriptions {
  2693. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, item.Creator)
  2694. if his.IdCardType == 1 {
  2695. bas := strings.Split(psn.CardInfo, "|")
  2696. basNumber := bas[1]
  2697. fmt.Println(basNumber)
  2698. card_sn := bas[3]
  2699. card_no := bas[2]
  2700. cFYLJG001.MdtrtCertType = "03"
  2701. cFYLJG001.CardSn = card_sn
  2702. cFYLJG001.MdtrtCertNo = card_no
  2703. cFYLJG001.EcToken = ""
  2704. cFYLJG001.AuthNo = ""
  2705. } else if his.IdCardType == 2 {
  2706. cFYLJG001.MdtrtCertType = "02"
  2707. cFYLJG001.CardSn = ""
  2708. cFYLJG001.MdtrtCertNo = his.IdCardNo
  2709. cFYLJG001.EcToken = ""
  2710. cFYLJG001.AuthNo = ""
  2711. } else if his.IdCardType == 4 {
  2712. cFYLJG001.MdtrtCertType = "01"
  2713. cFYLJG001.CardSn = ""
  2714. cFYLJG001.MdtrtCertNo = psn.VerifyNumber
  2715. cFYLJG001.EcToken = psn.VerifyNumber
  2716. cFYLJG001.AuthNo = ""
  2717. }
  2718. cFYLJG001.BizTypeCode = "01"
  2719. cFYLJG001.InsuAdmdvs = psn.InsuplcAdmdvs
  2720. cFYLJG001.HospRxno = strconv.FormatInt(item.ID, 10)
  2721. cFYLJG001.RxTypeCode = "1"
  2722. tempTime := time.Unix(item.PreTime, 0)
  2723. timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  2724. cFYLJG001.PrscTime = timeFormatOne
  2725. var count float64
  2726. if item.Type == 1 {
  2727. for _, sumItem := range item.HisDoctorAdviceInfo {
  2728. count = count + sumItem.PrescribingNumber
  2729. }
  2730. }
  2731. cFYLJG001.RxDrugCnt = count
  2732. cFYLJG001.ValiDays = "5"
  2733. ts := time.Unix(item.PreTime, 0)
  2734. record_time2 := ts.AddDate(0, 0, int(5)).Unix()
  2735. tempTime3 := time.Unix(record_time2, 0)
  2736. timeFormat3 := tempTime3.Format("2006-01-02 15:04:05")
  2737. cFYLJG001.ValiEndTime = timeFormat3
  2738. cFYLJG001.RxCotnFlag = "0"
  2739. for _, subItem := range item.HisDoctorAdviceInfo {
  2740. var drug models.RxDrug
  2741. drug.MedListCodg = subItem.BaseDrugLib.MedicalInsuranceNumber
  2742. drug.MedinsListCodg = subItem.BaseDrugLib.MedicalInsuranceNumber
  2743. drug.RxItemTypeCode = "11"
  2744. drug.DrugDosform = "乳膏剂" //TODO
  2745. if subItem.BaseDrugLib.MinUnit != subItem.BaseDrugLib.DoseUnit {
  2746. drug.DrugSpec = subItem.BaseDrugLib.Dose + subItem.BaseDrugLib.DoseUnit + "*" + strconv.FormatInt(subItem.BaseDrugLib.MinNumber, 10) + subItem.BaseDrugLib.MinUnit + "/" + subItem.BaseDrugLib.MaxUnit
  2747. }
  2748. drug.MedcWayDscr = subItem.DeliveryWay
  2749. tempTime2 := time.Unix(subItem.StartTime, 0)
  2750. timeFormatTwo := tempTime2.Format("2006-01-02 15:04:05")
  2751. drug.MedcBegntime = timeFormatTwo
  2752. if subItem.Day > 0 {
  2753. ts := time.Unix(subItem.StartTime, 0)
  2754. record_time := ts.AddDate(0, 0, int(subItem.Day)).Unix()
  2755. tempTime4 := time.Unix(record_time, 0)
  2756. timeFormat5 := tempTime4.Format("2006-01-02 15:04:05")
  2757. drug.MedcEndtime = timeFormat5
  2758. } else {
  2759. tempTime2 := time.Unix(subItem.StartTime, 0)
  2760. timeFormatTwo := tempTime2.Format("2006-01-02 15:04:05")
  2761. drug.MedcEndtime = timeFormatTwo
  2762. }
  2763. drug.MedcDays = strconv.FormatInt(subItem.Day, 10)
  2764. drug.DrugPric = fmt.Sprintf("%.2f", subItem.Price)
  2765. drug.DrugSumamt = fmt.Sprintf("%.2f", subItem.Price*subItem.PrescribingNumber)
  2766. drug.DrugCnt = subItem.PrescribingNumber
  2767. drug.DrugDosunt = subItem.PrescribingNumberUnit
  2768. drug.DrugGenname = subItem.AdviceName
  2769. drug.MedcWayCodg = subItem.DeliveryWay
  2770. //drug.DrugTotlcnt = subItem.PrescribingNumber
  2771. drug.SinDoscnt = subItem.SingleDose
  2772. drug.SinDosunt = subItem.SingleDoseUnit
  2773. drug.UsedFrquCodg = strconv.FormatInt(subItem.ID, 10)
  2774. drug.UsedFrquName = subItem.ExecutionFrequency
  2775. drug.DrugTotlcnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  2776. drug.DrugTotlcntEmp = subItem.PrescribingNumberUnit
  2777. drug.HospApprFlag = "1"
  2778. cFYLJG001.List = append(cFYLJG001.List, drug)
  2779. }
  2780. cFYLJG001.Mdtrtinfo.FixmedinsCode = miConfig.Code
  2781. cFYLJG001.Mdtrtinfo.FixmedinsName = miConfig.Code
  2782. cFYLJG001.Mdtrtinfo.MdtrtID = his.Number
  2783. cFYLJG001.Mdtrtinfo.MedType = item.MedType
  2784. cFYLJG001.Mdtrtinfo.IptOtpNo = his.IptOtpNo
  2785. cFYLJG001.Mdtrtinfo.OtpIptFlag = "1"
  2786. cFYLJG001.Mdtrtinfo.PsnNo = his.PsnNo
  2787. cFYLJG001.Mdtrtinfo.PatnName = his.PsnName
  2788. cFYLJG001.Mdtrtinfo.Certno = his.IdCardNo
  2789. cFYLJG001.Mdtrtinfo.PsnCertType = "01"
  2790. cFYLJG001.Mdtrtinfo.PatnAge = fmt.Sprintf("%.1f", his.Age)
  2791. cFYLJG001.Mdtrtinfo.PatnHgt = "160" //todo
  2792. cFYLJG001.Mdtrtinfo.PatnWt = "58" //todo
  2793. cFYLJG001.Mdtrtinfo.Gend = his.Gend
  2794. cFYLJG001.Mdtrtinfo.PatnAge = fmt.Sprintf("%.1f", his.Age)
  2795. cFYLJG001.Mdtrtinfo.PrscDeptName = "肾内科"
  2796. cFYLJG001.Mdtrtinfo.PrscDeptCode = "A03.06"
  2797. cFYLJG001.Mdtrtinfo.DrCode = doctor.DoctorNumber
  2798. cFYLJG001.Mdtrtinfo.PrscDrName = doctor.UserName
  2799. cFYLJG001.Mdtrtinfo.DrProfttlCodg = "234"
  2800. cFYLJG001.Mdtrtinfo.DrProfttlName = "医师"
  2801. cFYLJG001.Mdtrtinfo.DrDeptCode = "A03.06"
  2802. cFYLJG001.Mdtrtinfo.DrDeptName = "肾内科"
  2803. cFYLJG001.Mdtrtinfo.Caty = "A03.06"
  2804. tempTime2 := time.Now().Unix()
  2805. tempTime6 := time.Unix(tempTime2, 0)
  2806. timeFormatTwo := tempTime6.Format("2006-01-02 15:04:05")
  2807. cFYLJG001.Mdtrtinfo.MdtrtTime = timeFormatTwo
  2808. cFYLJG001.Mdtrtinfo.DiseCodg = "M07803"
  2809. cFYLJG001.Mdtrtinfo.SpDiseFlag = "1"
  2810. cFYLJG001.Mdtrtinfo.MaindiagCode = "N18.500"
  2811. cFYLJG001.Mdtrtinfo.MaindiagName = "慢性肾脏病5期"
  2812. //memo := make(map[string]interface{})
  2813. //inputData := make(map[string]interface{}, 0)
  2814. //type MyData struct {
  2815. // Insutype string `json:"insutype"`
  2816. //}
  2817. //
  2818. // data := MyData{
  2819. // Insutype: his.Insutype,
  2820. //}
  2821. //
  2822. diagnosis_ids := strings.Split(info.Diagnosis, ",")
  2823. var config []*models.HisXtDiagnoseConfig
  2824. for _, item := range diagnosis_ids {
  2825. id, _ := strconv.ParseInt(item, 10, 64)
  2826. diagnosisConfig, _ := service.FindDiagnoseById(id)
  2827. config = append(config, &diagnosisConfig)
  2828. }
  2829. for index, subitem := range config {
  2830. if index == 0 {
  2831. var dia models.DiseInfo
  2832. dia.DiagType = "1"
  2833. dia.MaindiagFlag = "1"
  2834. dia.DiagSrtNo = strconv.FormatInt(int64(index+1), 10)
  2835. dia.DiagCode = subitem.CountryCode
  2836. dia.DiagName = subitem.ClassName
  2837. dia.DiagDept = "肾内科"
  2838. dia.DiagDrNo = doctor.DoctorNumber
  2839. dia.DiagDrName = doctor.UserName
  2840. tempTime3 := time.Unix(item.PreTime, 0)
  2841. timeFormatTwo := tempTime3.Format("2006-01-02 15:04:05")
  2842. dia.DiagTime = timeFormatTwo
  2843. cFYLJG001.Diseinfo = append(cFYLJG001.Diseinfo, dia)
  2844. } else {
  2845. var dia models.DiseInfo
  2846. dia.DiagType = "1"
  2847. dia.MaindiagFlag = "0"
  2848. dia.DiagSrtNo = strconv.FormatInt(int64(index+1), 10)
  2849. dia.DiagCode = subitem.CountryCode
  2850. dia.DiagName = subitem.ClassName
  2851. dia.DiagDept = "肾内科"
  2852. dia.DiagDrNo = doctor.DoctorNumber
  2853. dia.DiagDrName = doctor.UserName
  2854. tempTime3 := time.Unix(item.PreTime, 0)
  2855. timeFormatTwo := tempTime3.Format("2006-01-02 15:04:05")
  2856. dia.DiagTime = timeFormatTwo
  2857. cFYLJG001.Diseinfo = append(cFYLJG001.Diseinfo, dia)
  2858. }
  2859. }
  2860. result, request := service.GetCFYLJG001(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG001, his.Insutype)
  2861. saveLog(result, request, "GetCFYLJG001", "GetCFYLJG001")
  2862. var res ResultCFYLJG001
  2863. var respJSON2 map[string]interface{}
  2864. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  2865. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2866. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2867. return
  2868. }
  2869. userJSONBytes2, _ := json.Marshal(respJSON2)
  2870. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2871. utils.ErrorLog("解析失败:%v", err)
  2872. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2873. return
  2874. }
  2875. if res.Infcode == -1 {
  2876. c.ServeSuccessJSON(map[string]interface{}{
  2877. "failed_code": -10,
  2878. "msg": res.ErrMsg,
  2879. })
  2880. return
  2881. } else {
  2882. var flow models.HisPrescriptionFlow
  2883. flow.Ctime = time.Now().Unix()
  2884. flow.SignDigest = ""
  2885. flow.RxTraceCode = res.Output.RxTraceCode
  2886. flow.HiRxno = res.Output.HiRxno
  2887. flow.MID = his.Number
  2888. flow.Status = 1
  2889. flow.DCode = doctor_info.DoctorNumber
  2890. flow.OriginalRxFile = ""
  2891. flow.OriginalValue = ""
  2892. flow.SignCertDn = ""
  2893. flow.UserOrgId = 10454
  2894. flow.SignCertSn = ""
  2895. flow.Mtime = time.Now().Unix()
  2896. service.Createflow(&flow)
  2897. c.ServeSuccessJSON(map[string]interface{}{
  2898. "msg": "上传成功",
  2899. })
  2900. }
  2901. }
  2902. }
  2903. func (c *HisApiController) GetCFYLJG002() {
  2904. admin_user_id, _ := c.GetInt64("admin_user_id")
  2905. his_patient_id, _ := c.GetInt64("his_patient_id")
  2906. record_time := c.GetString("record_time")
  2907. admin_user_id = 3626
  2908. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  2909. //id, _ := c.GetInt64("id")
  2910. admin_user_id = 3626
  2911. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2912. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2913. flow, _ := service.Getflowtwo(his.Number)
  2914. //his, _ := service.GetHisPatientByNumber(flow.MID)
  2915. //record_time := c.GetString("record_time")
  2916. patient_id, _ := c.GetInt64("patient_id")
  2917. //patient_id = 23834
  2918. //record_time = "2023-09-18"
  2919. timeLayout := "2006-01-02"
  2920. loc, _ := time.LoadLocation("Local")
  2921. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  2922. if err != nil {
  2923. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  2924. return
  2925. }
  2926. recordDateTime := theTime.Unix()
  2927. //prescriptions, _ := service.GetHisPrescriptionForMedType(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  2928. info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  2929. doctor_info, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, info.DoctorId)
  2930. dept, _ := service.GetDepartMentDetail(info.Departments)
  2931. inputData := make(map[string]interface{})
  2932. inputData["rxTraceCode"] = flow.RxTraceCode
  2933. inputData["hiRxno"] = flow.HiRxno
  2934. inputData["mdtrtId"] = flow.MID
  2935. inputData["patnName"] = his.PsnName
  2936. inputData["psnCertType"] = his.PsnCertType
  2937. inputData["certno"] = his.Certno
  2938. inputData["fixmedinsName"] = miConfig.OrgName
  2939. inputData["fixmedinsCode"] = miConfig.Code
  2940. inputData["drCode"] = doctor_info.DoctorNumber
  2941. inputData["prscDrName"] = doctor_info.UserName
  2942. inputData["pharDeptName"] = dept.Name
  2943. inputData["pharDeptCode"] = dept.Number
  2944. inputData["pharProfttlCodg"] = dept.Name
  2945. inputData["pharProfttlName"] = ""
  2946. inputData["pharCode"] = "HY440309002107"
  2947. inputData["pharCertType"] = "01"
  2948. inputData["pharCertno"] = "430482199408260023"
  2949. inputData["pharName"] = "彭斯遥"
  2950. inputData["pharPracCertNo"] = ""
  2951. tempTime2 := time.Unix(info.Ctime, 0)
  2952. timeFormatTwo := tempTime2.Format("2006-01-02 15:04:05")
  2953. inputData["pharChkTime"] = timeFormatTwo
  2954. bytesData, _ := json.Marshal(inputData)
  2955. fmt.Println(string(bytesData))
  2956. encoded := base64.StdEncoding.EncodeToString(bytesData)
  2957. pdfContent, err := ioutil.ReadFile("signed_data.pdf")
  2958. if err != nil {
  2959. fmt.Println("Error reading PDF file:", err)
  2960. return
  2961. }
  2962. // 将 PDF 文件内容进行 Base64 编码
  2963. rx_encoded := base64.StdEncoding.EncodeToString(pdfContent)
  2964. fmt.Println(err)
  2965. result, request := service.GetCFYLJG002(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, encoded, rx_encoded, "")
  2966. //result, request := service.GetCFYLJG001(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG001,his.Insutype)
  2967. saveLog(result, request, "GetCFYLJG002", "GetCFYLJG002")
  2968. var res2 Result002
  2969. var respJSON2 map[string]interface{}
  2970. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  2971. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2972. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2973. return
  2974. }
  2975. userJSONBytes2, _ := json.Marshal(respJSON2)
  2976. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  2977. utils.ErrorLog("解析失败:%v", err)
  2978. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2979. return
  2980. }
  2981. if res2.Infcode == 0 {
  2982. flow.Ctime = time.Now().Unix()
  2983. flow.SignDigest = res2.Output.SignDigest
  2984. flow.RxFile = res2.Output.RxFile
  2985. flow.MID = his.Number
  2986. flow.Status = 1
  2987. flow.DCode = doctor_info.DoctorNumber
  2988. flow.OriginalRxFile = rx_encoded
  2989. flow.OriginalValue = encoded
  2990. flow.SignCertDn = res2.Output.SignCertDn
  2991. flow.SignCertSn = res2.Output.SignCertSn
  2992. flow.Mtime = time.Now().Unix()
  2993. service.Saveflow(flow)
  2994. c.ServeSuccessJSON(map[string]interface{}{
  2995. "msg": "预签名成功",
  2996. })
  2997. } else {
  2998. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2999. return
  3000. }
  3001. }
  3002. func (c *HisApiController) GetCFYLJG003() {
  3003. admin_user_id, _ := c.GetInt64("admin_user_id")
  3004. his_patient_id, _ := c.GetInt64("his_patient_id")
  3005. record_time := c.GetString("record_time")
  3006. admin_user_id = 3626
  3007. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  3008. //id, _ := c.GetInt64("id")
  3009. admin_user_id = 3626
  3010. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3011. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3012. flow, _ := service.Getflowtwo(his.Number)
  3013. //id = 3
  3014. patient_id, _ := c.GetInt64("patient_id")
  3015. //patient_id = 23834
  3016. //record_time = "2023-09-18"
  3017. timeLayout := "2006-01-02"
  3018. loc, _ := time.LoadLocation("Local")
  3019. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  3020. if err != nil {
  3021. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  3022. return
  3023. }
  3024. recordDateTime := theTime.Unix()
  3025. //prescriptions, _ := service.GetHisPrescriptionForMedType(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  3026. info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  3027. doctor_info, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, info.DoctorId)
  3028. dept, _ := service.GetDepartMentDetail(info.Departments)
  3029. //psn_info,_ := service.GetPsnByPatientId(his.PatientId)
  3030. var cFYLJG003 models.CFYLJG003
  3031. cFYLJG003.RxTraceCode = flow.RxTraceCode
  3032. cFYLJG003.HiRxno = flow.HiRxno
  3033. cFYLJG003.MdtrtID = flow.MID
  3034. cFYLJG003.PatnName = his.Name
  3035. cFYLJG003.Certno = his.Certno
  3036. cFYLJG003.FixmedinsName = miConfig.OrgName
  3037. cFYLJG003.FixmedinsCode = miConfig.Code
  3038. cFYLJG003.DrCode = doctor_info.DoctorNumber
  3039. cFYLJG003.PrscDrName = doctor_info.UserName
  3040. cFYLJG003.PharDeptName = dept.Name
  3041. cFYLJG003.PharDeptCode = dept.Number
  3042. cFYLJG003.PharCode = "HY440309002107"
  3043. cFYLJG003.PharCertType = "01"
  3044. cFYLJG003.PharCertno = "430482199408260023"
  3045. cFYLJG003.PharName = "彭斯遥"
  3046. cFYLJG003.PsnCertType = "01"
  3047. cFYLJG003.RxFile = flow.RxFile
  3048. cFYLJG003.SignDigest = flow.SignDigest
  3049. cFYLJG003.FixmedinsCode = miConfig.Code
  3050. cFYLJG003.PsnCertType = "01"
  3051. cFYLJG003.PharProfttlCodg = dept.Name
  3052. //inputData["pharProfttlCodg"] =dept.Name
  3053. tempTime2 := time.Unix(info.Ctime, 0)
  3054. timeFormatTwo := tempTime2.Format("2006-01-02 15:04:05")
  3055. cFYLJG003.PharChkTime = timeFormatTwo
  3056. result, request := service.GetCFYLJG003(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG003)
  3057. saveLog(result, request, "GetCFYLJG003", "GetCFYLJG003")
  3058. var res ResultCFYLJG003
  3059. var respJSON2 map[string]interface{}
  3060. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  3061. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3062. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3063. return
  3064. }
  3065. userJSONBytes2, _ := json.Marshal(respJSON2)
  3066. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  3067. utils.ErrorLog("解析失败:%v", err)
  3068. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3069. return
  3070. }
  3071. if res.Infcode == -1 {
  3072. c.ServeSuccessJSON(map[string]interface{}{
  3073. "failed_code": -10,
  3074. "msg": res.ErrMsg,
  3075. })
  3076. return
  3077. } else {
  3078. c.ServeSuccessJSON(map[string]interface{}{
  3079. "info": res.Output,
  3080. })
  3081. }
  3082. }
  3083. func (c *HisApiController) GetCFYLJG004() {
  3084. admin_user_id, _ := c.GetInt64("admin_user_id")
  3085. his_patient_id, _ := c.GetInt64("his_patient_id")
  3086. record_time := c.GetString("record_time")
  3087. admin_user_id = 3626
  3088. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  3089. //id, _ := c.GetInt64("id")
  3090. admin_user_id = 3626
  3091. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3092. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3093. flow, _ := service.Getflowtwo(his.Number)
  3094. //id = 3
  3095. patient_id, _ := c.GetInt64("patient_id")
  3096. //patient_id = 23834
  3097. //record_time = "2023-09-18"
  3098. timeLayout := "2006-01-02"
  3099. loc, _ := time.LoadLocation("Local")
  3100. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  3101. if err != nil {
  3102. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  3103. return
  3104. }
  3105. recordDateTime := theTime.Unix()
  3106. info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  3107. doctor_info, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, info.DoctorId)
  3108. var cFYLJG004 models.CFYLJG004
  3109. cFYLJG004.HiRxno = flow.HiRxno
  3110. cFYLJG004.FixmedinsCode = miConfig.Code
  3111. cFYLJG004.UndoDrCertno = doctor_info.IdCard
  3112. cFYLJG004.UndoDrCertType = "01"
  3113. cFYLJG004.UndoRea = "撤销处方"
  3114. cFYLJG004.UndoTime = time.Now().Format("2006-01-02 15:04:05")
  3115. cFYLJG004.UndoDrName = doctor_info.UserName
  3116. cFYLJG004.UndoDrCode = doctor_info.DoctorNumber
  3117. result, request := service.GetCFYLJG004(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG004)
  3118. saveLog(result, request, "GetCFYLJG004", "GetCFYLJG004")
  3119. var res ResultCFYLJG004
  3120. var respJSON2 map[string]interface{}
  3121. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  3122. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3123. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3124. return
  3125. }
  3126. userJSONBytes2, _ := json.Marshal(respJSON2)
  3127. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  3128. utils.ErrorLog("解析失败:%v", err)
  3129. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3130. return
  3131. }
  3132. if res.Infcode == -1 {
  3133. c.ServeSuccessJSON(map[string]interface{}{
  3134. "failed_code": -10,
  3135. "msg": res.ErrMsg,
  3136. })
  3137. return
  3138. } else {
  3139. flow.Status = 0
  3140. service.Saveflow(flow)
  3141. c.ServeSuccessJSON(map[string]interface{}{
  3142. "msg": "撤销成功",
  3143. })
  3144. return
  3145. }
  3146. }
  3147. func (c *HisApiController) GetCFYLJG005() {
  3148. admin_user_id, _ := c.GetInt64("admin_user_id")
  3149. his_patient_id, _ := c.GetInt64("his_patient_id")
  3150. //record_time := c.GetString("record_time")
  3151. admin_user_id = 3626
  3152. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  3153. //id, _ := c.GetInt64("id")
  3154. admin_user_id = 3626
  3155. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3156. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3157. flow, _ := service.Getflowtwo(his.Number)
  3158. //id = 3
  3159. var cFYLJG005 models.CFYLJG005
  3160. //patient_id, _ := c.GetInt64("patient_id")
  3161. cFYLJG005.HiRxno = flow.HiRxno
  3162. cFYLJG005.MdtrtID = flow.MID
  3163. cFYLJG005.EcToken = ""
  3164. cFYLJG005.PsnName = his.Name
  3165. cFYLJG005.PsnCertType = "01"
  3166. cFYLJG005.Certno = his.IdCardNo
  3167. result, request := service.GetCFYLJG005(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG005)
  3168. saveLog(result, request, "GetCFYLJG005", "GetCFYLJG005")
  3169. var res ResultCFYLJG005
  3170. var respJSON2 map[string]interface{}
  3171. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  3172. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3173. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3174. return
  3175. }
  3176. userJSONBytes2, _ := json.Marshal(respJSON2)
  3177. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  3178. utils.ErrorLog("解析失败:%v", err)
  3179. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3180. return
  3181. }
  3182. if res.Infcode == -1 {
  3183. c.ServeSuccessJSON(map[string]interface{}{
  3184. "failed_code": -10,
  3185. "msg": res.ErrMsg,
  3186. })
  3187. return
  3188. } else {
  3189. c.ServeSuccessJSON(map[string]interface{}{
  3190. "info": res.Output,
  3191. })
  3192. return
  3193. }
  3194. }
  3195. func (c *HisApiController) GetCFYLJG006() {
  3196. admin_user_id, _ := c.GetInt64("admin_user_id")
  3197. his_patient_id, _ := c.GetInt64("his_patient_id")
  3198. admin_user_id = 3626
  3199. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  3200. //id, _ := c.GetInt64("id")
  3201. admin_user_id = 3626
  3202. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3203. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3204. flow, _ := service.Getflowtwo(his.Number)
  3205. //id = 3
  3206. patient_id, _ := c.GetInt64("patient_id")
  3207. var cFYLJG006 models.CFYLJG006
  3208. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, patient_id)
  3209. cFYLJG006.HiRxno = flow.HiRxno
  3210. cFYLJG006.MdtrtID = flow.MID
  3211. cFYLJG006.PsnName = patient.Name
  3212. cFYLJG006.PsnCertType = "01"
  3213. cFYLJG006.Certno = patient.IdCardNo
  3214. result, request := service.GetCFYLJG006(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG006)
  3215. saveLog(result, request, "GetCFYLJG006", "GetCFYLJG006")
  3216. var res ResultCFYLJG006
  3217. var respJSON2 map[string]interface{}
  3218. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  3219. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3220. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3221. return
  3222. }
  3223. userJSONBytes2, _ := json.Marshal(respJSON2)
  3224. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  3225. utils.ErrorLog("解析失败:%v", err)
  3226. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3227. return
  3228. }
  3229. if res.Infcode == -1 {
  3230. c.ServeSuccessJSON(map[string]interface{}{
  3231. "failed_code": -10,
  3232. "msg": res.ErrMsg,
  3233. })
  3234. return
  3235. } else {
  3236. c.ServeSuccessJSON(map[string]interface{}{
  3237. "info": res.Output,
  3238. })
  3239. return
  3240. }
  3241. }
  3242. func (c *HisApiController) GetCFYLJG007() {
  3243. admin_user_id, _ := c.GetInt64("admin_user_id")
  3244. his_patient_id, _ := c.GetInt64("his_patient_id")
  3245. admin_user_id = 3626
  3246. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  3247. //id, _ := c.GetInt64("id")
  3248. admin_user_id = 3626
  3249. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3250. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3251. flow, _ := service.Getflowtwo(his.Number)
  3252. //id = 3
  3253. patient_id, _ := c.GetInt64("patient_id")
  3254. var cFYLJG007 models.CFYLJG007
  3255. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, patient_id)
  3256. //his, _ := service.GetHisPatient(c.GetAdminUserInfo().CurrentOrgId,patient_id)
  3257. cFYLJG007.HiRxno = flow.HiRxno
  3258. cFYLJG007.MdtrtID = flow.MID
  3259. cFYLJG007.PsnNo = his.PsnNo
  3260. cFYLJG007.PsnCertType = "01"
  3261. cFYLJG007.Certno = patient.IdCardNo
  3262. cFYLJG007.PsnName = patient.Name
  3263. result, request := service.GetCFYLJG007(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG007)
  3264. saveLog(result, request, "GetCFYLJG007", "GetCFYLJG007")
  3265. var res ResultCFYLJG007
  3266. var respJSON2 map[string]interface{}
  3267. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  3268. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3269. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3270. return
  3271. }
  3272. userJSONBytes2, _ := json.Marshal(respJSON2)
  3273. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  3274. utils.ErrorLog("解析失败:%v", err)
  3275. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3276. return
  3277. }
  3278. if res.Infcode == -1 {
  3279. c.ServeSuccessJSON(map[string]interface{}{
  3280. "failed_code": -10,
  3281. "msg": res.ErrMsg,
  3282. })
  3283. return
  3284. } else {
  3285. c.ServeSuccessJSON(map[string]interface{}{
  3286. "info": res,
  3287. })
  3288. return
  3289. }
  3290. }
  3291. func (c *HisApiController) GetCFYLJG008() {
  3292. admin_user_id, _ := c.GetInt64("admin_user_id")
  3293. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3294. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3295. var cFYLJG008 models.CFYLJG008
  3296. //id, _ := c.GetInt64("id")
  3297. patient_id, _ := c.GetInt64("patient_id")
  3298. //patient, _ := service.G/etPatientByID(c.GetAdminUserInfo().CurrentOrgId,patient_id)
  3299. //his, _ := service.GetHisPatient(c.GetAdminUserInfo().CurrentOrgId,patient_id)
  3300. //id = 3
  3301. //flow, _ := service.Getflow(id)
  3302. //his, _ := service.GetHisPatientByNumber(flow.MID)
  3303. //
  3304. //admin_user_id, _ := c.GetInt64("admin_user_id")
  3305. //patient_id, _ := c.GetInt64("patient_id")
  3306. //his_patient_id, _ := c.GetInt64("his_patient_id")
  3307. record_time := c.GetString("record_time")
  3308. admin_user_id = 3626
  3309. patient_id = 19424
  3310. //his_patient_id = 263947
  3311. record_time = "2023-08-29"
  3312. timeLayout := "2006-01-02"
  3313. loc, _ := time.LoadLocation("Local")
  3314. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  3315. if err != nil {
  3316. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  3317. return
  3318. }
  3319. recordDateTime := theTime.Unix()
  3320. prescriptions, _ := service.GetHisPrescriptionForMedType(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  3321. cFYLJG008.FixmedinsName = ""
  3322. cFYLJG008.Lat = ""
  3323. cFYLJG008.Lng = ""
  3324. cFYLJG008.OrderType = "1"
  3325. cFYLJG008.PoolareaNo = ""
  3326. cFYLJG008.Lng = ""
  3327. cFYLJG008.PageNum = 1
  3328. cFYLJG008.PageSize = 10
  3329. var MPI models.MedinsProdInvChgDDTO
  3330. MPI.MedListCodg = prescriptions[0].HisDoctorAdviceInfo[0].MedListCodg
  3331. MPI.Cnt = prescriptions[0].HisDoctorAdviceInfo[0].PrescribingNumber
  3332. cFYLJG008.MedList = append(cFYLJG008.MedList, MPI)
  3333. result, request := service.GetCFYLJG008(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG008)
  3334. saveLog(result, request, "GetCFYLJG008", "GetCFYLJG008")
  3335. var res ResultCFYLJG008
  3336. var respJSON2 map[string]interface{}
  3337. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  3338. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3339. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3340. return
  3341. }
  3342. userJSONBytes2, _ := json.Marshal(respJSON2)
  3343. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  3344. utils.ErrorLog("解析失败:%v", err)
  3345. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3346. return
  3347. }
  3348. if res.Infcode == -1 {
  3349. c.ServeSuccessJSON(map[string]interface{}{
  3350. "failed_code": -10,
  3351. "msg": res.ErrMsg,
  3352. })
  3353. return
  3354. } else {
  3355. c.ServeSuccessJSON(map[string]interface{}{
  3356. "info": res.Output,
  3357. })
  3358. return
  3359. }
  3360. }
  3361. func (c *HisApiController) GetBL4201A() {
  3362. order_id, _ := c.GetInt64("order_id")
  3363. admin_user_id, _ := c.GetInt64("admin_user_id")
  3364. order, _ := service.GetHisOrderByIDTwo(order_id)
  3365. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  3366. order_info, _ := service.GetHisOrderInfoByNumber(order.MdtrtId)
  3367. order_info_two, _ := service.GetHisOrderInfoByNumberTwo(order.MdtrtId)
  3368. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3369. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3370. department, _ := service.GetDepartMentDetail(his.Departments)
  3371. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  3372. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  3373. if order.ID == 0 {
  3374. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  3375. return
  3376. }
  3377. var struct4201A models.Struct4201A
  3378. var fsiOPFLDs []models.FsiOwnpayPatnFeeListDDTO
  3379. for _, items := range order_info {
  3380. memo := make(map[string]interface{})
  3381. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  3382. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  3383. fsiOPFLD.MedType = "14"
  3384. fsiOPFLD.BkkpSn = items.FeedetlSn
  3385. fsiOPFLD.FixmedinsCode = miConfig.Code
  3386. fsiOPFLD.FixmedinsName = miConfig.OrgName
  3387. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  3388. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  3389. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  3390. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  3391. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  3392. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  3393. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  3394. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  3395. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  3396. fsiOPFLD.BilgDeptName = department.Name
  3397. fsiOPFLD.BilgDeptCodg = department.Number
  3398. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  3399. fsiOPFLD.BilgDrName = doctor.UserName
  3400. fsiOPFLD.MedChrgitmType = "09"
  3401. memo["hosp_appr_flag"] = "1"
  3402. memo["invoice_no"] = order.MdtrtId
  3403. memo["memo"] = "自费"
  3404. bytesData, _ := json.Marshal(memo)
  3405. fsiOPFLD.Memo = string(bytesData)
  3406. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  3407. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  3408. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  3409. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  3410. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  3411. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  3412. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  3413. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  3414. fsiOPFLD.BilgDeptName = department.Name
  3415. fsiOPFLD.BilgDeptCodg = department.Number
  3416. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  3417. fsiOPFLD.BilgDrName = doctor.UserName
  3418. switch items.HisPrescriptionProject.HisProject.CostClassify {
  3419. case 0:
  3420. break
  3421. case 1:
  3422. fsiOPFLD.MedChrgitmType = "14"
  3423. break
  3424. case 2:
  3425. fsiOPFLD.MedChrgitmType = "05"
  3426. break
  3427. case 3:
  3428. fsiOPFLD.MedChrgitmType = "03"
  3429. break
  3430. case 4:
  3431. fsiOPFLD.MedChrgitmType = "03"
  3432. break
  3433. case 5:
  3434. fsiOPFLD.MedChrgitmType = "08"
  3435. break
  3436. case 6:
  3437. fsiOPFLD.MedChrgitmType = "14"
  3438. break
  3439. case 7:
  3440. fsiOPFLD.MedChrgitmType = "14"
  3441. break
  3442. case 8:
  3443. fsiOPFLD.MedChrgitmType = "03"
  3444. break
  3445. case 9:
  3446. fsiOPFLD.MedChrgitmType = "14"
  3447. break
  3448. case 10:
  3449. fsiOPFLD.MedChrgitmType = "14"
  3450. break
  3451. case 11:
  3452. fsiOPFLD.MedChrgitmType = "06"
  3453. break
  3454. case 12:
  3455. fsiOPFLD.MedChrgitmType = "12"
  3456. break
  3457. case 13:
  3458. fsiOPFLD.MedChrgitmType = "01"
  3459. break
  3460. case 14:
  3461. fsiOPFLD.MedChrgitmType = "04"
  3462. break
  3463. case 15:
  3464. fsiOPFLD.MedChrgitmType = "14"
  3465. break
  3466. }
  3467. memo["hosp_appr_flag"] = "1"
  3468. memo["invoice_no"] = order.MdtrtId
  3469. memo["memo"] = "自费"
  3470. bytesData, _ := json.Marshal(memo)
  3471. fsiOPFLD.Memo = string(bytesData)
  3472. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  3473. } else if items.HisPrescriptionProject.Type == 3 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 {
  3474. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  3475. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  3476. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  3477. fsiOPFLD.BilgDeptName = department.Name
  3478. fsiOPFLD.BilgDeptCodg = department.Number
  3479. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  3480. fsiOPFLD.BilgDrName = doctor.UserName
  3481. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  3482. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  3483. fsiOPFLD.MedChrgitmType = "08"
  3484. memo["hosp_appr_flag"] = "1"
  3485. memo["invoice_no"] = order.MdtrtId
  3486. memo["memo"] = "自费"
  3487. bytesData, _ := json.Marshal(memo)
  3488. fsiOPFLD.Memo = string(bytesData)
  3489. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  3490. }
  3491. }
  3492. }
  3493. for _, items := range order_info_two {
  3494. memo := make(map[string]interface{})
  3495. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  3496. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  3497. fsiOPFLD.MedType = "14"
  3498. fsiOPFLD.BkkpSn = items.FeedetlSn
  3499. fsiOPFLD.FixmedinsCode = miConfig.Code
  3500. fsiOPFLD.FixmedinsName = miConfig.OrgName
  3501. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  3502. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  3503. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  3504. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  3505. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  3506. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  3507. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  3508. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  3509. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  3510. fsiOPFLD.BilgDeptName = department.Name
  3511. fsiOPFLD.BilgDeptCodg = department.Number
  3512. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  3513. fsiOPFLD.BilgDrName = doctor.UserName
  3514. fsiOPFLD.MedChrgitmType = "09"
  3515. memo["hosp_appr_flag"] = "1"
  3516. memo["invoice_no"] = order.MdtrtId
  3517. memo["memo"] = "自费"
  3518. bytesData, _ := json.Marshal(memo)
  3519. fsiOPFLD.Memo = string(bytesData)
  3520. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  3521. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  3522. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  3523. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  3524. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  3525. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  3526. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  3527. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  3528. fsiOPFLD.BilgDeptName = department.Name
  3529. fsiOPFLD.BilgDeptCodg = department.Number
  3530. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  3531. fsiOPFLD.BilgDrName = doctor.UserName
  3532. switch items.HisPrescriptionProject.HisProject.CostClassify {
  3533. case 0:
  3534. break
  3535. case 1:
  3536. fsiOPFLD.MedChrgitmType = "14"
  3537. break
  3538. case 2:
  3539. fsiOPFLD.MedChrgitmType = "05"
  3540. break
  3541. case 3:
  3542. fsiOPFLD.MedChrgitmType = "03"
  3543. break
  3544. case 4:
  3545. fsiOPFLD.MedChrgitmType = "03"
  3546. break
  3547. case 5:
  3548. fsiOPFLD.MedChrgitmType = "08"
  3549. break
  3550. case 6:
  3551. fsiOPFLD.MedChrgitmType = "14"
  3552. break
  3553. case 7:
  3554. fsiOPFLD.MedChrgitmType = "14"
  3555. break
  3556. case 8:
  3557. fsiOPFLD.MedChrgitmType = "03"
  3558. break
  3559. case 9:
  3560. fsiOPFLD.MedChrgitmType = "14"
  3561. break
  3562. case 10:
  3563. fsiOPFLD.MedChrgitmType = "14"
  3564. break
  3565. case 11:
  3566. fsiOPFLD.MedChrgitmType = "06"
  3567. break
  3568. case 12:
  3569. fsiOPFLD.MedChrgitmType = "12"
  3570. break
  3571. case 13:
  3572. fsiOPFLD.MedChrgitmType = "01"
  3573. break
  3574. case 14:
  3575. fsiOPFLD.MedChrgitmType = "04"
  3576. break
  3577. case 15:
  3578. fsiOPFLD.MedChrgitmType = "14"
  3579. break
  3580. }
  3581. memo["hosp_appr_flag"] = "1"
  3582. memo["invoice_no"] = order.MdtrtId
  3583. memo["memo"] = "自费"
  3584. bytesData, _ := json.Marshal(memo)
  3585. fsiOPFLD.Memo = string(bytesData)
  3586. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  3587. } else if items.HisPrescriptionProject.Type == 3 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 {
  3588. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  3589. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  3590. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  3591. fsiOPFLD.BilgDeptName = department.Name
  3592. fsiOPFLD.BilgDeptCodg = department.Number
  3593. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  3594. fsiOPFLD.BilgDrName = doctor.UserName
  3595. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  3596. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  3597. fsiOPFLD.MedChrgitmType = "08"
  3598. memo["hosp_appr_flag"] = "1"
  3599. memo["invoice_no"] = order.MdtrtId
  3600. memo["memo"] = "自费"
  3601. bytesData, _ := json.Marshal(memo)
  3602. fsiOPFLD.Memo = string(bytesData)
  3603. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  3604. }
  3605. }
  3606. }
  3607. fmt.Println(fsiOPFLDs)
  3608. struct4201A.Fopfd = fsiOPFLDs
  3609. fmt.Println(struct4201A.Fopfd)
  3610. result, requestLog := service.Gdyb4201A(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4201A)
  3611. saveLog(result, requestLog, "4201A", "自费费用明细上传")
  3612. var res2 ResultSix
  3613. var respJSON2 map[string]interface{}
  3614. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  3615. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3616. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3617. return
  3618. }
  3619. userJSONBytes2, _ := json.Marshal(respJSON2)
  3620. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  3621. utils.ErrorLog("解析失败:%v", err)
  3622. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3623. return
  3624. }
  3625. if res2.Infcode != 0 {
  3626. c.ServeSuccessJSON(map[string]interface{}{
  3627. "failed_code": -10,
  3628. "msg": res2.ErrMsg,
  3629. })
  3630. return
  3631. } else {
  3632. order.IsUploadOrderInfo = 1
  3633. service.UpdateOrder(order)
  3634. c.ServeSuccessJSON(map[string]interface{}{
  3635. "msg": "上传成功",
  3636. })
  3637. }
  3638. }
  3639. func (c *HisApiController) Get2505() {
  3640. admin_user_id, _ := c.GetInt64("admin_user_id")
  3641. miConfig, _ := service.FindMedicalInsuranceInfo(10375)
  3642. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3643. 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)
  3644. }
  3645. func (c *HisApiController) Get4201A() {
  3646. order_id, _ := c.GetInt64("order_id")
  3647. admin_user_id, _ := c.GetInt64("admin_user_id")
  3648. order, _ := service.GetHisOrderByIDTwo(order_id)
  3649. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  3650. order_info, _ := service.GetHisOrderInfoByNumber(order.MdtrtId)
  3651. order_info_two, _ := service.GetHisOrderInfoByNumberTwo(order.MdtrtId)
  3652. //order_info = append(order_info, order_info_two...)
  3653. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3654. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3655. department, _ := service.GetDepartMentDetail(his.Departments)
  3656. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  3657. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  3658. if order.ID == 0 {
  3659. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  3660. return
  3661. }
  3662. var struct4201A models.Struct4201A
  3663. var fsiOPFLDs []models.FsiOwnpayPatnFeeListDDTO
  3664. for _, items := range order_info {
  3665. memo := make(map[string]interface{})
  3666. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  3667. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  3668. fsiOPFLD.MedType = "14"
  3669. fsiOPFLD.BkkpSn = items.FeedetlSn
  3670. fsiOPFLD.FixmedinsCode = miConfig.Code
  3671. fsiOPFLD.FixmedinsName = miConfig.OrgName
  3672. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  3673. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  3674. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  3675. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  3676. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  3677. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  3678. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  3679. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  3680. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  3681. fsiOPFLD.BilgDeptName = department.Name
  3682. fsiOPFLD.BilgDeptCodg = department.Number
  3683. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  3684. fsiOPFLD.BilgDrName = doctor.UserName
  3685. fsiOPFLD.MedChrgitmType = "09"
  3686. memo["hosp_appr_flag"] = "1"
  3687. memo["invoice_no"] = order.MdtrtId
  3688. memo["memo"] = "自费"
  3689. bytesData, _ := json.Marshal(memo)
  3690. fsiOPFLD.Memo = string(bytesData)
  3691. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  3692. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  3693. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  3694. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  3695. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  3696. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  3697. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  3698. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  3699. fsiOPFLD.BilgDeptName = department.Name
  3700. fsiOPFLD.BilgDeptCodg = department.Number
  3701. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  3702. fsiOPFLD.BilgDrName = doctor.UserName
  3703. switch items.HisPrescriptionProject.HisProject.CostClassify {
  3704. case 0:
  3705. break
  3706. case 1:
  3707. fsiOPFLD.MedChrgitmType = "14"
  3708. break
  3709. case 2:
  3710. fsiOPFLD.MedChrgitmType = "05"
  3711. break
  3712. case 3:
  3713. fsiOPFLD.MedChrgitmType = "03"
  3714. break
  3715. case 4:
  3716. fsiOPFLD.MedChrgitmType = "03"
  3717. break
  3718. case 5:
  3719. fsiOPFLD.MedChrgitmType = "08"
  3720. break
  3721. case 6:
  3722. fsiOPFLD.MedChrgitmType = "14"
  3723. break
  3724. case 7:
  3725. fsiOPFLD.MedChrgitmType = "14"
  3726. break
  3727. case 8:
  3728. fsiOPFLD.MedChrgitmType = "03"
  3729. break
  3730. case 9:
  3731. fsiOPFLD.MedChrgitmType = "14"
  3732. break
  3733. case 10:
  3734. fsiOPFLD.MedChrgitmType = "14"
  3735. break
  3736. case 11:
  3737. fsiOPFLD.MedChrgitmType = "06"
  3738. break
  3739. case 12:
  3740. fsiOPFLD.MedChrgitmType = "12"
  3741. break
  3742. case 13:
  3743. fsiOPFLD.MedChrgitmType = "01"
  3744. break
  3745. case 14:
  3746. fsiOPFLD.MedChrgitmType = "04"
  3747. break
  3748. case 15:
  3749. fsiOPFLD.MedChrgitmType = "14"
  3750. break
  3751. }
  3752. memo["hosp_appr_flag"] = "1"
  3753. memo["invoice_no"] = order.MdtrtId
  3754. memo["memo"] = "自费"
  3755. bytesData, _ := json.Marshal(memo)
  3756. fsiOPFLD.Memo = string(bytesData)
  3757. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  3758. } else if items.HisPrescriptionProject.Type == 3 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 {
  3759. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  3760. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  3761. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  3762. fsiOPFLD.BilgDeptName = department.Name
  3763. fsiOPFLD.BilgDeptCodg = department.Number
  3764. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  3765. fsiOPFLD.BilgDrName = doctor.UserName
  3766. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  3767. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  3768. fsiOPFLD.MedChrgitmType = "08"
  3769. memo["hosp_appr_flag"] = "1"
  3770. memo["invoice_no"] = order.MdtrtId
  3771. memo["memo"] = "自费"
  3772. bytesData, _ := json.Marshal(memo)
  3773. fsiOPFLD.Memo = string(bytesData)
  3774. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  3775. }
  3776. }
  3777. }
  3778. for _, items := range order_info_two {
  3779. memo := make(map[string]interface{})
  3780. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  3781. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  3782. fsiOPFLD.MedType = "14"
  3783. fsiOPFLD.BkkpSn = items.FeedetlSn
  3784. fsiOPFLD.FixmedinsCode = miConfig.Code
  3785. fsiOPFLD.FixmedinsName = miConfig.OrgName
  3786. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  3787. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  3788. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  3789. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  3790. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  3791. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  3792. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  3793. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  3794. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  3795. fsiOPFLD.BilgDeptName = department.Name
  3796. fsiOPFLD.BilgDeptCodg = department.Number
  3797. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  3798. fsiOPFLD.BilgDrName = doctor.UserName
  3799. fsiOPFLD.MedChrgitmType = "09"
  3800. memo["hosp_appr_flag"] = "1"
  3801. memo["invoice_no"] = order.MdtrtId
  3802. memo["memo"] = "自费"
  3803. bytesData, _ := json.Marshal(memo)
  3804. fsiOPFLD.Memo = string(bytesData)
  3805. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  3806. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  3807. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  3808. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  3809. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  3810. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  3811. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  3812. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  3813. fsiOPFLD.BilgDeptName = department.Name
  3814. fsiOPFLD.BilgDeptCodg = department.Number
  3815. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  3816. fsiOPFLD.BilgDrName = doctor.UserName
  3817. switch items.HisPrescriptionProject.HisProject.CostClassify {
  3818. case 0:
  3819. break
  3820. case 1:
  3821. fsiOPFLD.MedChrgitmType = "14"
  3822. break
  3823. case 2:
  3824. fsiOPFLD.MedChrgitmType = "05"
  3825. break
  3826. case 3:
  3827. fsiOPFLD.MedChrgitmType = "03"
  3828. break
  3829. case 4:
  3830. fsiOPFLD.MedChrgitmType = "03"
  3831. break
  3832. case 5:
  3833. fsiOPFLD.MedChrgitmType = "08"
  3834. break
  3835. case 6:
  3836. fsiOPFLD.MedChrgitmType = "14"
  3837. break
  3838. case 7:
  3839. fsiOPFLD.MedChrgitmType = "14"
  3840. break
  3841. case 8:
  3842. fsiOPFLD.MedChrgitmType = "03"
  3843. break
  3844. case 9:
  3845. fsiOPFLD.MedChrgitmType = "14"
  3846. break
  3847. case 10:
  3848. fsiOPFLD.MedChrgitmType = "14"
  3849. break
  3850. case 11:
  3851. fsiOPFLD.MedChrgitmType = "06"
  3852. break
  3853. case 12:
  3854. fsiOPFLD.MedChrgitmType = "12"
  3855. break
  3856. case 13:
  3857. fsiOPFLD.MedChrgitmType = "01"
  3858. break
  3859. case 14:
  3860. fsiOPFLD.MedChrgitmType = "04"
  3861. break
  3862. case 15:
  3863. fsiOPFLD.MedChrgitmType = "14"
  3864. break
  3865. }
  3866. memo["hosp_appr_flag"] = "1"
  3867. memo["invoice_no"] = order.MdtrtId
  3868. memo["memo"] = "自费"
  3869. bytesData, _ := json.Marshal(memo)
  3870. fsiOPFLD.Memo = string(bytesData)
  3871. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  3872. } else if items.HisPrescriptionProject.Type == 3 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 {
  3873. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  3874. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  3875. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  3876. fsiOPFLD.BilgDeptName = department.Name
  3877. fsiOPFLD.BilgDeptCodg = department.Number
  3878. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  3879. fsiOPFLD.BilgDrName = doctor.UserName
  3880. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  3881. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  3882. fsiOPFLD.MedChrgitmType = "08"
  3883. memo["hosp_appr_flag"] = "1"
  3884. memo["invoice_no"] = order.MdtrtId
  3885. memo["memo"] = "自费"
  3886. bytesData, _ := json.Marshal(memo)
  3887. fsiOPFLD.Memo = string(bytesData)
  3888. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  3889. }
  3890. }
  3891. }
  3892. fmt.Println(fsiOPFLDs)
  3893. struct4201A.Fopfd = fsiOPFLDs
  3894. fmt.Println(struct4201A.Fopfd)
  3895. result, requestLog := service.Gdyb4201A(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4201A)
  3896. saveLog(result, requestLog, "4201A", "自费费用明细上传")
  3897. var res2 ResultSix
  3898. var respJSON2 map[string]interface{}
  3899. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  3900. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3901. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3902. return
  3903. }
  3904. userJSONBytes2, _ := json.Marshal(respJSON2)
  3905. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  3906. utils.ErrorLog("解析失败:%v", err)
  3907. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3908. return
  3909. }
  3910. if res2.Infcode != 0 {
  3911. c.ServeSuccessJSON(map[string]interface{}{
  3912. "failed_code": -10,
  3913. "msg": res2.ErrMsg,
  3914. })
  3915. return
  3916. } else {
  3917. order.IsUploadOrderInfo = 1
  3918. service.UpdateOrder(order)
  3919. c.ServeSuccessJSON(map[string]interface{}{
  3920. "msg": "上传成功",
  3921. })
  3922. }
  3923. }
  3924. func (c *HisApiController) Get4202() {
  3925. order_id, _ := c.GetInt64("order_id")
  3926. admin_user_id, _ := c.GetInt64("admin_user_id")
  3927. order, _ := service.GetHisOrderByIDTwo(order_id)
  3928. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  3929. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3930. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3931. if order.ID == 0 {
  3932. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  3933. return
  3934. }
  3935. var struct4202 models.Struct4202
  3936. struct4202.OwnPayPatnMdtrtD.FixmedinsMdtrtID = his.Number
  3937. struct4202.OwnPayPatnMdtrtD.FixmedinsCode = miConfig.Code
  3938. struct4202.OwnPayPatnMdtrtD.FixmedinsName = miConfig.OrgName
  3939. struct4202.OwnPayPatnMdtrtD.PsnCertType = "01"
  3940. struct4202.OwnPayPatnMdtrtD.Certno = his.IdCardNo
  3941. struct4202.OwnPayPatnMdtrtD.PsnName = his.Name
  3942. struct4202.OwnPayPatnMdtrtD.Begntime = his.InHosptialTime
  3943. struct4202.OwnPayPatnMdtrtD.MedType = "14"
  3944. struct4202.OwnPayPatnMdtrtD.ValiFlag = "1"
  3945. struct4202.OwnPayPatnMdtrtD.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  3946. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  3947. var config []*models.HisXtDiagnoseConfig
  3948. for _, item := range diagnosis_ids {
  3949. id, _ := strconv.ParseInt(item, 10, 64)
  3950. diagnosisConfig, _ := service.FindDiagnoseById(id)
  3951. config = append(config, &diagnosisConfig)
  3952. }
  3953. var tempDiaginfos []models.OwnPayPatnDiagListD
  3954. for index, item := range config {
  3955. if index == 0 {
  3956. var tempDiaginfo models.OwnPayPatnDiagListD
  3957. tempDiaginfo.InoutDiagType = "1"
  3958. tempDiaginfo.DiagCode = item.CountryCode
  3959. tempDiaginfo.DiagName = item.CountryContentName
  3960. tempDiaginfo.DiagType = "1"
  3961. tempDiaginfo.DiagSrtNo = "1"
  3962. tempDiaginfo.MaindiagFlag = "1"
  3963. tempDiaginfo.ValiFlag = "1"
  3964. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  3965. } else {
  3966. var tempDiaginfo models.OwnPayPatnDiagListD
  3967. tempDiaginfo.DiagCode = item.CountryCode
  3968. tempDiaginfo.DiagName = item.CountryContentName
  3969. tempDiaginfo.DiagType = "2"
  3970. tempDiaginfo.DiagSrtNo = strconv.FormatInt(int64(index+1), 10)
  3971. tempDiaginfo.MaindiagFlag = "0"
  3972. tempDiaginfo.ValiFlag = "1"
  3973. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  3974. }
  3975. }
  3976. struct4202.ODiagListD = tempDiaginfos
  3977. result, requestLog := service.Gdyb4202(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4202)
  3978. saveLog(result, requestLog, "4202", "自费就诊和诊断信息上传")
  3979. var res2 ResultSix
  3980. var respJSON2 map[string]interface{}
  3981. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  3982. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3983. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3984. return
  3985. }
  3986. userJSONBytes2, _ := json.Marshal(respJSON2)
  3987. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  3988. utils.ErrorLog("解析失败:%v", err)
  3989. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3990. return
  3991. }
  3992. if res2.Infcode != 0 {
  3993. c.ServeSuccessJSON(map[string]interface{}{
  3994. "failed_code": -10,
  3995. "msg": res2.ErrMsg,
  3996. })
  3997. return
  3998. } else {
  3999. order.IsUploadDiagnose = 1
  4000. service.UpdateOrder(order)
  4001. c.ServeSuccessJSON(map[string]interface{}{
  4002. "msg": "上传成功",
  4003. })
  4004. }
  4005. }
  4006. func (c *HisApiController) Get4203() {
  4007. admin_user_id, _ := c.GetInt64("admin_user_id")
  4008. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  4009. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  4010. order_id, _ := c.GetInt64("order_id")
  4011. order, _ := service.GetHisOrderByIDTwo1111(order_id)
  4012. number := ""
  4013. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  4014. hospital, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  4015. if his.ID == 0 {
  4016. number = hospital.Number
  4017. } else {
  4018. number = his.Number
  4019. }
  4020. result, requestLog := service.Gdyb4203(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, number)
  4021. saveLog(result, requestLog, "4203", "自费就诊与结算明细上传完成")
  4022. var res2 ResultSix
  4023. var respJSON2 map[string]interface{}
  4024. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  4025. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4026. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4027. return
  4028. }
  4029. userJSONBytes2, _ := json.Marshal(respJSON2)
  4030. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  4031. utils.ErrorLog("解析失败:%v", err)
  4032. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4033. return
  4034. }
  4035. if res2.Infcode != 0 {
  4036. c.ServeSuccessJSON(map[string]interface{}{
  4037. "failed_code": -10,
  4038. "msg": res2.ErrMsg,
  4039. })
  4040. return
  4041. } else {
  4042. order.IsUploadSuccess = 1
  4043. service.UpdateOrderTwo(order)
  4044. c.ServeSuccessJSON(map[string]interface{}{
  4045. "msg": "上传成功",
  4046. })
  4047. }
  4048. }
  4049. func (c *HisApiController) Get4205() {
  4050. order_id, _ := c.GetInt64("order_id")
  4051. admin_user_id, _ := c.GetInt64("admin_user_id")
  4052. fapiao_code := c.GetString("fapiao_code")
  4053. order, _ := service.GetHisOrderByIDTwo1111(order_id)
  4054. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  4055. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  4056. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  4057. order_info, _ := service.GetHisOrderInfoByNumber(order.Number)
  4058. order_info_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  4059. //order_info = append(order_info, order_info_two...)
  4060. department, _ := service.GetDepartMentDetail(his.Departments)
  4061. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  4062. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  4063. if order.ID == 0 {
  4064. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  4065. return
  4066. }
  4067. var struct4201A models.Struct4201A
  4068. var fsiOPFLDs []models.FsiOwnpayPatnFeeListDDTO
  4069. for _, items := range order_info {
  4070. memo := make(map[string]interface{})
  4071. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  4072. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  4073. fsiOPFLD.MedType = pre.MedType
  4074. fsiOPFLD.FixmedinsCode = miConfig.Code
  4075. fsiOPFLD.FixmedinsName = miConfig.OrgName
  4076. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  4077. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  4078. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  4079. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  4080. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  4081. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  4082. fsiOPFLD.BkkpSn = items.HisDoctorAdviceInfo.FeedetlSn
  4083. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  4084. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  4085. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  4086. fsiOPFLD.BilgDeptName = department.Name
  4087. fsiOPFLD.BilgDeptCodg = department.Number
  4088. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  4089. fsiOPFLD.BilgDrName = doctor.UserName
  4090. fsiOPFLD.MedChrgitmType = "09"
  4091. memo["hosp_appr_flag"] = "1"
  4092. memo["invoice_no"] = fapiao_code
  4093. memo["memo"] = "自费"
  4094. bytesData, _ := json.Marshal(memo)
  4095. fsiOPFLD.Memo = string(bytesData)
  4096. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  4097. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  4098. fsiOPFLD.BkkpSn = items.HisPrescriptionProject.FeedetlSn
  4099. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  4100. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  4101. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  4102. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  4103. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  4104. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  4105. fsiOPFLD.BilgDeptName = department.Name
  4106. fsiOPFLD.BilgDeptCodg = department.Number
  4107. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  4108. fsiOPFLD.BilgDrName = doctor.UserName
  4109. switch items.HisPrescriptionProject.HisProject.CostClassify {
  4110. case 0:
  4111. break
  4112. case 1:
  4113. fsiOPFLD.MedChrgitmType = "14"
  4114. break
  4115. case 2:
  4116. fsiOPFLD.MedChrgitmType = "05"
  4117. break
  4118. case 3:
  4119. fsiOPFLD.MedChrgitmType = "03"
  4120. break
  4121. case 4:
  4122. fsiOPFLD.MedChrgitmType = "03"
  4123. break
  4124. case 5:
  4125. fsiOPFLD.MedChrgitmType = "08"
  4126. break
  4127. case 6:
  4128. fsiOPFLD.MedChrgitmType = "14"
  4129. break
  4130. case 7:
  4131. fsiOPFLD.MedChrgitmType = "14"
  4132. break
  4133. case 8:
  4134. fsiOPFLD.MedChrgitmType = "03"
  4135. break
  4136. case 9:
  4137. fsiOPFLD.MedChrgitmType = "14"
  4138. break
  4139. case 10:
  4140. fsiOPFLD.MedChrgitmType = "14"
  4141. break
  4142. case 11:
  4143. fsiOPFLD.MedChrgitmType = "06"
  4144. break
  4145. case 12:
  4146. fsiOPFLD.MedChrgitmType = "12"
  4147. break
  4148. case 13:
  4149. fsiOPFLD.MedChrgitmType = "01"
  4150. break
  4151. case 14:
  4152. fsiOPFLD.MedChrgitmType = "04"
  4153. break
  4154. case 15:
  4155. fsiOPFLD.MedChrgitmType = "14"
  4156. break
  4157. }
  4158. memo["hosp_appr_flag"] = "1"
  4159. memo["invoice_no"] = fapiao_code
  4160. memo["memo"] = "自费"
  4161. bytesData, _ := json.Marshal(memo)
  4162. fsiOPFLD.Memo = string(bytesData)
  4163. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  4164. } else if items.HisPrescriptionProject.Type == 3 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 {
  4165. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  4166. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  4167. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  4168. fsiOPFLD.BilgDeptName = department.Name
  4169. fsiOPFLD.BilgDeptCodg = department.Number
  4170. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  4171. fsiOPFLD.BilgDrName = doctor.UserName
  4172. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  4173. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  4174. fsiOPFLD.MedChrgitmType = "08"
  4175. memo["hosp_appr_flag"] = "1"
  4176. memo["invoice_no"] = fapiao_code
  4177. memo["memo"] = "自费"
  4178. bytesData, _ := json.Marshal(memo)
  4179. fsiOPFLD.Memo = string(bytesData)
  4180. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  4181. }
  4182. }
  4183. }
  4184. for _, items := range order_info_two {
  4185. memo := make(map[string]interface{})
  4186. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  4187. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  4188. fsiOPFLD.MedType = pre.MedType
  4189. fsiOPFLD.BkkpSn = items.FeedetlSn
  4190. fsiOPFLD.FixmedinsCode = miConfig.Code
  4191. fsiOPFLD.FixmedinsName = miConfig.OrgName
  4192. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  4193. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  4194. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  4195. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  4196. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  4197. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  4198. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  4199. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  4200. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  4201. fsiOPFLD.BilgDeptName = department.Name
  4202. fsiOPFLD.BilgDeptCodg = department.Number
  4203. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  4204. fsiOPFLD.BilgDrName = doctor.UserName
  4205. fsiOPFLD.MedChrgitmType = "09"
  4206. memo["hosp_appr_flag"] = "1"
  4207. memo["invoice_no"] = fapiao_code
  4208. memo["memo"] = "自费"
  4209. bytesData, _ := json.Marshal(memo)
  4210. fsiOPFLD.Memo = string(bytesData)
  4211. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  4212. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  4213. fsiOPFLD.BkkpSn = items.HisPrescriptionProject.FeedetlSn
  4214. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  4215. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  4216. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  4217. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  4218. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  4219. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  4220. fsiOPFLD.BilgDeptName = department.Name
  4221. fsiOPFLD.BilgDeptCodg = department.Number
  4222. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  4223. fsiOPFLD.BilgDrName = doctor.UserName
  4224. switch items.HisPrescriptionProject.HisProject.CostClassify {
  4225. case 0:
  4226. break
  4227. case 1:
  4228. fsiOPFLD.MedChrgitmType = "14"
  4229. break
  4230. case 2:
  4231. fsiOPFLD.MedChrgitmType = "05"
  4232. break
  4233. case 3:
  4234. fsiOPFLD.MedChrgitmType = "03"
  4235. break
  4236. case 4:
  4237. fsiOPFLD.MedChrgitmType = "03"
  4238. break
  4239. case 5:
  4240. fsiOPFLD.MedChrgitmType = "08"
  4241. break
  4242. case 6:
  4243. fsiOPFLD.MedChrgitmType = "14"
  4244. break
  4245. case 7:
  4246. fsiOPFLD.MedChrgitmType = "14"
  4247. break
  4248. case 8:
  4249. fsiOPFLD.MedChrgitmType = "03"
  4250. break
  4251. case 9:
  4252. fsiOPFLD.MedChrgitmType = "14"
  4253. break
  4254. case 10:
  4255. fsiOPFLD.MedChrgitmType = "14"
  4256. break
  4257. case 11:
  4258. fsiOPFLD.MedChrgitmType = "06"
  4259. break
  4260. case 12:
  4261. fsiOPFLD.MedChrgitmType = "12"
  4262. break
  4263. case 13:
  4264. fsiOPFLD.MedChrgitmType = "01"
  4265. break
  4266. case 14:
  4267. fsiOPFLD.MedChrgitmType = "04"
  4268. break
  4269. case 15:
  4270. fsiOPFLD.MedChrgitmType = "14"
  4271. break
  4272. }
  4273. memo["hosp_appr_flag"] = "1"
  4274. memo["invoice_no"] = fapiao_code
  4275. memo["memo"] = "自费"
  4276. bytesData, _ := json.Marshal(memo)
  4277. fsiOPFLD.Memo = string(bytesData)
  4278. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  4279. } else if items.HisPrescriptionProject.Type == 3 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 {
  4280. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  4281. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  4282. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  4283. fsiOPFLD.BilgDeptName = department.Name
  4284. fsiOPFLD.BilgDeptCodg = department.Number
  4285. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  4286. fsiOPFLD.BilgDrName = doctor.UserName
  4287. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  4288. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  4289. fsiOPFLD.MedChrgitmType = "08"
  4290. memo["hosp_appr_flag"] = "1"
  4291. memo["invoice_no"] = fapiao_code
  4292. memo["memo"] = "自费"
  4293. bytesData, _ := json.Marshal(memo)
  4294. fsiOPFLD.Memo = string(bytesData)
  4295. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  4296. }
  4297. }
  4298. }
  4299. fmt.Println(fsiOPFLDs)
  4300. struct4201A.Fopfd = fsiOPFLDs
  4301. fmt.Println(struct4201A.Fopfd)
  4302. var struct4202 models.Struct4202
  4303. timeLayout := "2006-01-02 15:04:05"
  4304. dataTimeStr := time.Unix(his.Ctime, 0).Format(timeLayout)
  4305. struct4202.OwnPayPatnMdtrtD.FixmedinsMdtrtID = his.Number
  4306. struct4202.OwnPayPatnMdtrtD.FixmedinsCode = miConfig.Code
  4307. struct4202.OwnPayPatnMdtrtD.FixmedinsName = miConfig.OrgName
  4308. struct4202.OwnPayPatnMdtrtD.PsnCertType = "01"
  4309. struct4202.OwnPayPatnMdtrtD.Certno = his.IdCardNo
  4310. struct4202.OwnPayPatnMdtrtD.PsnName = his.Name
  4311. struct4202.OwnPayPatnMdtrtD.Begntime = dataTimeStr
  4312. struct4202.OwnPayPatnMdtrtD.MedType = pre.MedType
  4313. struct4202.OwnPayPatnMdtrtD.ValiFlag = "1"
  4314. struct4202.OwnPayPatnMdtrtD.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  4315. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  4316. var config []*models.HisXtDiagnoseConfig
  4317. for _, item := range diagnosis_ids {
  4318. id, _ := strconv.ParseInt(item, 10, 64)
  4319. diagnosisConfig, _ := service.FindDiagnoseById(id)
  4320. config = append(config, &diagnosisConfig)
  4321. }
  4322. var tempDiaginfos []models.OwnPayPatnDiagListD
  4323. for index, item := range config {
  4324. if index == 0 {
  4325. var tempDiaginfo models.OwnPayPatnDiagListD
  4326. tempDiaginfo.InoutDiagType = "1"
  4327. tempDiaginfo.DiagCode = item.CountryCode
  4328. tempDiaginfo.DiagName = item.CountryContentName
  4329. tempDiaginfo.DiagType = "1"
  4330. tempDiaginfo.DiagSrtNo = "1"
  4331. tempDiaginfo.MaindiagFlag = "1"
  4332. tempDiaginfo.ValiFlag = "1"
  4333. tempDiaginfo.DiagDrName = doctor.UserName
  4334. tempDiaginfo.DiagDrCode = doctor.DoctorNumber
  4335. tempDiaginfo.DiagTime = time.Unix(pre.Ctime, 0).Format("2006-01-02 15:04:05")
  4336. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  4337. } else {
  4338. var tempDiaginfo models.OwnPayPatnDiagListD
  4339. tempDiaginfo.DiagCode = item.CountryCode
  4340. tempDiaginfo.DiagName = item.CountryContentName
  4341. tempDiaginfo.DiagType = "2"
  4342. tempDiaginfo.DiagSrtNo = strconv.FormatInt(int64(index+1), 10)
  4343. tempDiaginfo.MaindiagFlag = "0"
  4344. tempDiaginfo.ValiFlag = "1"
  4345. tempDiaginfo.DiagDrName = doctor.UserName
  4346. tempDiaginfo.DiagDrCode = doctor.DoctorNumber
  4347. tempDiaginfo.DiagTime = time.Unix(pre.Ctime, 0).Format("2006-01-02 15:04:05")
  4348. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  4349. }
  4350. }
  4351. struct4202.ODiagListD = tempDiaginfos
  4352. result, requestLog := service.Gdyb4205(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4202, struct4201A)
  4353. saveLog(result, requestLog, "4205", "自费就诊和诊断信息上传")
  4354. var res2 ResultSix
  4355. var respJSON2 map[string]interface{}
  4356. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  4357. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4358. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4359. return
  4360. }
  4361. userJSONBytes2, _ := json.Marshal(respJSON2)
  4362. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  4363. utils.ErrorLog("解析失败:%v", err)
  4364. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4365. return
  4366. }
  4367. if res2.Infcode != 0 {
  4368. c.ServeSuccessJSON(map[string]interface{}{
  4369. "failed_code": -10,
  4370. "msg": res2.ErrMsg,
  4371. })
  4372. return
  4373. } else {
  4374. order.IsUploadDiagnose = 1
  4375. order.IsUploadOrderInfo = 1
  4376. service.UpdateOrderTwo(order)
  4377. c.ServeSuccessJSON(map[string]interface{}{
  4378. "msg": "上传成功",
  4379. })
  4380. }
  4381. }
  4382. func (c *HisApiController) Get4207() {
  4383. admin_user_id, _ := c.GetInt64("admin_user_id")
  4384. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  4385. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  4386. order_id, _ := c.GetInt64("order_id")
  4387. order, _ := service.GetHisOrderByIDTwo(order_id)
  4388. //his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  4389. var struct4207 models.Struct4207
  4390. struct4207.PageNum = "1"
  4391. struct4207.PageSize = "1000"
  4392. struct4207.FixmedinsCode = miConfig.Code
  4393. struct4207.FixmedinsMdtrtID = order.Number
  4394. result, requestLog := service.Gdyb4207(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4207)
  4395. saveLog(result, requestLog, "4207", "查询")
  4396. var res2 ResultSix
  4397. var respJSON2 map[string]interface{}
  4398. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  4399. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4400. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4401. return
  4402. }
  4403. userJSONBytes2, _ := json.Marshal(respJSON2)
  4404. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  4405. utils.ErrorLog("解析失败:%v", err)
  4406. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4407. return
  4408. }
  4409. if res2.Infcode != 0 {
  4410. c.ServeSuccessJSON(map[string]interface{}{
  4411. "failed_code": -10,
  4412. "msg": res2.ErrMsg,
  4413. })
  4414. return
  4415. } else {
  4416. c.ServeSuccessJSON(map[string]interface{}{
  4417. "msg": "查询成功",
  4418. })
  4419. }
  4420. }
  4421. func (c *HisApiController) Get4208() {
  4422. admin_user_id, _ := c.GetInt64("admin_user_id")
  4423. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  4424. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  4425. order_id, _ := c.GetInt64("order_id")
  4426. order, _ := service.GetHisOrderByIDTwo(order_id)
  4427. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  4428. var struct4208 models.Struct4208
  4429. struct4208.PageNum = "1"
  4430. struct4208.PageSize = "1000"
  4431. struct4208.PsnCertType = "01"
  4432. struct4208.Certno = his.Certno
  4433. struct4208.MedType = order.MedType
  4434. struct4208.PsnName = his.Name
  4435. result, requestLog := service.Gdyb4208(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4208)
  4436. saveLog(result, requestLog, "4208", "查询")
  4437. var res2 ResultSix
  4438. var respJSON2 map[string]interface{}
  4439. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  4440. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4441. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4442. return
  4443. }
  4444. userJSONBytes2, _ := json.Marshal(respJSON2)
  4445. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  4446. utils.ErrorLog("解析失败:%v", err)
  4447. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4448. return
  4449. }
  4450. if res2.Infcode != 0 {
  4451. c.ServeSuccessJSON(map[string]interface{}{
  4452. "failed_code": -10,
  4453. "msg": res2.ErrMsg,
  4454. })
  4455. return
  4456. } else {
  4457. c.ServeSuccessJSON(map[string]interface{}{
  4458. "msg": "查询成功",
  4459. })
  4460. }
  4461. }
  4462. func (c *HisApiController) Get4209() {
  4463. admin_user_id, _ := c.GetInt64("admin_user_id")
  4464. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  4465. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  4466. order_id, _ := c.GetInt64("order_id")
  4467. order, _ := service.GetHisOrderByIDTwo(order_id)
  4468. //his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  4469. var struct4209 models.Struct4209
  4470. struct4209.FixmedinsMdtrtID = order.Number
  4471. struct4209.FixmedinsCode = miConfig.Code
  4472. struct4209.PageSize = "1000"
  4473. struct4209.PageNum = "1"
  4474. result, requestLog := service.Gdyb4209(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4209)
  4475. saveLog(result, requestLog, "4209", "查询")
  4476. var res2 ResultSix
  4477. var respJSON2 map[string]interface{}
  4478. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  4479. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4480. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4481. return
  4482. }
  4483. userJSONBytes2, _ := json.Marshal(respJSON2)
  4484. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  4485. utils.ErrorLog("解析失败:%v", err)
  4486. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4487. return
  4488. }
  4489. if res2.Infcode != 0 {
  4490. c.ServeSuccessJSON(map[string]interface{}{
  4491. "failed_code": -10,
  4492. "msg": res2.ErrMsg,
  4493. })
  4494. return
  4495. } else {
  4496. c.ServeSuccessJSON(map[string]interface{}{
  4497. "msg": "查询成功",
  4498. })
  4499. }
  4500. }
  4501. type Result3101 struct {
  4502. Infcode string `json:"infcode"`
  4503. InfRefmsgid string `json:"inf_refmsgid"`
  4504. RefmsgTime string `json:"refmsg_time"`
  4505. RespondTime string `json:"respond_time"`
  4506. Enctype string `json:"enctype"`
  4507. Signtype string `json:"signtype"`
  4508. ErrMsg string `json:"err_msg"`
  4509. Output struct {
  4510. Result []struct {
  4511. JudgeResultDetailDtos []struct {
  4512. VolaItemType string `json:"vola_item_type"`
  4513. MdtrtID string `json:"mdtrt_id"`
  4514. JrdID string `json:"jrd_id"`
  4515. PatnID string `json:"patn_id"`
  4516. RxID string `json:"rx_id"`
  4517. VolaAmt interface{} `json:"vola_amt"`
  4518. } `json:"judge_result_detail_dtos"`
  4519. RuleID string `json:"rule_id"`
  4520. VolaEvid string `json:"vola_evid"`
  4521. MdtrtID string `json:"mdtrt_id"`
  4522. RuleName string `json:"rule_name"`
  4523. VolaAmtStas string `json:"vola_amt_stas"`
  4524. JrID string `json:"jr_id"`
  4525. PatnID string `json:"patn_id"`
  4526. SevDeg string `json:"sev_deg"`
  4527. VolaAmt float64 `json:"vola_amt"`
  4528. VolaBhvrType string `json:"vola_bhvr_type"`
  4529. VolaCont string `json:"vola_cont"`
  4530. } `json:"result"`
  4531. } `json:"output"`
  4532. }
  4533. type Resultgd3101 struct {
  4534. Infcode int64 `json:"infcode"`
  4535. InfRefmsgid string `json:"inf_refmsgid"`
  4536. RefmsgTime string `json:"refmsg_time"`
  4537. RespondTime string `json:"respond_time"`
  4538. Enctype string `json:"enctype"`
  4539. Signtype string `json:"signtype"`
  4540. ErrMsg string `json:"err_msg"`
  4541. Output struct {
  4542. Result []struct {
  4543. JudgeResultDetailDtos []struct {
  4544. VolaItemType string `json:"vola_item_type"`
  4545. MdtrtID string `json:"mdtrt_id"`
  4546. JrdID string `json:"jrd_id"`
  4547. PatnID string `json:"patn_id"`
  4548. RxID string `json:"rx_id"`
  4549. VolaAmt interface{} `json:"vola_amt"`
  4550. } `json:"judge_result_detail_dtos"`
  4551. RuleID string `json:"rule_id"`
  4552. VolaEvid string `json:"vola_evid"`
  4553. MdtrtID string `json:"mdtrt_id"`
  4554. RuleName string `json:"rule_name"`
  4555. VolaAmtStas string `json:"vola_amt_stas"`
  4556. JrID string `json:"jr_id"`
  4557. PatnID string `json:"patn_id"`
  4558. SevDeg string `json:"sev_deg"`
  4559. VolaAmt float64 `json:"vola_amt"`
  4560. VolaBhvrType string `json:"vola_bhvr_type"`
  4561. VolaCont string `json:"vola_cont"`
  4562. } `json:"result"`
  4563. } `json:"output"`
  4564. }
  4565. func (c *HisApiController) ReadEleToken() {
  4566. admin_user_id, _ := c.GetInt64("admin_user_id")
  4567. his_patient_id, _ := c.GetInt64("his_patient_id")
  4568. adminUser := c.GetAdminUserInfo()
  4569. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  4570. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  4571. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  4572. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  4573. tokens := ReadEleCard(admin_user_id, c.GetAdminUserInfo().CurrentOrgId, c)
  4574. if len(tokens) > 0 {
  4575. c.ServeSuccessJSON(map[string]interface{}{
  4576. "msg": "读取成功",
  4577. })
  4578. } else {
  4579. c.ServeSuccessJSON(map[string]interface{}{
  4580. "failed_code": -10,
  4581. "msg": "读取失败",
  4582. })
  4583. }
  4584. } else if miConfig.MdtrtareaAdmvs == "341203" {
  4585. tokens := ReadEleCardforah(admin_user_id, c.GetAdminUserInfo().CurrentOrgId, c)
  4586. if len(tokens) > 0 {
  4587. c.ServeSuccessJSON(map[string]interface{}{
  4588. "msg": "读取成功",
  4589. })
  4590. } else {
  4591. c.ServeSuccessJSON(map[string]interface{}{
  4592. "failed_code": -10,
  4593. "msg": "读取失败",
  4594. })
  4595. }
  4596. } else if miConfig.MdtrtareaAdmvs == "150499" {
  4597. var api string
  4598. 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 +
  4599. "&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"
  4600. resp, requestErr := http.Get(api)
  4601. if requestErr != nil {
  4602. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4603. }
  4604. body, ioErr := ioutil.ReadAll(resp.Body)
  4605. if ioErr != nil {
  4606. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4607. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4608. }
  4609. var respJSON map[string]interface{}
  4610. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  4611. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4612. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4613. return
  4614. }
  4615. var status string
  4616. status = respJSON["data"].(map[string]interface{})["status"].(string)
  4617. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  4618. var token string
  4619. var res ResultTwo //1101结果
  4620. var res10265 ResultTwo10265 //1101结果
  4621. if status == "0" { //读卡成功
  4622. var card_info string //卡信息
  4623. var busi_card_info string
  4624. token = respJSON["data"].(map[string]interface{})["token"].(string)
  4625. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  4626. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  4627. fmt.Println(card_info)
  4628. fmt.Println(busi_card_info)
  4629. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  4630. result, _ := json.Marshal(respJSON)
  4631. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  4632. utils.ErrorLog("解析失败:%v", err)
  4633. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4634. return
  4635. }
  4636. res.ErrMsg = res10265.ErrMsg
  4637. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  4638. res.Infcode = infocode
  4639. res.Output = res10265.Output
  4640. res.InfRefmsgid = res10265.InfRefmsgid
  4641. if res.Infcode == 0 {
  4642. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  4643. if err == gorm.ErrRecordNotFound {
  4644. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  4645. return
  4646. } else if err != nil {
  4647. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  4648. return
  4649. } else {
  4650. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  4651. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  4652. infoStr := string(Iinfos)
  4653. idetinfoStr := string(Idetinfos)
  4654. //date,age,_ := GetBirthdateAndAge(res.Output.Baseinfo.Certno),
  4655. b, age, _ := getBirthdateAndAge(res.Output.Baseinfo.Certno)
  4656. psn := &models.HisPsn{
  4657. PsnNo: res.Output.Baseinfo.PsnNo,
  4658. PatientId: patient.ID,
  4659. Certno: res.Output.Baseinfo.Certno,
  4660. Gend: res.Output.Baseinfo.Gend,
  4661. Naty: res.Output.Baseinfo.Naty,
  4662. PsnCertType: res.Output.Baseinfo.PsnCertType,
  4663. PsnName: res.Output.Baseinfo.PsnName,
  4664. Age: float64(age),
  4665. Brdy: b,
  4666. Idetinfo: idetinfoStr,
  4667. Insuinfo: infoStr,
  4668. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  4669. CardInfo: card_info,
  4670. VerifyNumber: token,
  4671. IdCardType: 4,
  4672. }
  4673. var rf []*ResultFive
  4674. json.Unmarshal([]byte(infoStr), &rf)
  4675. var insutypes []*ResultFive
  4676. var insutype string
  4677. var is390 int = 0
  4678. var is310 int = 0
  4679. for _, item := range rf {
  4680. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  4681. insutypes = append(insutypes, item)
  4682. }
  4683. }
  4684. if len(insutypes) == 1 {
  4685. insutype = insutypes[0].Insutype
  4686. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  4687. } else {
  4688. for _, i := range insutypes {
  4689. if i.Insutype == "390" {
  4690. is390 = 1
  4691. }
  4692. if i.Insutype == "310" {
  4693. is310 = 1
  4694. }
  4695. }
  4696. }
  4697. if is390 == 1 {
  4698. insutype = "390"
  4699. }
  4700. if is310 == 1 {
  4701. insutype = "310"
  4702. }
  4703. if len(insutypes) == 0 {
  4704. insutype = "310"
  4705. }
  4706. service.CreateHisPsn(psn)
  4707. c.ServeSuccessJSON(map[string]interface{}{
  4708. "patient": patient,
  4709. "number": token,
  4710. "insutype": insutype,
  4711. })
  4712. }
  4713. } else {
  4714. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  4715. return
  4716. }
  4717. } else { //读卡失败
  4718. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  4719. return
  4720. }
  4721. } else if miConfig.MdtrtareaAdmvs == "350500" {
  4722. _, outPutInfo, errMsg := service.ReadEleCardForSettle(miConfig.Code, roles.UserName, roles.AdminUserId)
  4723. if len(errMsg) == 0 {
  4724. type ELeData struct {
  4725. Data struct {
  4726. IdNo string `json:"idNo"`
  4727. IdType string `json:"idType"`
  4728. UserName string `json:"userName"`
  4729. EcToken string `json:"ecToken"`
  4730. InsuOrg string `json:"insuOrg"`
  4731. Gender string `json:"gender"`
  4732. Birthday string `json:"birthday"`
  4733. Nationality string `json:"nationality"`
  4734. Email string `json:"email"`
  4735. Extra string `json:"extra"`
  4736. } `json:"data"`
  4737. Code int `json:"code"`
  4738. Message string `json:"message"`
  4739. }
  4740. var ele ELeData
  4741. err := json.Unmarshal([]byte(outPutInfo), &ele)
  4742. if err != nil {
  4743. utils.ErrorLog("解析失败:%v", err)
  4744. }
  4745. token := ele.Data.EcToken
  4746. if len(token) > 0 {
  4747. psn := &models.HisPsn{
  4748. PsnNo: his.PsnNo,
  4749. Age: 0,
  4750. PatientId: his.PatientId,
  4751. Certno: his.Certno,
  4752. Brdy: his.Brdy,
  4753. Gend: his.Gend,
  4754. Naty: his.Naty,
  4755. PsnCertType: his.PsnCertType,
  4756. PsnName: his.PsnName,
  4757. Idetinfo: his.Idetinfo,
  4758. Insuinfo: his.Iinfo,
  4759. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  4760. CardInfo: outPutInfo,
  4761. VerifyNumber: token,
  4762. }
  4763. service.CreateHisPsn(psn)
  4764. }
  4765. if len(token) > 0 {
  4766. c.ServeSuccessJSON(map[string]interface{}{
  4767. "msg": "读取成功",
  4768. })
  4769. } else {
  4770. c.ServeSuccessJSON(map[string]interface{}{
  4771. "failed_code": -10,
  4772. "msg": "读取失败",
  4773. })
  4774. }
  4775. }
  4776. } else if miConfig.MdtrtareaAdmvs == "360302" {
  4777. _, result := GetELeInfoThree(miConfig.Code, "1", roles.UserName)
  4778. //json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  4779. type ELeData struct {
  4780. Data struct {
  4781. IdNo string `json:"idNo"`
  4782. IdType string `json:"idType"`
  4783. UserName string `json:"userName"`
  4784. EcToken string `json:"ecToken"`
  4785. InsuOrg string `json:"insuOrg"`
  4786. Gender string `json:"gender"`
  4787. Birthday string `json:"birthday"`
  4788. Nationality string `json:"nationality"`
  4789. Email string `json:"email"`
  4790. Extra string `json:"extra"`
  4791. } `json:"data"`
  4792. Code int `json:"code"`
  4793. Message string `json:"message"`
  4794. }
  4795. var ele ELeData
  4796. err := json.Unmarshal([]byte(result), &ele)
  4797. if err != nil {
  4798. utils.ErrorLog("解析失败:%v", err)
  4799. }
  4800. token := ele.Data.EcToken
  4801. token = Remove0000(token)
  4802. fmt.Println(ele.Data.UserName)
  4803. 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)
  4804. saveLog(result2, requestLog2, "1101", "获取人员信息")
  4805. var res ResultTwo
  4806. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  4807. utils.ErrorLog("解析失败:%v", err)
  4808. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4809. return
  4810. }
  4811. if res.Infcode == 0 {
  4812. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  4813. if err == gorm.ErrRecordNotFound {
  4814. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  4815. return
  4816. } else if err != nil {
  4817. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  4818. return
  4819. } else {
  4820. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  4821. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  4822. infoStr := string(Iinfos)
  4823. idetinfoStr := string(Idetinfos)
  4824. psn := &models.HisPsn{
  4825. PsnNo: res.Output.Baseinfo.PsnNo,
  4826. PatientId: patient.ID,
  4827. Certno: res.Output.Baseinfo.Certno,
  4828. Gend: res.Output.Baseinfo.Gend,
  4829. Naty: res.Output.Baseinfo.Naty,
  4830. PsnCertType: res.Output.Baseinfo.PsnCertType,
  4831. PsnName: res.Output.Baseinfo.PsnName,
  4832. Idetinfo: idetinfoStr,
  4833. Insuinfo: infoStr,
  4834. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  4835. CardInfo: "",
  4836. VerifyNumber: token,
  4837. }
  4838. service.CreateHisPsn(psn)
  4839. c.ServeSuccessJSON(map[string]interface{}{
  4840. "patient": patient,
  4841. "number": token,
  4842. })
  4843. }
  4844. } else {
  4845. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  4846. return
  4847. }
  4848. } else if miConfig.MdtrtareaAdmvs == "430800" {
  4849. idNo := c.GetString("idNo")
  4850. userName := c.GetString("userName")
  4851. ecToken := c.GetString("ecToken")
  4852. insuOrg := c.GetString("insuOrg")
  4853. result2, requestLog2 := service.Hnyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, insuOrg, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, ecToken, "", idNo, userName)
  4854. saveLog(result2, requestLog2, "1101", "获取人员信息")
  4855. var res ResultTwo
  4856. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  4857. utils.ErrorLog("解析失败:%v", err)
  4858. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4859. return
  4860. }
  4861. if res.Infcode == 0 {
  4862. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  4863. if err == gorm.ErrRecordNotFound {
  4864. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  4865. return
  4866. } else if err != nil {
  4867. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  4868. return
  4869. } else {
  4870. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  4871. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  4872. infoStr := string(Iinfos)
  4873. idetinfoStr := string(Idetinfos)
  4874. psn := &models.HisPsn{
  4875. PsnNo: res.Output.Baseinfo.PsnNo,
  4876. PatientId: patient.ID,
  4877. Certno: res.Output.Baseinfo.Certno,
  4878. Gend: res.Output.Baseinfo.Gend,
  4879. Naty: res.Output.Baseinfo.Naty,
  4880. PsnCertType: res.Output.Baseinfo.PsnCertType,
  4881. PsnName: res.Output.Baseinfo.PsnName,
  4882. Idetinfo: idetinfoStr,
  4883. Insuinfo: infoStr,
  4884. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  4885. CardInfo: "",
  4886. VerifyNumber: ecToken,
  4887. InsuplcAdmdvs: insuOrg,
  4888. }
  4889. service.CreateHisPsn(psn)
  4890. c.ServeSuccessJSON(map[string]interface{}{
  4891. "patient": patient,
  4892. "number": ecToken,
  4893. })
  4894. }
  4895. } else {
  4896. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  4897. return
  4898. }
  4899. } else if miConfig.MdtrtareaAdmvs == "450721" {
  4900. res := c.GetoleInfo()
  4901. if res.Infcode == 0 {
  4902. var result string
  4903. if res.Output.MdtrtCertType == "01" {
  4904. 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)
  4905. } else if res.Output.MdtrtCertType == "02" {
  4906. 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)
  4907. } else if res.Output.MdtrtCertType == "03" {
  4908. 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)
  4909. }
  4910. var dat map[string]interface{}
  4911. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4912. fmt.Println(dat)
  4913. } else {
  4914. fmt.Println(err)
  4915. }
  4916. userJSONBytes, _ := json.Marshal(dat)
  4917. var res2 ResultTwo
  4918. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  4919. utils.ErrorLog("解析失败:%v", err)
  4920. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4921. return
  4922. }
  4923. if res2.Infcode == 0 {
  4924. patient, err := service.GetPatientByNumber(res.Output.CertNo, c.GetAdminUserInfo().CurrentOrgId)
  4925. if err == gorm.ErrRecordNotFound {
  4926. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  4927. return
  4928. } else if err != nil {
  4929. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  4930. return
  4931. } else {
  4932. Iinfos, _ := json.Marshal(res2.Output.Iinfo)
  4933. Idetinfos, _ := json.Marshal(res2.Output.Idetinfo)
  4934. infoStr := string(Iinfos)
  4935. idetinfoStr := string(Idetinfos)
  4936. var rf []*ResultFive
  4937. json.Unmarshal([]byte(infoStr), &rf)
  4938. var insutypes []*ResultFive
  4939. var insutype string
  4940. var is390 int = 0
  4941. var is310 int = 0
  4942. //var insuplc_admdvs string
  4943. for _, item := range rf {
  4944. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  4945. insutypes = append(insutypes, item)
  4946. }
  4947. }
  4948. if len(insutypes) == 1 {
  4949. insutype = insutypes[0].Insutype
  4950. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  4951. } else {
  4952. for _, i := range insutypes {
  4953. if i.Insutype == "390" {
  4954. is390 = 1
  4955. }
  4956. if i.Insutype == "310" {
  4957. is310 = 1
  4958. }
  4959. }
  4960. }
  4961. if is390 == 1 {
  4962. insutype = "390"
  4963. }
  4964. if is310 == 1 {
  4965. insutype = "310"
  4966. }
  4967. if len(insutypes) == 0 {
  4968. insutype = "310"
  4969. }
  4970. psn := &models.HisPsn{
  4971. PsnNo: res2.Output.Baseinfo.PsnNo,
  4972. PatientId: patient.ID,
  4973. Certno: res2.Output.Baseinfo.Certno,
  4974. Gend: res2.Output.Baseinfo.Gend,
  4975. Naty: res2.Output.Baseinfo.Naty,
  4976. PsnCertType: res2.Output.Baseinfo.PsnCertType,
  4977. PsnName: res2.Output.Baseinfo.PsnName,
  4978. Idetinfo: idetinfoStr,
  4979. Insuinfo: infoStr,
  4980. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  4981. CardInfo: res.Output.CertNo + "|" + res.Output.CardSN,
  4982. VerifyNumber: res.Output.EcToken,
  4983. InsuplcAdmdvs: res.Output.InsuplcAdmdvs,
  4984. }
  4985. service.CreateHisPsn(psn)
  4986. c.ServeSuccessJSON(map[string]interface{}{
  4987. "patient": patient,
  4988. "number": res.Output.CardNo,
  4989. "insutype": insutype,
  4990. })
  4991. }
  4992. } else {
  4993. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  4994. return
  4995. }
  4996. } else {
  4997. c.ServeSuccessJSON(map[string]interface{}{
  4998. "failed_code": -10,
  4999. "msg": res.ErrMsg,
  5000. })
  5001. }
  5002. } else {
  5003. //if initFlag == 0 {
  5004. // c.TestGetBasBaseInit()
  5005. //}
  5006. //token := c.GetEleBaseInfo()
  5007. //token = Remove0000(token)
  5008. type ELeData struct {
  5009. Code string `json:"code"`
  5010. Data struct {
  5011. Aac002 string `json:"aac002"`
  5012. Aaz500 string `json:"aaz500"`
  5013. ActCardNo string `json:"actCardNo"`
  5014. Bab520 string `json:"bab520"`
  5015. Bkz543 string `json:"bkz543"`
  5016. BusinessType string `json:"businessType"`
  5017. CertfCodg string `json:"certfCodg"`
  5018. EcIndexNo string `json:"ecIndexNo"`
  5019. EcToken string `json:"ecToken"`
  5020. ID0000 string `json:"id0000"`
  5021. IDNo string `json:"idNo"`
  5022. IDType string `json:"idType"`
  5023. Idcode string `json:"idcode"`
  5024. IdentityToken string `json:"identity_token"`
  5025. InsuOrg string `json:"insuOrg"`
  5026. OfficeID string `json:"officeId"`
  5027. OfficeName string `json:"officeName"`
  5028. OperatorID string `json:"operatorId"`
  5029. OperatorName string `json:"operatorName"`
  5030. OrgID string `json:"orgId"`
  5031. UserName string `json:"userName"`
  5032. } `json:"data"`
  5033. Infno interface{} `json:"infno"`
  5034. Message string `json:"message"`
  5035. OrgID string `json:"orgId"`
  5036. TransType string `json:"transType"`
  5037. }
  5038. _, result := GetELeInfoThree(miConfig.Code, "1", roles.UserName)
  5039. fmt.Println(result)
  5040. outPutInfo := Remove0000(result)
  5041. fmt.Println(outPutInfo)
  5042. var ele ELeData
  5043. err := json.Unmarshal([]byte(outPutInfo), &ele)
  5044. if err != nil {
  5045. utils.ErrorLog("解析失败:%v", err)
  5046. }
  5047. token := ele.Data.EcToken
  5048. var result2 string
  5049. var requestLog2 string
  5050. if len(token) > 0 {
  5051. if strings.Contains(ele.Data.IDNo, "HKG") {
  5052. 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)
  5053. } else {
  5054. result2, requestLog2 = service.Gdyb1101ForEleCerttwo(miConfig.OrgName, roles.UserName, miConfig.Code, ele.Data.InsuOrg, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, token, ele.Data.UserName, ele.Data.IDNo)
  5055. }
  5056. saveLog(result2, requestLog2, "1101", "获取人员信息")
  5057. var res ResultTwo
  5058. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  5059. utils.ErrorLog("解析失败:%v", err)
  5060. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5061. return
  5062. }
  5063. if res.Infcode == 0 {
  5064. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  5065. if err == gorm.ErrRecordNotFound {
  5066. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  5067. return
  5068. } else if err != nil {
  5069. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  5070. return
  5071. } else {
  5072. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  5073. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  5074. infoStr := string(Iinfos)
  5075. idetinfoStr := string(Idetinfos)
  5076. psn := &models.HisPsn{
  5077. PsnNo: res.Output.Baseinfo.PsnNo,
  5078. PatientId: patient.ID,
  5079. Certno: res.Output.Baseinfo.Certno,
  5080. Gend: res.Output.Baseinfo.Gend,
  5081. Naty: res.Output.Baseinfo.Naty,
  5082. PsnCertType: res.Output.Baseinfo.PsnCertType,
  5083. PsnName: res.Output.Baseinfo.PsnName,
  5084. Idetinfo: idetinfoStr,
  5085. Insuinfo: infoStr,
  5086. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  5087. CardInfo: "",
  5088. VerifyNumber: token,
  5089. }
  5090. service.CreateHisPsn(psn)
  5091. c.ServeSuccessJSON(map[string]interface{}{
  5092. "msg": "读取成功",
  5093. })
  5094. }
  5095. } else {
  5096. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  5097. return
  5098. }
  5099. } else {
  5100. c.ServeSuccessJSON(map[string]interface{}{
  5101. "failed_code": -10,
  5102. "msg": "读取失败",
  5103. })
  5104. }
  5105. }
  5106. }
  5107. func (c *HisApiController) ReadEleFace() {
  5108. admin_user_id, _ := c.GetInt64("admin_user_id")
  5109. //his_patient_id, _ := c.GetInt64("his_patient_id")
  5110. adminUser := c.GetAdminUserInfo()
  5111. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5112. //roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5113. //his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  5114. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  5115. tokens := ReadEleFace(admin_user_id, c.GetAdminUserInfo().CurrentOrgId, c)
  5116. if len(tokens) > 0 {
  5117. c.ServeSuccessJSON(map[string]interface{}{
  5118. "msg": "读取成功",
  5119. })
  5120. } else {
  5121. c.ServeSuccessJSON(map[string]interface{}{
  5122. "failed_code": -10,
  5123. "msg": "读取失败",
  5124. })
  5125. }
  5126. }
  5127. }
  5128. func (c *HisApiController) Get9001() {
  5129. adminUser := c.GetAdminUserInfo()
  5130. admin_user_id, _ := c.GetInt64("admin_user_id")
  5131. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5132. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5133. if miConfig.MdtrtareaAdmvs == "350500" {
  5134. service.GetFjAuthorizationInfo(miConfig.Code)
  5135. } else if miConfig.MdtrtareaAdmvs == "131023" {
  5136. result, _ := service.HeBeiyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  5137. var dat map[string]interface{}
  5138. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5139. fmt.Println(dat)
  5140. } else {
  5141. fmt.Println(err)
  5142. }
  5143. userJSONBytes, _ := json.Marshal(dat)
  5144. var res models.Result9001
  5145. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5146. utils.ErrorLog("解析失败:%v", err)
  5147. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5148. return
  5149. }
  5150. } else if miConfig.MdtrtareaAdmvs == "341203" {
  5151. fmt.Println(miConfig.SecretKey)
  5152. var res models.Result9001Two
  5153. 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 +
  5154. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&cainfo=" + miConfig.Cainfo + "&url=" + miConfig.Url
  5155. resp, requestErr := http.Get(api)
  5156. if requestErr != nil {
  5157. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5158. return
  5159. }
  5160. body, ioErr := ioutil.ReadAll(resp.Body)
  5161. if ioErr != nil {
  5162. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5163. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5164. return
  5165. }
  5166. var respJSON map[string]interface{}
  5167. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5168. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5169. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5170. return
  5171. }
  5172. status := respJSON["data"].(map[string]interface{})["status"].(string)
  5173. if status == "0" {
  5174. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  5175. c.ServeSuccessJSON(map[string]interface{}{
  5176. "failed_code": -10,
  5177. "msg": err_msg,
  5178. })
  5179. return
  5180. }
  5181. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5182. result, _ := json.Marshal(respJSON)
  5183. fmt.Println("log")
  5184. fmt.Println(string(result))
  5185. if err := json.Unmarshal([]byte(result), &res); err != nil {
  5186. utils.ErrorLog("解析失败:%v", err)
  5187. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5188. return
  5189. }
  5190. if res.Infcode == 0 {
  5191. sign := models.HisSignIn{
  5192. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  5193. SignNo: res.Output.Signinoutb.SignNo,
  5194. SignTime: "",
  5195. Ctime: time.Now().Unix(),
  5196. Mtime: time.Now().Unix(),
  5197. Status: 1,
  5198. InputLog: "",
  5199. OutputLog: "",
  5200. FixmedinsCode: miConfig.Code,
  5201. }
  5202. err := service.CreateSignIn(&sign)
  5203. if err == nil {
  5204. c.ServeSuccessJSON(map[string]interface{}{
  5205. "msg": "签到成功",
  5206. })
  5207. }
  5208. } else {
  5209. c.ServeSuccessJSON(map[string]interface{}{
  5210. "failed_code": -10,
  5211. "msg": res.ErrMsg,
  5212. })
  5213. return
  5214. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  5215. //return
  5216. }
  5217. } else {
  5218. result, _ := service.Gdyb9001Two(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  5219. var dat map[string]interface{}
  5220. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5221. fmt.Println(dat)
  5222. } else {
  5223. fmt.Println(err)
  5224. }
  5225. userJSONBytes, _ := json.Marshal(dat)
  5226. var res models.Result9001
  5227. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5228. utils.ErrorLog("解析失败:%v", err)
  5229. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5230. return
  5231. }
  5232. if res.Infcode == 0 {
  5233. sign := models.HisSignIn{
  5234. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  5235. SignNo: res.Output.Signinoutb.SignNo,
  5236. SignTime: res.Output.Signinoutb.SignTime,
  5237. Ctime: time.Now().Unix(),
  5238. Mtime: time.Now().Unix(),
  5239. Status: 1,
  5240. InputLog: "",
  5241. OutputLog: "",
  5242. FixmedinsCode: miConfig.Code,
  5243. }
  5244. err := service.CreateSignIn(&sign)
  5245. if err == nil {
  5246. c.ServeSuccessJSON(map[string]interface{}{
  5247. "msg": "签到成功",
  5248. })
  5249. }
  5250. }
  5251. }
  5252. }
  5253. 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) {
  5254. var res Result3101
  5255. adminUser := c.GetAdminUserInfo()
  5256. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  5257. //his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  5258. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  5259. //record_time := c.GetString("record_time")
  5260. //trig_scen := c.GetString("trig_scen")
  5261. timeLayout := "2006-01-02"
  5262. loc, _ := time.LoadLocation("Local")
  5263. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  5264. if err != nil {
  5265. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5266. return res
  5267. }
  5268. recordDateTime := theTime.Unix()
  5269. var patientPrescription models.HisPrescriptionInfo
  5270. //patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  5271. //if patientPrescription.ID == 0 {
  5272. patientPrescription, _ = service.FindLastPatientPrescriptionInfoTwo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  5273. //}
  5274. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  5275. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  5276. //
  5277. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  5278. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  5279. var pp models.PublicParams
  5280. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  5281. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  5282. pp.FixmedinsName = miConfig.OrgName
  5283. pp.FixmedinsCode = miConfig.Code
  5284. pp.RequestUrl = miConfig.Url
  5285. pp.Cainfo = miConfig.Cainfo
  5286. pp.SecretKey = miConfig.SecretKey
  5287. pp.AccessKey = miConfig.AccessKey
  5288. pp.OpterName = roles.UserName
  5289. var config []*models.HisXtDiagnoseConfig
  5290. for _, item := range diagnosis_ids {
  5291. id, _ := strconv.ParseInt(item, 10, 64)
  5292. diagnosisConfig, _ := service.FindDiagnoseById(id)
  5293. config = append(config, &diagnosisConfig)
  5294. }
  5295. var pd models.PatientDtos
  5296. pd.PatnID = his.PsnNo
  5297. pd.PatnName = his.Name
  5298. pd.Gend = his.Gend
  5299. pd.Brdy = his.Brdy
  5300. pd.Poolarea = miConfig.MdtrtareaAdmvs
  5301. pd.CurrMdtrtID = his.Number
  5302. var fed models.FsiEncounterDtos
  5303. fed.MdtrtID = his.Number
  5304. fed.MedinsID = miConfig.Code
  5305. fed.MedinsName = miConfig.OrgName
  5306. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  5307. fed.MedMdtrtType = "1"
  5308. fed.MedinsType = "1"
  5309. fed.MedinsLv = "11"
  5310. tm := time.Unix(his.RecordDate, 0)
  5311. s_tm := tm.Format("2006-01-02 15:04:05")
  5312. fed.AdmDate = s_tm
  5313. fed.DscgDate = s_tm
  5314. fed.DscgMainDiseCodg = config[0].CountryCode
  5315. fed.DscgMainDiseName = config[0].CountryContentName
  5316. //诊断信息
  5317. var fdds []*models.FsiDiagnoseDtos
  5318. for index, item := range config {
  5319. if index == 0 {
  5320. var fdd models.FsiDiagnoseDtos
  5321. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  5322. fdd.InoutDiseType = "1"
  5323. fdd.MaindiseFlag = "1"
  5324. fdd.DiseDate = s_tm
  5325. fdd.DiasSrtNo = "1"
  5326. fdd.DiseName = item.CountryContentName
  5327. fdd.DiseCodg = item.CountryCode
  5328. fdds = append(fdds, &fdd)
  5329. } else {
  5330. var fdd models.FsiDiagnoseDtos
  5331. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  5332. fdd.InoutDiseType = "1"
  5333. fdd.MaindiseFlag = "1"
  5334. fdd.DiseDate = s_tm
  5335. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  5336. fdd.DiseName = item.CountryContentName
  5337. fdd.DiseCodg = item.CountryCode
  5338. fdds = append(fdds, &fdd)
  5339. }
  5340. }
  5341. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  5342. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  5343. fed.AdmDeptName = department.Name
  5344. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  5345. fed.DscgDeptName = department.Name
  5346. fed.MedMdtrtType = "1"
  5347. fed.MedType = "11"
  5348. //if his.Insutype == "390" {
  5349. // fed.MedType = "1402"
  5350. //} else {
  5351. // fed.MedType = "9933"
  5352. //}
  5353. var orders []*models.FsiOrderDtos
  5354. if trig_scen == "2" {
  5355. //处方医嘱信息
  5356. for _, item := range prescriptions {
  5357. for _, subItem := range item.HisDoctorAdviceInfo {
  5358. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  5359. var order models.FsiOrderDtos
  5360. order.RxID = strconv.FormatInt(item.ID, 10)
  5361. order.Rxno = strconv.FormatInt(item.ID, 10)
  5362. order.LongDrordFlag = "0"
  5363. order.HilistType = "1"
  5364. order.ChrgType = "1"
  5365. order.DrordBhvr = "-"
  5366. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  5367. order.HosplistName = subItem.BaseDrugLib.DrugName
  5368. order.HilistLv = "1"
  5369. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  5370. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  5371. order.HosplistName = subItem.BaseDrugLib.DrugName
  5372. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  5373. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  5374. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  5375. order.OwnpayAmt = ""
  5376. order.SelfpayAmt = ""
  5377. order.Spec = ""
  5378. order.SpecUnt = ""
  5379. order.DrordBegnDate = s_tm
  5380. order.DrordStopDate = ""
  5381. order.DrordDrCodg = doctor_info.DoctorNumber
  5382. order.DrordDeptName = department.Name
  5383. order.DrordDeptCodg = department.Number
  5384. order.DrordDrName = doctor_info.UserName
  5385. order.DrordDrProfttl = "234"
  5386. order.CurrDrordFlag = "1"
  5387. orders = append(orders, &order)
  5388. }
  5389. }
  5390. for _, subItem := range item.HisPrescriptionProject {
  5391. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  5392. var order models.FsiOrderDtos
  5393. order.RxID = strconv.FormatInt(item.ID, 10)
  5394. order.Rxno = strconv.FormatInt(item.ID, 10)
  5395. order.LongDrordFlag = "0"
  5396. order.HilistType = "1"
  5397. order.ChrgType = "1"
  5398. order.DrordBhvr = "-"
  5399. order.HilistCode = subItem.HisProject.MedicalCode
  5400. order.HosplistName = subItem.HisProject.ProjectName
  5401. order.HilistLv = "1"
  5402. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  5403. order.HosplistCode = subItem.HisProject.MedicalCode
  5404. order.HosplistName = subItem.HisProject.ProjectName
  5405. order.Cnt = subItem.Count
  5406. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  5407. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  5408. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  5409. order.OwnpayAmt = ""
  5410. order.SelfpayAmt = ""
  5411. order.Spec = ""
  5412. order.SpecUnt = ""
  5413. order.DrordBegnDate = s_tm
  5414. order.DrordStopDate = ""
  5415. order.DrordDrCodg = doctor_info.DoctorNumber
  5416. order.DrordDeptName = department.Name
  5417. order.DrordDeptCodg = department.Number
  5418. order.DrordDrName = doctor_info.UserName
  5419. order.DrordDrProfttl = "234"
  5420. order.CurrDrordFlag = "1"
  5421. orders = append(orders, &order)
  5422. }
  5423. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  5424. var order models.FsiOrderDtos
  5425. order.RxID = strconv.FormatInt(item.ID, 10)
  5426. order.Rxno = strconv.FormatInt(item.ID, 10)
  5427. order.LongDrordFlag = "0"
  5428. order.HilistType = "1"
  5429. order.ChrgType = "1"
  5430. order.DrordBhvr = "-"
  5431. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  5432. order.HosplistName = subItem.GoodInfo.GoodName
  5433. order.HilistLv = "1"
  5434. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  5435. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  5436. order.HosplistName = subItem.GoodInfo.GoodName
  5437. order.Cnt = subItem.Count
  5438. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  5439. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  5440. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  5441. order.OwnpayAmt = ""
  5442. order.SelfpayAmt = ""
  5443. order.Spec = ""
  5444. order.SpecUnt = ""
  5445. order.DrordBegnDate = s_tm
  5446. order.DrordStopDate = ""
  5447. order.DrordDrCodg = doctor_info.DoctorNumber
  5448. order.DrordDeptName = department.Name
  5449. order.DrordDeptCodg = department.Number
  5450. order.DrordDrName = doctor_info.UserName
  5451. order.DrordDrProfttl = "234"
  5452. order.CurrDrordFlag = "1"
  5453. orders = append(orders, &order)
  5454. }
  5455. }
  5456. }
  5457. //处方医嘱信息
  5458. }
  5459. fed.MatnStas = "0"
  5460. fed.MedfeeSumamt = "0"
  5461. fed.OwnpayAmt = "0"
  5462. fed.SelfpayAmt = "0"
  5463. fed.AcctPayamt = "0"
  5464. fed.MaAmt = "0"
  5465. fed.HifpPayamt = "0"
  5466. fed.SetlTotlnum = "1"
  5467. fed.Insutype = his.Insutype
  5468. fed.ReimFlag = "0"
  5469. fed.OutSetlFlag = "0"
  5470. var fopd []*models.FsiOperationDtosData
  5471. data := make(map[string]interface{})
  5472. data["fed"] = fed
  5473. data["fdd"] = fdds
  5474. data["fod"] = orders
  5475. data["pd"] = pd
  5476. data["pp"] = pp
  5477. data["fopd"] = fopd
  5478. data["trig_scen"] = trig_scen
  5479. fmt.Println(data)
  5480. fmt.Println(fed)
  5481. fmt.Println(fdds)
  5482. fmt.Println(orders)
  5483. fmt.Println(pd)
  5484. fmt.Println(pp)
  5485. fmt.Println(fopd)
  5486. client := &http.Client{}
  5487. bytesData, _ := json.Marshal(data)
  5488. var req *http.Request
  5489. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  5490. if miConfig.MdtrtareaAdmvs == "320921" {
  5491. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  5492. } else {
  5493. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  5494. }
  5495. resp, _ := client.Do(req)
  5496. defer resp.Body.Close()
  5497. body, ioErr := ioutil.ReadAll(resp.Body)
  5498. if ioErr != nil {
  5499. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5500. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5501. return res
  5502. }
  5503. var respJSON map[string]interface{}
  5504. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5505. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5506. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5507. return res
  5508. }
  5509. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  5510. fmt.Println(respJSON)
  5511. result, _ := json.Marshal(respJSON)
  5512. fmt.Println(result)
  5513. if err := json.Unmarshal([]byte(result), &res); err != nil {
  5514. utils.ErrorLog("解析失败:%v", err)
  5515. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5516. return res
  5517. }
  5518. return res
  5519. } else {
  5520. //if miConfig.MdtrtareaAdmvs == "441202" {
  5521. output, input := service.Gdyb3101(pd, fed, fdds, orders, fopd, pp, trig_scen)
  5522. saveLog(output, input, "3101", "事前")
  5523. if err := json.Unmarshal([]byte(output), &res); err != nil {
  5524. utils.ErrorLog("解析失败:%v", err)
  5525. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5526. return
  5527. }
  5528. return res
  5529. //}
  5530. }
  5531. }
  5532. 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) {
  5533. adminUser := c.GetAdminUserInfo()
  5534. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  5535. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  5536. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  5537. //record_time := c.GetString("record_time")
  5538. //trig_scen := c.GetString("trig_scen")
  5539. timeLayout := "2006-01-02"
  5540. loc, _ := time.LoadLocation("Local")
  5541. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  5542. if err != nil {
  5543. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5544. return res
  5545. }
  5546. recordDateTime := theTime.Unix()
  5547. var patientPrescription models.HisPrescriptionInfo
  5548. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  5549. if patientPrescription.ID == 0 {
  5550. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  5551. }
  5552. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  5553. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  5554. //
  5555. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  5556. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  5557. var pp models.PublicParams
  5558. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  5559. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  5560. pp.FixmedinsName = miConfig.OrgName
  5561. pp.FixmedinsCode = miConfig.Code
  5562. pp.RequestUrl = miConfig.Url
  5563. pp.Cainfo = miConfig.Cainfo
  5564. pp.SecretKey = miConfig.SecretKey
  5565. pp.AccessKey = miConfig.AccessKey
  5566. pp.OpterName = roles.UserName
  5567. var config []*models.HisXtDiagnoseConfig
  5568. for _, item := range diagnosis_ids {
  5569. id, _ := strconv.ParseInt(item, 10, 64)
  5570. diagnosisConfig, _ := service.FindDiagnoseById(id)
  5571. config = append(config, &diagnosisConfig)
  5572. }
  5573. var pd models.PatientDtos
  5574. pd.PatnID = his.PsnNo
  5575. pd.PatnName = his.Name
  5576. pd.Gend = his.Gend
  5577. pd.Brdy = his.Brdy
  5578. pd.Poolarea = his.InsuplcAdmdvs
  5579. pd.CurrMdtrtID = his.Number
  5580. var fed models.FsiEncounterDtos
  5581. fed.MdtrtID = his.Number
  5582. fed.MedinsID = miConfig.Code
  5583. fed.MedinsName = miConfig.OrgName
  5584. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  5585. fed.MedMdtrtType = "1"
  5586. fed.MedinsType = "1"
  5587. fed.MedinsLv = "11"
  5588. tm := time.Unix(his.RecordDate, 0)
  5589. s_tm := tm.Format("2006-01-02 15:04:05")
  5590. fed.AdmDate = s_tm
  5591. fed.DscgDate = s_tm
  5592. fed.DscgMainDiseCodg = config[0].CountryCode
  5593. fed.DscgMainDiseName = config[0].CountryContentName
  5594. //诊断信息
  5595. var fdds []*models.FsiDiagnoseDtos
  5596. for index, item := range config {
  5597. if index == 0 {
  5598. var fdd models.FsiDiagnoseDtos
  5599. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  5600. fdd.InoutDiseType = "1"
  5601. fdd.MaindiseFlag = "1"
  5602. fdd.DiseDate = s_tm
  5603. fdd.DiasSrtNo = "1"
  5604. fdd.DiseName = item.CountryContentName
  5605. fdd.DiseCodg = item.CountryCode
  5606. fdds = append(fdds, &fdd)
  5607. } else {
  5608. var fdd models.FsiDiagnoseDtos
  5609. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  5610. fdd.InoutDiseType = "1"
  5611. fdd.MaindiseFlag = "1"
  5612. fdd.DiseDate = s_tm
  5613. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  5614. fdd.DiseName = item.CountryContentName
  5615. fdd.DiseCodg = item.CountryCode
  5616. fdds = append(fdds, &fdd)
  5617. }
  5618. }
  5619. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  5620. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  5621. fed.AdmDeptName = department.Name
  5622. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  5623. fed.DscgDeptName = department.Name
  5624. fed.MedMdtrtType = "1"
  5625. fed.MedType = "11"
  5626. //if his.Insutype == "390" {
  5627. // fed.MedType = "1402"
  5628. //} else {
  5629. // fed.MedType = "9933"
  5630. //}
  5631. var orders []*models.FsiOrderDtos
  5632. if trig_scen == "2" {
  5633. //处方医嘱信息
  5634. for _, item := range prescriptions {
  5635. for _, subItem := range item.HisDoctorAdviceInfo {
  5636. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  5637. var order models.FsiOrderDtos
  5638. order.RxID = strconv.FormatInt(item.ID, 10)
  5639. order.Rxno = strconv.FormatInt(item.ID, 10)
  5640. order.LongDrordFlag = "0"
  5641. order.HilistType = "1"
  5642. order.ChrgType = "1"
  5643. order.DrordBhvr = "-"
  5644. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  5645. order.HosplistName = subItem.BaseDrugLib.DrugName
  5646. order.HilistLv = "1"
  5647. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  5648. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  5649. order.HosplistName = subItem.BaseDrugLib.DrugName
  5650. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  5651. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  5652. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  5653. order.OwnpayAmt = ""
  5654. order.SelfpayAmt = ""
  5655. order.Spec = ""
  5656. order.SpecUnt = ""
  5657. order.DrordBegnDate = s_tm
  5658. order.DrordStopDate = ""
  5659. order.DrordDrCodg = doctor_info.DoctorNumber
  5660. order.DrordDeptName = department.Name
  5661. order.DrordDeptCodg = department.Number
  5662. order.DrordDrName = doctor_info.UserName
  5663. order.DrordDrProfttl = "234"
  5664. order.CurrDrordFlag = "1"
  5665. orders = append(orders, &order)
  5666. }
  5667. }
  5668. for _, subItem := range item.HisPrescriptionProject {
  5669. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  5670. var order models.FsiOrderDtos
  5671. order.RxID = strconv.FormatInt(item.ID, 10)
  5672. order.Rxno = strconv.FormatInt(item.ID, 10)
  5673. order.LongDrordFlag = "0"
  5674. order.HilistType = "1"
  5675. order.ChrgType = "1"
  5676. order.DrordBhvr = "-"
  5677. order.HilistCode = subItem.HisProject.MedicalCode
  5678. order.HosplistName = subItem.HisProject.ProjectName
  5679. order.HilistLv = "1"
  5680. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  5681. order.HosplistCode = subItem.HisProject.MedicalCode
  5682. order.HosplistName = subItem.HisProject.ProjectName
  5683. order.Cnt = subItem.Count
  5684. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  5685. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  5686. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  5687. order.OwnpayAmt = ""
  5688. order.SelfpayAmt = ""
  5689. order.Spec = ""
  5690. order.SpecUnt = ""
  5691. order.DrordBegnDate = s_tm
  5692. order.DrordStopDate = ""
  5693. order.DrordDrCodg = doctor_info.DoctorNumber
  5694. order.DrordDeptName = department.Name
  5695. order.DrordDeptCodg = department.Number
  5696. order.DrordDrName = doctor_info.UserName
  5697. order.DrordDrProfttl = "234"
  5698. order.CurrDrordFlag = "1"
  5699. orders = append(orders, &order)
  5700. }
  5701. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  5702. var order models.FsiOrderDtos
  5703. order.RxID = strconv.FormatInt(item.ID, 10)
  5704. order.Rxno = strconv.FormatInt(item.ID, 10)
  5705. order.LongDrordFlag = "0"
  5706. order.HilistType = "1"
  5707. order.ChrgType = "1"
  5708. order.DrordBhvr = "-"
  5709. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  5710. order.HosplistName = subItem.GoodInfo.GoodName
  5711. order.HilistLv = "1"
  5712. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  5713. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  5714. order.HosplistName = subItem.GoodInfo.GoodName
  5715. order.Cnt = subItem.Count
  5716. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  5717. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  5718. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  5719. order.OwnpayAmt = ""
  5720. order.SelfpayAmt = ""
  5721. order.Spec = ""
  5722. order.SpecUnt = ""
  5723. order.DrordBegnDate = s_tm
  5724. order.DrordStopDate = ""
  5725. order.DrordDrCodg = doctor_info.DoctorNumber
  5726. order.DrordDeptName = department.Name
  5727. order.DrordDeptCodg = department.Number
  5728. order.DrordDrName = doctor_info.UserName
  5729. order.DrordDrProfttl = "234"
  5730. order.CurrDrordFlag = "1"
  5731. orders = append(orders, &order)
  5732. }
  5733. }
  5734. }
  5735. //处方医嘱信息
  5736. }
  5737. fed.MatnStas = "0"
  5738. fed.MedfeeSumamt = "0"
  5739. fed.OwnpayAmt = "0"
  5740. fed.SelfpayAmt = "0"
  5741. fed.AcctPayamt = "0"
  5742. fed.MaAmt = "0"
  5743. fed.HifpPayamt = "0"
  5744. fed.SetlTotlnum = "1"
  5745. fed.Insutype = his.Insutype
  5746. fed.ReimFlag = "0"
  5747. fed.OutSetlFlag = "0"
  5748. var fopd []*models.FsiOperationDtosData
  5749. data := make(map[string]interface{})
  5750. data["fed"] = fed
  5751. data["fdd"] = fdds
  5752. data["fod"] = orders
  5753. data["pd"] = pd
  5754. data["pp"] = pp
  5755. data["fopd"] = fopd
  5756. data["trig_scen"] = trig_scen
  5757. fmt.Println(data)
  5758. fmt.Println(fed)
  5759. fmt.Println(fdds)
  5760. fmt.Println(orders)
  5761. fmt.Println(pd)
  5762. fmt.Println(pp)
  5763. fmt.Println(fopd)
  5764. client := &http.Client{}
  5765. bytesData, _ := json.Marshal(data)
  5766. var req *http.Request
  5767. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  5768. if miConfig.MdtrtareaAdmvs == "320921" {
  5769. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  5770. } else {
  5771. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  5772. }
  5773. resp, _ := client.Do(req)
  5774. defer resp.Body.Close()
  5775. body, ioErr := ioutil.ReadAll(resp.Body)
  5776. if ioErr != nil {
  5777. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5778. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5779. return res
  5780. }
  5781. var respJSON map[string]interface{}
  5782. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5783. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5784. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5785. return res
  5786. }
  5787. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  5788. fmt.Println(respJSON)
  5789. result, _ := json.Marshal(respJSON)
  5790. fmt.Println(result)
  5791. if err := json.Unmarshal([]byte(result), &res); err != nil {
  5792. utils.ErrorLog("解析失败:%v", err)
  5793. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5794. return res
  5795. }
  5796. return res
  5797. } else {
  5798. output, input := service.Gdyb3101(pd, fed, fdds, orders, fopd, pp, trig_scen)
  5799. saveLog(output, input, "3101", "事前")
  5800. if err := json.Unmarshal([]byte(output), &res); err != nil {
  5801. utils.ErrorLog("解析失败:%v", err)
  5802. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5803. return
  5804. }
  5805. return res
  5806. }
  5807. return res
  5808. }
  5809. func Check3102(c *HisApiController, patient_id int64, his_patient_id int64, admin_user_id int64, trig_scen string, order_id int64) (res Result3101) {
  5810. ////patient_id, _ := c.GetInt64("patient_id")
  5811. //order_id, _ := c.GetInt64("order_id")
  5812. ////his_patient_id, _ := c.GetInt64("his_patient_id")
  5813. ////admin_user_id, _ := c.GetInt64("admin_user_id")
  5814. //trig_scen := c.GetString("trig_scen")
  5815. adminUser := c.GetAdminUserInfo()
  5816. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  5817. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  5818. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  5819. record_time := c.GetString("record_time")
  5820. order, _ := service.GetHisOrderByID(order_id)
  5821. psn_info, _ := service.GetPsnByPatientId(patient_id)
  5822. timeLayout := "2006-01-02"
  5823. loc, _ := time.LoadLocation("Local")
  5824. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  5825. if err != nil {
  5826. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5827. return
  5828. }
  5829. recordDateTime := theTime.Unix()
  5830. var patientPrescription models.HisPrescriptionInfo
  5831. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  5832. if patientPrescription.ID == 0 {
  5833. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  5834. }
  5835. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  5836. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  5837. //
  5838. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  5839. prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  5840. var pp models.PublicParams
  5841. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  5842. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  5843. pp.FixmedinsName = miConfig.OrgName
  5844. pp.FixmedinsCode = miConfig.Code
  5845. pp.RequestUrl = miConfig.Url
  5846. pp.Cainfo = miConfig.Cainfo
  5847. pp.SecretKey = miConfig.SecretKey
  5848. pp.AccessKey = miConfig.AccessKey
  5849. pp.OpterName = roles.UserName
  5850. var config []*models.HisXtDiagnoseConfig
  5851. for _, item := range diagnosis_ids {
  5852. id, _ := strconv.ParseInt(item, 10, 64)
  5853. diagnosisConfig, _ := service.FindDiagnoseById(id)
  5854. config = append(config, &diagnosisConfig)
  5855. }
  5856. var pd models.PatientDtos
  5857. pd.PatnID = his.PsnNo
  5858. pd.PatnName = his.Name
  5859. pd.Gend = his.Gend
  5860. pd.Brdy = psn_info.Brdy
  5861. pd.Poolarea = his.InsuplcAdmdvs
  5862. pd.CurrMdtrtID = his.Number
  5863. var fed models.FsiEncounterDtos
  5864. fed.MdtrtID = his.Number
  5865. fed.MedinsID = miConfig.Code
  5866. fed.MedinsName = miConfig.OrgName
  5867. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  5868. fed.MedMdtrtType = "1"
  5869. fed.MedinsType = "1"
  5870. fed.MedinsLv = "11"
  5871. tm := time.Unix(his.RecordDate, 0)
  5872. s_tm := tm.Format("2006-01-02 15:04:05")
  5873. fed.AdmDate = s_tm
  5874. fed.DscgDate = s_tm
  5875. fed.DscgMainDiseCodg = config[0].CountryCode
  5876. fed.DscgMainDiseName = config[0].CountryContentName
  5877. //诊断信息
  5878. var fdds []*models.FsiDiagnoseDtos
  5879. for index, item := range config {
  5880. if index == 0 {
  5881. var fdd models.FsiDiagnoseDtos
  5882. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  5883. fdd.InoutDiseType = "1"
  5884. fdd.MaindiseFlag = "1"
  5885. fdd.DiseDate = s_tm
  5886. fdd.DiasSrtNo = "1"
  5887. fdd.DiseName = item.CountryContentName
  5888. fdd.DiseCodg = item.CountryCode
  5889. fdds = append(fdds, &fdd)
  5890. } else {
  5891. var fdd models.FsiDiagnoseDtos
  5892. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  5893. fdd.InoutDiseType = "1"
  5894. fdd.MaindiseFlag = "1"
  5895. fdd.DiseDate = s_tm
  5896. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  5897. fdd.DiseName = item.CountryContentName
  5898. fdd.DiseCodg = item.CountryCode
  5899. fdds = append(fdds, &fdd)
  5900. }
  5901. }
  5902. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  5903. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  5904. fed.AdmDeptName = department.Name
  5905. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  5906. fed.DscgDeptName = department.Name
  5907. fed.MedType = order.MedType
  5908. //处方医嘱信息
  5909. var orders []*models.FsiOrderDtos
  5910. //for _, item := range prescriptions {
  5911. // for _, subItem := range item.HisDoctorAdviceInfo {
  5912. // var order models.FsiOrderDtos
  5913. // order.RxID = strconv.FormatInt(item.ID, 10)
  5914. // order.Rxno = strconv.FormatInt(item.ID, 10)
  5915. // order.LongDrordFlag = "0"
  5916. // order.HilistType = "1"
  5917. // order.ChrgType = "1"
  5918. // order.DrordBhvr = "-"
  5919. // order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  5920. // order.HosplistName = subItem.BaseDrugLib.DrugName
  5921. // order.HilistLv = "1"
  5922. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  5923. // order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  5924. // order.HosplistName = subItem.BaseDrugLib.DrugName
  5925. // order.Cnt = strconv.FormatFloat(subItem.PrescribingNumber, 'E', -1, 64)
  5926. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  5927. // order.Sumamt = strconv.FormatFloat((subItem.Price * subItem.PrescribingNumber), 'E', -1, 64)
  5928. // order.OwnpayAmt = ""
  5929. // order.SelfpayAmt = ""
  5930. // order.Spec = ""
  5931. // order.SpecUnt = ""
  5932. // order.DrordBegnDate = s_tm
  5933. // order.DrordStopDate = ""
  5934. // order.DrordDrCodg = "1"
  5935. // order.DrordDeptName = department.Name
  5936. // order.DrordDrCodg = "1"
  5937. // order.DrordDrName = doctor_info.UserName
  5938. // order.DrordDrProfttl = ""
  5939. // order.CurrDrordFlag = "1"
  5940. // orders = append(orders, &order)
  5941. // }
  5942. // for _, subItem := range item.HisPrescriptionProject {
  5943. // if subItem.Type == 2 {
  5944. // var order models.FsiOrderDtos
  5945. // order.RxID = strconv.FormatInt(item.ID, 10)
  5946. // order.Rxno = strconv.FormatInt(item.ID, 10)
  5947. // order.LongDrordFlag = "0"
  5948. // order.HilistType = "1"
  5949. // order.ChrgType = "1"
  5950. // order.DrordBhvr = "-"
  5951. // order.HilistCode = subItem.HisProject.MedicalCode
  5952. // order.HosplistName = subItem.HisProject.ProjectName
  5953. // order.HilistLv = "1"
  5954. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  5955. // order.HosplistCode = subItem.HisProject.MedicalCode
  5956. // order.HosplistName = subItem.HisProject.ProjectName
  5957. // order.Cnt = subItem.Count
  5958. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  5959. //
  5960. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  5961. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  5962. // order.OwnpayAmt = ""
  5963. // order.SelfpayAmt = ""
  5964. // order.Spec = ""
  5965. // order.SpecUnt = ""
  5966. // order.DrordBegnDate = s_tm
  5967. // order.DrordStopDate = ""
  5968. // order.DrordDrCodg = "1"
  5969. // order.DrordDeptName = department.Name
  5970. // order.DrordDrCodg = "1"
  5971. // order.DrordDrName = doctor_info.UserName
  5972. // order.DrordDrProfttl = ""
  5973. // order.CurrDrordFlag = "1"
  5974. // orders = append(orders, &order)
  5975. //
  5976. // }
  5977. // if subItem.Type == 3 {
  5978. //
  5979. // var order models.FsiOrderDtos
  5980. // order.RxID = strconv.FormatInt(item.ID, 10)
  5981. // order.Rxno = strconv.FormatInt(item.ID, 10)
  5982. // order.LongDrordFlag = "0"
  5983. // order.HilistType = "1"
  5984. // order.ChrgType = "1"
  5985. // order.DrordBhvr = "-"
  5986. // order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  5987. // order.HosplistName = subItem.GoodInfo.GoodName
  5988. // order.HilistLv = "1"
  5989. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  5990. // order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  5991. // order.HosplistName = subItem.GoodInfo.GoodName
  5992. // order.Cnt = subItem.Count
  5993. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  5994. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  5995. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  5996. // order.OwnpayAmt = ""
  5997. // order.SelfpayAmt = ""
  5998. // order.Spec = ""
  5999. // order.SpecUnt = ""
  6000. // order.DrordBegnDate = s_tm
  6001. // order.DrordStopDate = ""
  6002. // order.DrordDrCodg = "1"
  6003. // order.DrordDeptName = department.Name
  6004. // order.DrordDrCodg = "1"
  6005. // order.DrordDrName = doctor_info.UserName
  6006. // order.DrordDrProfttl = ""
  6007. // order.CurrDrordFlag = "1"
  6008. // orders = append(orders, &order)
  6009. //
  6010. // }
  6011. // }
  6012. //}
  6013. for _, item := range prescriptions {
  6014. for _, subItem := range item.HisDoctorAdviceInfo {
  6015. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  6016. var order models.FsiOrderDtos
  6017. order.RxID = strconv.FormatInt(item.ID, 10)
  6018. order.Rxno = strconv.FormatInt(item.ID, 10)
  6019. order.LongDrordFlag = "0"
  6020. order.HilistType = "1"
  6021. order.ChrgType = "1"
  6022. order.DrordBhvr = "-"
  6023. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  6024. order.HosplistName = subItem.BaseDrugLib.DrugName
  6025. order.HilistLv = "1"
  6026. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  6027. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  6028. order.HosplistName = subItem.BaseDrugLib.DrugName
  6029. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  6030. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  6031. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  6032. order.OwnpayAmt = ""
  6033. order.SelfpayAmt = ""
  6034. order.Spec = ""
  6035. order.SpecUnt = ""
  6036. order.DrordBegnDate = s_tm
  6037. order.DrordStopDate = ""
  6038. order.DrordDrCodg = doctor_info.DoctorNumber
  6039. order.DrordDeptName = department.Name
  6040. order.DrordDeptCodg = department.Number
  6041. order.DrordDrName = doctor_info.UserName
  6042. order.DrordDrProfttl = "234"
  6043. order.CurrDrordFlag = "1"
  6044. orders = append(orders, &order)
  6045. }
  6046. }
  6047. for _, subItem := range item.HisPrescriptionProject {
  6048. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  6049. var order models.FsiOrderDtos
  6050. order.RxID = strconv.FormatInt(item.ID, 10)
  6051. order.Rxno = strconv.FormatInt(item.ID, 10)
  6052. order.LongDrordFlag = "0"
  6053. order.HilistType = "1"
  6054. order.ChrgType = "1"
  6055. order.DrordBhvr = "-"
  6056. order.HilistCode = subItem.HisProject.MedicalCode
  6057. order.HosplistName = subItem.HisProject.ProjectName
  6058. order.HilistLv = "1"
  6059. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  6060. order.HosplistCode = subItem.HisProject.MedicalCode
  6061. order.HosplistName = subItem.HisProject.ProjectName
  6062. order.Cnt = subItem.Count
  6063. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  6064. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  6065. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  6066. order.OwnpayAmt = ""
  6067. order.SelfpayAmt = ""
  6068. order.Spec = ""
  6069. order.SpecUnt = ""
  6070. order.DrordBegnDate = s_tm
  6071. order.DrordStopDate = ""
  6072. order.DrordDrCodg = doctor_info.DoctorNumber
  6073. order.DrordDeptName = department.Name
  6074. order.DrordDeptCodg = department.Number
  6075. order.DrordDrName = doctor_info.UserName
  6076. order.DrordDrProfttl = "234"
  6077. order.CurrDrordFlag = "1"
  6078. orders = append(orders, &order)
  6079. }
  6080. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  6081. var order models.FsiOrderDtos
  6082. order.RxID = strconv.FormatInt(item.ID, 10)
  6083. order.Rxno = strconv.FormatInt(item.ID, 10)
  6084. order.LongDrordFlag = "0"
  6085. order.HilistType = "1"
  6086. order.ChrgType = "1"
  6087. order.DrordBhvr = "0"
  6088. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  6089. order.HosplistName = subItem.GoodInfo.GoodName
  6090. order.HilistLv = "1"
  6091. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  6092. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  6093. order.HosplistName = subItem.GoodInfo.GoodName
  6094. order.Cnt = subItem.Count
  6095. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  6096. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  6097. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  6098. order.OwnpayAmt = ""
  6099. order.SelfpayAmt = ""
  6100. order.Spec = ""
  6101. order.SpecUnt = ""
  6102. order.DrordBegnDate = s_tm
  6103. order.DrordStopDate = ""
  6104. order.DrordDrCodg = doctor_info.DoctorNumber
  6105. order.DrordDeptName = department.Name
  6106. order.DrordDeptCodg = department.Number
  6107. order.DrordDrName = doctor_info.UserName
  6108. order.DrordDrProfttl = "234"
  6109. order.CurrDrordFlag = "1"
  6110. orders = append(orders, &order)
  6111. }
  6112. }
  6113. }
  6114. //处方医嘱信息
  6115. fed.MatnStas = "0"
  6116. fed.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  6117. fed.OwnpayAmt = fmt.Sprintf("%.2f", order.FulamtOwnpayAmt)
  6118. fed.SelfpayAmt = fmt.Sprintf("%.2f", order.PreselfpayAmt)
  6119. fed.AcctPayamt = fmt.Sprintf("%.2f", order.AcctPay)
  6120. fed.MaAmt = fmt.Sprintf("%.2f", order.MafPay)
  6121. fed.HifpPayamt = fmt.Sprintf("%.2f", order.HifpPay)
  6122. fed.SetlTotlnum = "1"
  6123. fed.Insutype = his.Insutype
  6124. fed.ReimFlag = "0"
  6125. fed.OutSetlFlag = "0"
  6126. var fopd []*models.FsiOperationDtosData
  6127. data := make(map[string]interface{})
  6128. data["fed"] = fed
  6129. data["fdd"] = fdds
  6130. data["fod"] = orders
  6131. data["pd"] = pd
  6132. data["pp"] = pp
  6133. data["fopd"] = fopd
  6134. data["trig_scen"] = trig_scen
  6135. client := &http.Client{}
  6136. bytesData, _ := json.Marshal(data)
  6137. var req *http.Request
  6138. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  6139. if miConfig.MdtrtareaAdmvs == "320921" {
  6140. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  6141. } else {
  6142. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  6143. }
  6144. resp, _ := client.Do(req)
  6145. defer resp.Body.Close()
  6146. body, ioErr := ioutil.ReadAll(resp.Body)
  6147. if ioErr != nil {
  6148. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6149. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6150. return res
  6151. }
  6152. var respJSON map[string]interface{}
  6153. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6154. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6155. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6156. return res
  6157. }
  6158. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  6159. result, _ := json.Marshal(respJSON)
  6160. if err := json.Unmarshal([]byte(result), &res); err != nil {
  6161. utils.ErrorLog("解析失败:%v", err)
  6162. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6163. return res
  6164. }
  6165. return res
  6166. } else {
  6167. output, input := service.Gdyb3102(pd, fed, fdds, orders, fopd, pp, trig_scen)
  6168. saveLog(output, input, "3102", "事中")
  6169. if err := json.Unmarshal([]byte(output), &res); err != nil {
  6170. utils.ErrorLog("解析失败:%v", err)
  6171. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6172. return
  6173. }
  6174. return res
  6175. }
  6176. return res
  6177. }
  6178. 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) {
  6179. var res Resultgd3101
  6180. adminUser := c.GetAdminUserInfo()
  6181. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6182. //his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  6183. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6184. //record_time := c.GetString("record_time")
  6185. //trig_scen := c.GetString("trig_scen")
  6186. psn_info, _ := service.GetPsnByPatientId(patient_id)
  6187. timeLayout := "2006-01-02"
  6188. loc, _ := time.LoadLocation("Local")
  6189. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  6190. if err != nil {
  6191. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6192. return res
  6193. }
  6194. recordDateTime := theTime.Unix()
  6195. var patientPrescription models.HisPrescriptionInfo
  6196. //patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  6197. //if patientPrescription.ID == 0 {
  6198. patientPrescription, _ = service.FindLastPatientPrescriptionInfoTwo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  6199. //}
  6200. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  6201. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  6202. //
  6203. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  6204. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  6205. var pp models.PublicParams
  6206. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  6207. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  6208. pp.FixmedinsName = miConfig.OrgName
  6209. pp.FixmedinsCode = miConfig.Code
  6210. pp.RequestUrl = miConfig.Url
  6211. pp.Cainfo = miConfig.Cainfo
  6212. pp.SecretKey = miConfig.SecretKey
  6213. pp.AccessKey = miConfig.AccessKey
  6214. pp.OpterName = roles.UserName
  6215. var config []*models.HisXtDiagnoseConfig
  6216. for _, item := range diagnosis_ids {
  6217. id, _ := strconv.ParseInt(item, 10, 64)
  6218. diagnosisConfig, _ := service.FindDiagnoseById(id)
  6219. config = append(config, &diagnosisConfig)
  6220. }
  6221. var pd models.PatientDtos
  6222. pd.PatnID = his.PsnNo
  6223. pd.PatnName = his.Name
  6224. pd.Gend = his.Gend
  6225. pd.Brdy = psn_info.Brdy
  6226. pd.Poolarea = miConfig.MdtrtareaAdmvs
  6227. pd.CurrMdtrtID = his.Number
  6228. var fed models.FsiEncounterDtos
  6229. fed.MdtrtID = his.Number
  6230. fed.MedinsID = miConfig.Code
  6231. fed.MedinsName = miConfig.OrgName
  6232. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  6233. fed.MedMdtrtType = "1"
  6234. fed.MedinsType = "1"
  6235. fed.MedinsLv = "11"
  6236. tm := time.Unix(his.RecordDate, 0)
  6237. s_tm := tm.Format("2006-01-02 15:04:05")
  6238. fed.AdmDate = s_tm
  6239. fed.DscgDate = s_tm
  6240. fed.DscgMainDiseCodg = config[0].CountryCode
  6241. fed.DscgMainDiseName = config[0].CountryContentName
  6242. //诊断信息
  6243. var fdds []*models.FsiDiagnoseDtos
  6244. for index, item := range config {
  6245. if index == 0 {
  6246. var fdd models.FsiDiagnoseDtos
  6247. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  6248. fdd.InoutDiseType = "1"
  6249. fdd.MaindiseFlag = "1"
  6250. fdd.DiseDate = s_tm
  6251. fdd.DiasSrtNo = "1"
  6252. fdd.DiseName = item.CountryContentName
  6253. fdd.DiseCodg = item.CountryCode
  6254. fdds = append(fdds, &fdd)
  6255. } else {
  6256. var fdd models.FsiDiagnoseDtos
  6257. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  6258. fdd.InoutDiseType = "1"
  6259. fdd.MaindiseFlag = "1"
  6260. fdd.DiseDate = s_tm
  6261. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  6262. fdd.DiseName = item.CountryContentName
  6263. fdd.DiseCodg = item.CountryCode
  6264. fdds = append(fdds, &fdd)
  6265. }
  6266. }
  6267. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  6268. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  6269. fed.AdmDeptName = department.Name
  6270. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  6271. fed.DscgDeptName = department.Name
  6272. fed.MedMdtrtType = "1"
  6273. fed.MedType = "11"
  6274. //if his.Insutype == "390" {
  6275. // fed.MedType = "1402"
  6276. //} else {
  6277. // fed.MedType = "9933"
  6278. //}
  6279. var orders []*models.FsiOrderDtos
  6280. if trig_scen == "2" {
  6281. //处方医嘱信息
  6282. for _, item := range prescriptions {
  6283. for _, subItem := range item.HisDoctorAdviceInfo {
  6284. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  6285. spec := (subItem.BaseDrugLib.Dose + subItem.BaseDrugLib.DoseUnit) + "*" + strconv.FormatInt(subItem.BaseDrugLib.MinNumber, 10) + subItem.BaseDrugLib.MinUnit + "/" + subItem.BaseDrugLib.MaxUnit
  6286. var order models.FsiOrderDtos
  6287. order.RxID = strconv.FormatInt(item.ID, 10)
  6288. order.Rxno = strconv.FormatInt(item.ID, 10)
  6289. order.LongDrordFlag = "0"
  6290. order.HilistType = "1"
  6291. order.ChrgType = "1"
  6292. order.DrordBhvr = "0"
  6293. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  6294. order.HosplistName = subItem.BaseDrugLib.DrugName
  6295. order.HilistLv = "1"
  6296. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  6297. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  6298. order.HosplistName = subItem.BaseDrugLib.DrugName
  6299. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  6300. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  6301. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  6302. order.OwnpayAmt = ""
  6303. order.SelfpayAmt = ""
  6304. order.Spec = spec
  6305. order.SpecUnt = subItem.PrescribingNumberUnit
  6306. order.DrordBegnDate = s_tm
  6307. order.DrordStopDate = ""
  6308. order.DrordDrCodg = doctor_info.DoctorNumber
  6309. order.DrordDeptName = department.Name
  6310. order.DrordDeptCodg = department.Number
  6311. order.DrordDrName = doctor_info.UserName
  6312. order.DrordDrProfttl = "234"
  6313. order.CurrDrordFlag = "1"
  6314. orders = append(orders, &order)
  6315. }
  6316. }
  6317. for _, subItem := range item.HisPrescriptionProject {
  6318. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  6319. var order models.FsiOrderDtos
  6320. order.RxID = strconv.FormatInt(item.ID, 10)
  6321. order.Rxno = strconv.FormatInt(item.ID, 10)
  6322. order.LongDrordFlag = "0"
  6323. order.HilistType = "1"
  6324. order.ChrgType = "1"
  6325. order.DrordBhvr = "0"
  6326. order.HilistCode = subItem.HisProject.MedicalCode
  6327. order.HosplistName = subItem.HisProject.ProjectName
  6328. order.HilistLv = "1"
  6329. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  6330. order.HosplistCode = subItem.HisProject.MedicalCode
  6331. order.HosplistName = subItem.HisProject.ProjectName
  6332. order.Cnt = subItem.Count
  6333. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  6334. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  6335. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  6336. order.OwnpayAmt = ""
  6337. order.SelfpayAmt = ""
  6338. order.Spec = subItem.Unit
  6339. order.SpecUnt = subItem.Unit
  6340. order.DrordBegnDate = s_tm
  6341. order.DrordStopDate = ""
  6342. order.DrordDrCodg = doctor_info.DoctorNumber
  6343. order.DrordDeptName = department.Name
  6344. order.DrordDeptCodg = department.Number
  6345. order.DrordDrName = doctor_info.UserName
  6346. order.DrordDrProfttl = "234"
  6347. order.CurrDrordFlag = "1"
  6348. orders = append(orders, &order)
  6349. }
  6350. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  6351. var order models.FsiOrderDtos
  6352. order.RxID = strconv.FormatInt(item.ID, 10)
  6353. order.Rxno = strconv.FormatInt(item.ID, 10)
  6354. order.LongDrordFlag = "0"
  6355. order.HilistType = "1"
  6356. order.ChrgType = "1"
  6357. order.DrordBhvr = "0"
  6358. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  6359. order.HosplistName = subItem.GoodInfo.GoodName
  6360. order.HilistLv = "1"
  6361. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  6362. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  6363. order.HosplistName = subItem.GoodInfo.GoodName
  6364. order.Cnt = subItem.Count
  6365. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  6366. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  6367. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  6368. order.OwnpayAmt = ""
  6369. order.SelfpayAmt = ""
  6370. order.Spec = subItem.GoodInfo.SpecificationName
  6371. order.SpecUnt = subItem.Unit
  6372. order.DrordBegnDate = s_tm
  6373. order.DrordStopDate = ""
  6374. order.DrordDrCodg = doctor_info.DoctorNumber
  6375. order.DrordDeptName = department.Name
  6376. order.DrordDeptCodg = department.Number
  6377. order.DrordDrName = doctor_info.UserName
  6378. order.DrordDrProfttl = "234"
  6379. order.CurrDrordFlag = "1"
  6380. orders = append(orders, &order)
  6381. }
  6382. }
  6383. }
  6384. //处方医嘱信息
  6385. }
  6386. fed.MatnStas = "0"
  6387. fed.MedfeeSumamt = "0"
  6388. fed.OwnpayAmt = "0"
  6389. fed.SelfpayAmt = "0"
  6390. fed.AcctPayamt = "0"
  6391. fed.MaAmt = "0"
  6392. fed.HifpPayamt = "0"
  6393. fed.SetlTotlnum = "1"
  6394. fed.Insutype = his.Insutype
  6395. fed.ReimFlag = "0"
  6396. fed.OutSetlFlag = "0"
  6397. var fopd []*models.FsiOperationDtosData
  6398. data := make(map[string]interface{})
  6399. data["fed"] = fed
  6400. data["fdd"] = fdds
  6401. data["fod"] = orders
  6402. data["pd"] = pd
  6403. data["pp"] = pp
  6404. data["fopd"] = fopd
  6405. data["trig_scen"] = trig_scen
  6406. fmt.Println(data)
  6407. fmt.Println(fed)
  6408. fmt.Println(fdds)
  6409. fmt.Println(orders)
  6410. fmt.Println(pd)
  6411. fmt.Println(pp)
  6412. fmt.Println(fopd)
  6413. client := &http.Client{}
  6414. bytesData, _ := json.Marshal(data)
  6415. var req *http.Request
  6416. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  6417. if miConfig.MdtrtareaAdmvs == "320921" {
  6418. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  6419. } else {
  6420. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  6421. }
  6422. resp, _ := client.Do(req)
  6423. defer resp.Body.Close()
  6424. body, ioErr := ioutil.ReadAll(resp.Body)
  6425. if ioErr != nil {
  6426. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6427. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6428. return res
  6429. }
  6430. var respJSON map[string]interface{}
  6431. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6432. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6433. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6434. return res
  6435. }
  6436. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  6437. fmt.Println(respJSON)
  6438. result, _ := json.Marshal(respJSON)
  6439. fmt.Println(result)
  6440. if err := json.Unmarshal([]byte(result), &res); err != nil {
  6441. utils.ErrorLog("解析失败:%v", err)
  6442. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6443. return res
  6444. }
  6445. return res
  6446. } else {
  6447. //if miConfig.MdtrtareaAdmvs == "441202" {
  6448. output, input := service.Gdyb3101(pd, fed, fdds, orders, fopd, pp, trig_scen)
  6449. saveLog(output, input, "3101", "事前")
  6450. if err := json.Unmarshal([]byte(output), &res); err != nil {
  6451. utils.ErrorLog("解析失败:%v", err)
  6452. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6453. return
  6454. }
  6455. return res
  6456. //}
  6457. }
  6458. }
  6459. 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) {
  6460. adminUser := c.GetAdminUserInfo()
  6461. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6462. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  6463. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6464. //record_time := c.GetString("record_time")
  6465. //trig_scen := c.GetString("trig_scen")
  6466. psn_info, _ := service.GetPsnByPatientId(patient_id)
  6467. timeLayout := "2006-01-02"
  6468. loc, _ := time.LoadLocation("Local")
  6469. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  6470. if err != nil {
  6471. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6472. return res
  6473. }
  6474. recordDateTime := theTime.Unix()
  6475. var patientPrescription models.HisPrescriptionInfo
  6476. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  6477. if patientPrescription.ID == 0 {
  6478. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  6479. }
  6480. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  6481. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  6482. //
  6483. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  6484. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  6485. var pp models.PublicParams
  6486. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  6487. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  6488. pp.FixmedinsName = miConfig.OrgName
  6489. pp.FixmedinsCode = miConfig.Code
  6490. pp.RequestUrl = miConfig.Url
  6491. pp.Cainfo = miConfig.Cainfo
  6492. pp.SecretKey = miConfig.SecretKey
  6493. pp.AccessKey = miConfig.AccessKey
  6494. pp.OpterName = roles.UserName
  6495. var config []*models.HisXtDiagnoseConfig
  6496. for _, item := range diagnosis_ids {
  6497. id, _ := strconv.ParseInt(item, 10, 64)
  6498. diagnosisConfig, _ := service.FindDiagnoseById(id)
  6499. config = append(config, &diagnosisConfig)
  6500. }
  6501. var pd models.PatientDtos
  6502. pd.PatnID = his.PsnNo
  6503. pd.PatnName = his.Name
  6504. pd.Gend = his.Gend
  6505. pd.Brdy = psn_info.Brdy
  6506. pd.Poolarea = his.InsuplcAdmdvs
  6507. pd.CurrMdtrtID = his.Number
  6508. var fed models.FsiEncounterDtos
  6509. fed.MdtrtID = his.Number
  6510. fed.MedinsID = miConfig.Code
  6511. fed.MedinsName = miConfig.OrgName
  6512. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  6513. fed.MedMdtrtType = "1"
  6514. fed.MedinsType = "1"
  6515. fed.MedinsLv = "11"
  6516. tm := time.Unix(his.RecordDate, 0)
  6517. s_tm := tm.Format("2006-01-02 15:04:05")
  6518. fed.AdmDate = s_tm
  6519. fed.DscgDate = s_tm
  6520. fed.DscgMainDiseCodg = config[0].CountryCode
  6521. fed.DscgMainDiseName = config[0].CountryContentName
  6522. //诊断信息
  6523. var fdds []*models.FsiDiagnoseDtos
  6524. for index, item := range config {
  6525. if index == 0 {
  6526. var fdd models.FsiDiagnoseDtos
  6527. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  6528. fdd.InoutDiseType = "1"
  6529. fdd.MaindiseFlag = "1"
  6530. fdd.DiseDate = s_tm
  6531. fdd.DiasSrtNo = "1"
  6532. fdd.DiseName = item.CountryContentName
  6533. fdd.DiseCodg = item.CountryCode
  6534. fdds = append(fdds, &fdd)
  6535. } else {
  6536. var fdd models.FsiDiagnoseDtos
  6537. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  6538. fdd.InoutDiseType = "1"
  6539. fdd.MaindiseFlag = "1"
  6540. fdd.DiseDate = s_tm
  6541. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  6542. fdd.DiseName = item.CountryContentName
  6543. fdd.DiseCodg = item.CountryCode
  6544. fdds = append(fdds, &fdd)
  6545. }
  6546. }
  6547. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  6548. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  6549. fed.AdmDeptName = department.Name
  6550. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  6551. fed.DscgDeptName = department.Name
  6552. fed.MedMdtrtType = "1"
  6553. fed.MedType = "11"
  6554. //if his.Insutype == "390" {
  6555. // fed.MedType = "1402"
  6556. //} else {
  6557. // fed.MedType = "9933"
  6558. //}
  6559. var orders []*models.FsiOrderDtos
  6560. if trig_scen == "2" {
  6561. //处方医嘱信息
  6562. for _, item := range prescriptions {
  6563. for _, subItem := range item.HisDoctorAdviceInfo {
  6564. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  6565. spec := (subItem.BaseDrugLib.Dose + subItem.BaseDrugLib.DoseUnit) + "*" + strconv.FormatInt(subItem.BaseDrugLib.MinNumber, 10) + subItem.BaseDrugLib.MinUnit + "/" + subItem.BaseDrugLib.MaxUnit
  6566. var order models.FsiOrderDtos
  6567. order.RxID = strconv.FormatInt(item.ID, 10)
  6568. order.Rxno = strconv.FormatInt(item.ID, 10)
  6569. order.LongDrordFlag = "0"
  6570. order.HilistType = "1"
  6571. order.ChrgType = "1"
  6572. order.DrordBhvr = "0"
  6573. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  6574. order.HosplistName = subItem.BaseDrugLib.DrugName
  6575. order.HilistLv = "1"
  6576. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  6577. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  6578. order.HosplistName = subItem.BaseDrugLib.DrugName
  6579. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  6580. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  6581. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  6582. order.OwnpayAmt = ""
  6583. order.SelfpayAmt = ""
  6584. order.Spec = spec
  6585. order.SpecUnt = subItem.PrescribingNumberUnit
  6586. order.DrordBegnDate = s_tm
  6587. order.DrordStopDate = ""
  6588. order.DrordDrCodg = doctor_info.DoctorNumber
  6589. order.DrordDeptName = department.Name
  6590. order.DrordDeptCodg = department.Number
  6591. order.DrordDrName = doctor_info.UserName
  6592. order.DrordDrProfttl = "234"
  6593. order.CurrDrordFlag = "1"
  6594. orders = append(orders, &order)
  6595. }
  6596. }
  6597. for _, subItem := range item.HisPrescriptionProject {
  6598. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  6599. var order models.FsiOrderDtos
  6600. order.RxID = strconv.FormatInt(item.ID, 10)
  6601. order.Rxno = strconv.FormatInt(item.ID, 10)
  6602. order.LongDrordFlag = "0"
  6603. order.HilistType = "1"
  6604. order.ChrgType = "1"
  6605. order.DrordBhvr = "0"
  6606. order.HilistCode = subItem.HisProject.MedicalCode
  6607. order.HosplistName = subItem.HisProject.ProjectName
  6608. order.HilistLv = "1"
  6609. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  6610. order.HosplistCode = subItem.HisProject.MedicalCode
  6611. order.HosplistName = subItem.HisProject.ProjectName
  6612. order.Cnt = subItem.Count
  6613. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  6614. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  6615. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  6616. order.OwnpayAmt = ""
  6617. order.SelfpayAmt = ""
  6618. order.Spec = subItem.Unit
  6619. order.SpecUnt = subItem.Unit
  6620. order.DrordBegnDate = s_tm
  6621. order.DrordStopDate = ""
  6622. order.DrordDrCodg = doctor_info.DoctorNumber
  6623. order.DrordDeptName = department.Name
  6624. order.DrordDeptCodg = department.Number
  6625. order.DrordDrName = doctor_info.UserName
  6626. order.DrordDrProfttl = "234"
  6627. order.CurrDrordFlag = "1"
  6628. orders = append(orders, &order)
  6629. }
  6630. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  6631. var order models.FsiOrderDtos
  6632. order.RxID = strconv.FormatInt(item.ID, 10)
  6633. order.Rxno = strconv.FormatInt(item.ID, 10)
  6634. order.LongDrordFlag = "0"
  6635. order.HilistType = "1"
  6636. order.ChrgType = "1"
  6637. order.DrordBhvr = "0"
  6638. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  6639. order.HosplistName = subItem.GoodInfo.GoodName
  6640. order.HilistLv = "1"
  6641. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  6642. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  6643. order.HosplistName = subItem.GoodInfo.GoodName
  6644. order.Cnt = subItem.Count
  6645. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  6646. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  6647. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  6648. order.OwnpayAmt = ""
  6649. order.SelfpayAmt = ""
  6650. order.Spec = subItem.GoodInfo.SpecificationName
  6651. order.SpecUnt = subItem.Unit
  6652. order.DrordBegnDate = s_tm
  6653. order.DrordStopDate = ""
  6654. order.DrordDrCodg = doctor_info.DoctorNumber
  6655. order.DrordDeptName = department.Name
  6656. order.DrordDeptCodg = department.Number
  6657. order.DrordDrName = doctor_info.UserName
  6658. order.DrordDrProfttl = "234"
  6659. order.CurrDrordFlag = "1"
  6660. orders = append(orders, &order)
  6661. }
  6662. }
  6663. }
  6664. //处方医嘱信息
  6665. }
  6666. fed.MatnStas = "0"
  6667. fed.MedfeeSumamt = "0"
  6668. fed.OwnpayAmt = "0"
  6669. fed.SelfpayAmt = "0"
  6670. fed.AcctPayamt = "0"
  6671. fed.MaAmt = "0"
  6672. fed.HifpPayamt = "0"
  6673. fed.SetlTotlnum = "1"
  6674. fed.Insutype = his.Insutype
  6675. fed.ReimFlag = "0"
  6676. fed.OutSetlFlag = "0"
  6677. var fopd []*models.FsiOperationDtosData
  6678. data := make(map[string]interface{})
  6679. data["fed"] = fed
  6680. data["fdd"] = fdds
  6681. data["fod"] = orders
  6682. data["pd"] = pd
  6683. data["pp"] = pp
  6684. data["fopd"] = fopd
  6685. data["trig_scen"] = trig_scen
  6686. fmt.Println(data)
  6687. fmt.Println(fed)
  6688. fmt.Println(fdds)
  6689. fmt.Println(orders)
  6690. fmt.Println(pd)
  6691. fmt.Println(pp)
  6692. fmt.Println(fopd)
  6693. client := &http.Client{}
  6694. bytesData, _ := json.Marshal(data)
  6695. var req *http.Request
  6696. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  6697. if miConfig.MdtrtareaAdmvs == "320921" {
  6698. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  6699. } else {
  6700. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  6701. }
  6702. resp, _ := client.Do(req)
  6703. defer resp.Body.Close()
  6704. body, ioErr := ioutil.ReadAll(resp.Body)
  6705. if ioErr != nil {
  6706. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6707. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6708. return res
  6709. }
  6710. var respJSON map[string]interface{}
  6711. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6712. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6713. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6714. return res
  6715. }
  6716. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  6717. fmt.Println(respJSON)
  6718. result, _ := json.Marshal(respJSON)
  6719. fmt.Println(result)
  6720. if err := json.Unmarshal([]byte(result), &res); err != nil {
  6721. utils.ErrorLog("解析失败:%v", err)
  6722. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6723. return res
  6724. }
  6725. return res
  6726. } else {
  6727. output, input := service.Gdyb3101(pd, fed, fdds, orders, fopd, pp, trig_scen)
  6728. saveLog(output, input, "3101", "事前")
  6729. if err := json.Unmarshal([]byte(output), &res); err != nil {
  6730. utils.ErrorLog("解析失败:%v", err)
  6731. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6732. return
  6733. }
  6734. return res
  6735. }
  6736. return res
  6737. }
  6738. func Checkgd3102(c *HisApiController, patient_id int64, his_patient_id int64, admin_user_id int64, trig_scen string, order_id int64) (res Resultgd3101) {
  6739. ////patient_id, _ := c.GetInt64("patient_id")
  6740. //order_id, _ := c.GetInt64("order_id")
  6741. ////his_patient_id, _ := c.GetInt64("his_patient_id")
  6742. ////admin_user_id, _ := c.GetInt64("admin_user_id")
  6743. //trig_scen := c.GetString("trig_scen")
  6744. psn_info, _ := service.GetPsnByPatientId(patient_id)
  6745. utils.ErrorLog("解析失败:%v", psn_info)
  6746. adminUser := c.GetAdminUserInfo()
  6747. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6748. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  6749. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6750. record_time := c.GetString("record_time")
  6751. order, _ := service.GetHisOrderByID(order_id)
  6752. timeLayout := "2006-01-02"
  6753. loc, _ := time.LoadLocation("Local")
  6754. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  6755. if err != nil {
  6756. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6757. return
  6758. }
  6759. recordDateTime := theTime.Unix()
  6760. var patientPrescription models.HisPrescriptionInfo
  6761. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  6762. if patientPrescription.ID == 0 {
  6763. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  6764. }
  6765. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  6766. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  6767. //
  6768. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  6769. prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  6770. var pp models.PublicParams
  6771. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  6772. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  6773. pp.FixmedinsName = miConfig.OrgName
  6774. pp.FixmedinsCode = miConfig.Code
  6775. pp.RequestUrl = miConfig.Url
  6776. pp.Cainfo = miConfig.Cainfo
  6777. pp.SecretKey = miConfig.SecretKey
  6778. pp.AccessKey = miConfig.AccessKey
  6779. pp.OpterName = roles.UserName
  6780. var config []*models.HisXtDiagnoseConfig
  6781. for _, item := range diagnosis_ids {
  6782. id, _ := strconv.ParseInt(item, 10, 64)
  6783. diagnosisConfig, _ := service.FindDiagnoseById(id)
  6784. config = append(config, &diagnosisConfig)
  6785. }
  6786. var pd models.PatientDtos
  6787. pd.PatnID = his.PsnNo
  6788. pd.PatnName = his.Name
  6789. pd.Gend = his.Gend
  6790. pd.Brdy = psn_info.Brdy
  6791. pd.Poolarea = his.InsuplcAdmdvs
  6792. pd.CurrMdtrtID = his.Number
  6793. var fed models.FsiEncounterDtos
  6794. fed.MdtrtID = his.Number
  6795. fed.MedinsID = miConfig.Code
  6796. fed.MedinsName = miConfig.OrgName
  6797. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  6798. fed.MedMdtrtType = "1"
  6799. fed.MedinsType = "1"
  6800. fed.MedinsLv = "11"
  6801. tm := time.Unix(his.RecordDate, 0)
  6802. s_tm := tm.Format("2006-01-02 15:04:05")
  6803. fed.AdmDate = s_tm
  6804. fed.DscgDate = s_tm
  6805. fed.DscgMainDiseCodg = config[0].CountryCode
  6806. fed.DscgMainDiseName = config[0].CountryContentName
  6807. //诊断信息
  6808. var fdds []*models.FsiDiagnoseDtos
  6809. for index, item := range config {
  6810. if index == 0 {
  6811. var fdd models.FsiDiagnoseDtos
  6812. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  6813. fdd.InoutDiseType = "1"
  6814. fdd.MaindiseFlag = "1"
  6815. fdd.DiseDate = s_tm
  6816. fdd.DiasSrtNo = "1"
  6817. fdd.DiseName = item.CountryContentName
  6818. fdd.DiseCodg = item.CountryCode
  6819. fdds = append(fdds, &fdd)
  6820. } else {
  6821. var fdd models.FsiDiagnoseDtos
  6822. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  6823. fdd.InoutDiseType = "1"
  6824. fdd.MaindiseFlag = "1"
  6825. fdd.DiseDate = s_tm
  6826. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  6827. fdd.DiseName = item.CountryContentName
  6828. fdd.DiseCodg = item.CountryCode
  6829. fdds = append(fdds, &fdd)
  6830. }
  6831. }
  6832. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  6833. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  6834. fed.AdmDeptName = department.Name
  6835. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  6836. fed.DscgDeptName = department.Name
  6837. fed.MedType = order.MedType
  6838. //处方医嘱信息
  6839. var orders []*models.FsiOrderDtos
  6840. //for _, item := range prescriptions {
  6841. // for _, subItem := range item.HisDoctorAdviceInfo {
  6842. // var order models.FsiOrderDtos
  6843. // order.RxID = strconv.FormatInt(item.ID, 10)
  6844. // order.Rxno = strconv.FormatInt(item.ID, 10)
  6845. // order.LongDrordFlag = "0"
  6846. // order.HilistType = "1"
  6847. // order.ChrgType = "1"
  6848. // order.DrordBhvr = "-"
  6849. // order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  6850. // order.HosplistName = subItem.BaseDrugLib.DrugName
  6851. // order.HilistLv = "1"
  6852. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  6853. // order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  6854. // order.HosplistName = subItem.BaseDrugLib.DrugName
  6855. // order.Cnt = strconv.FormatFloat(subItem.PrescribingNumber, 'E', -1, 64)
  6856. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  6857. // order.Sumamt = strconv.FormatFloat((subItem.Price * subItem.PrescribingNumber), 'E', -1, 64)
  6858. // order.OwnpayAmt = ""
  6859. // order.SelfpayAmt = ""
  6860. // order.Spec = ""
  6861. // order.SpecUnt = ""
  6862. // order.DrordBegnDate = s_tm
  6863. // order.DrordStopDate = ""
  6864. // order.DrordDrCodg = "1"
  6865. // order.DrordDeptName = department.Name
  6866. // order.DrordDrCodg = "1"
  6867. // order.DrordDrName = doctor_info.UserName
  6868. // order.DrordDrProfttl = ""
  6869. // order.CurrDrordFlag = "1"
  6870. // orders = append(orders, &order)
  6871. // }
  6872. // for _, subItem := range item.HisPrescriptionProject {
  6873. // if subItem.Type == 2 {
  6874. // var order models.FsiOrderDtos
  6875. // order.RxID = strconv.FormatInt(item.ID, 10)
  6876. // order.Rxno = strconv.FormatInt(item.ID, 10)
  6877. // order.LongDrordFlag = "0"
  6878. // order.HilistType = "1"
  6879. // order.ChrgType = "1"
  6880. // order.DrordBhvr = "-"
  6881. // order.HilistCode = subItem.HisProject.MedicalCode
  6882. // order.HosplistName = subItem.HisProject.ProjectName
  6883. // order.HilistLv = "1"
  6884. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  6885. // order.HosplistCode = subItem.HisProject.MedicalCode
  6886. // order.HosplistName = subItem.HisProject.ProjectName
  6887. // order.Cnt = subItem.Count
  6888. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  6889. //
  6890. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  6891. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  6892. // order.OwnpayAmt = ""
  6893. // order.SelfpayAmt = ""
  6894. // order.Spec = ""
  6895. // order.SpecUnt = ""
  6896. // order.DrordBegnDate = s_tm
  6897. // order.DrordStopDate = ""
  6898. // order.DrordDrCodg = "1"
  6899. // order.DrordDeptName = department.Name
  6900. // order.DrordDrCodg = "1"
  6901. // order.DrordDrName = doctor_info.UserName
  6902. // order.DrordDrProfttl = ""
  6903. // order.CurrDrordFlag = "1"
  6904. // orders = append(orders, &order)
  6905. //
  6906. // }
  6907. // if subItem.Type == 3 {
  6908. //
  6909. // var order models.FsiOrderDtos
  6910. // order.RxID = strconv.FormatInt(item.ID, 10)
  6911. // order.Rxno = strconv.FormatInt(item.ID, 10)
  6912. // order.LongDrordFlag = "0"
  6913. // order.HilistType = "1"
  6914. // order.ChrgType = "1"
  6915. // order.DrordBhvr = "-"
  6916. // order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  6917. // order.HosplistName = subItem.GoodInfo.GoodName
  6918. // order.HilistLv = "1"
  6919. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  6920. // order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  6921. // order.HosplistName = subItem.GoodInfo.GoodName
  6922. // order.Cnt = subItem.Count
  6923. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  6924. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  6925. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  6926. // order.OwnpayAmt = ""
  6927. // order.SelfpayAmt = ""
  6928. // order.Spec = ""
  6929. // order.SpecUnt = ""
  6930. // order.DrordBegnDate = s_tm
  6931. // order.DrordStopDate = ""
  6932. // order.DrordDrCodg = "1"
  6933. // order.DrordDeptName = department.Name
  6934. // order.DrordDrCodg = "1"
  6935. // order.DrordDrName = doctor_info.UserName
  6936. // order.DrordDrProfttl = ""
  6937. // order.CurrDrordFlag = "1"
  6938. // orders = append(orders, &order)
  6939. //
  6940. // }
  6941. // }
  6942. //}
  6943. for _, item := range prescriptions {
  6944. for _, subItem := range item.HisDoctorAdviceInfo {
  6945. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  6946. spec := (subItem.BaseDrugLib.Dose + subItem.BaseDrugLib.DoseUnit) + "*" + strconv.FormatInt(subItem.BaseDrugLib.MinNumber, 10) + subItem.BaseDrugLib.MinUnit + "/" + subItem.BaseDrugLib.MaxUnit
  6947. var order models.FsiOrderDtos
  6948. order.RxID = strconv.FormatInt(item.ID, 10)
  6949. order.Rxno = strconv.FormatInt(item.ID, 10)
  6950. order.LongDrordFlag = "0"
  6951. order.HilistType = "1"
  6952. order.ChrgType = "1"
  6953. order.DrordBhvr = "0"
  6954. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  6955. order.HosplistName = subItem.BaseDrugLib.DrugName
  6956. order.HilistLv = "1"
  6957. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  6958. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  6959. order.HosplistName = subItem.BaseDrugLib.DrugName
  6960. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  6961. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  6962. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  6963. order.OwnpayAmt = ""
  6964. order.SelfpayAmt = ""
  6965. order.Spec = spec
  6966. order.SpecUnt = subItem.PrescribingNumberUnit
  6967. order.DrordBegnDate = s_tm
  6968. order.DrordStopDate = ""
  6969. order.DrordDrCodg = doctor_info.DoctorNumber
  6970. order.DrordDeptName = department.Name
  6971. order.DrordDeptCodg = department.Number
  6972. order.DrordDrName = doctor_info.UserName
  6973. order.DrordDrProfttl = "234"
  6974. order.CurrDrordFlag = "1"
  6975. orders = append(orders, &order)
  6976. }
  6977. }
  6978. for _, subItem := range item.HisPrescriptionProject {
  6979. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  6980. var order models.FsiOrderDtos
  6981. order.RxID = strconv.FormatInt(item.ID, 10)
  6982. order.Rxno = strconv.FormatInt(item.ID, 10)
  6983. order.LongDrordFlag = "0"
  6984. order.HilistType = "1"
  6985. order.ChrgType = "1"
  6986. order.DrordBhvr = "0"
  6987. order.HilistCode = subItem.HisProject.MedicalCode
  6988. order.HosplistName = subItem.HisProject.ProjectName
  6989. order.HilistLv = "1"
  6990. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  6991. order.HosplistCode = subItem.HisProject.MedicalCode
  6992. order.HosplistName = subItem.HisProject.ProjectName
  6993. order.Cnt = subItem.Count
  6994. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  6995. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  6996. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  6997. order.OwnpayAmt = ""
  6998. order.SelfpayAmt = ""
  6999. order.Spec = subItem.Unit
  7000. order.SpecUnt = subItem.Unit
  7001. order.DrordBegnDate = s_tm
  7002. order.DrordStopDate = ""
  7003. order.DrordDrCodg = doctor_info.DoctorNumber
  7004. order.DrordDeptName = department.Name
  7005. order.DrordDeptCodg = department.Number
  7006. order.DrordDrName = doctor_info.UserName
  7007. order.DrordDrProfttl = "234"
  7008. order.CurrDrordFlag = "1"
  7009. orders = append(orders, &order)
  7010. }
  7011. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  7012. var order models.FsiOrderDtos
  7013. order.RxID = strconv.FormatInt(item.ID, 10)
  7014. order.Rxno = strconv.FormatInt(item.ID, 10)
  7015. order.LongDrordFlag = "0"
  7016. order.HilistType = "1"
  7017. order.ChrgType = "1"
  7018. order.DrordBhvr = "0"
  7019. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  7020. order.HosplistName = subItem.GoodInfo.GoodName
  7021. order.HilistLv = "1"
  7022. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  7023. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  7024. order.HosplistName = subItem.GoodInfo.GoodName
  7025. order.Cnt = subItem.Count
  7026. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  7027. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  7028. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  7029. order.OwnpayAmt = ""
  7030. order.SelfpayAmt = ""
  7031. order.Spec = subItem.GoodInfo.SpecificationName
  7032. order.SpecUnt = subItem.Unit
  7033. order.DrordBegnDate = s_tm
  7034. order.DrordStopDate = ""
  7035. order.DrordDrCodg = doctor_info.DoctorNumber
  7036. order.DrordDeptName = department.Name
  7037. order.DrordDeptCodg = department.Number
  7038. order.DrordDrName = doctor_info.UserName
  7039. order.DrordDrProfttl = "234"
  7040. order.CurrDrordFlag = "1"
  7041. orders = append(orders, &order)
  7042. }
  7043. }
  7044. }
  7045. //处方医嘱信息
  7046. fed.MatnStas = "0"
  7047. fed.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  7048. fed.OwnpayAmt = fmt.Sprintf("%.2f", order.FulamtOwnpayAmt)
  7049. fed.SelfpayAmt = fmt.Sprintf("%.2f", order.PreselfpayAmt)
  7050. fed.AcctPayamt = fmt.Sprintf("%.2f", order.AcctPay)
  7051. fed.MaAmt = fmt.Sprintf("%.2f", order.MafPay)
  7052. fed.HifpPayamt = fmt.Sprintf("%.2f", order.HifpPay)
  7053. fed.SetlTotlnum = "1"
  7054. fed.Insutype = his.Insutype
  7055. fed.ReimFlag = "0"
  7056. fed.OutSetlFlag = "0"
  7057. var fopd []*models.FsiOperationDtosData
  7058. data := make(map[string]interface{})
  7059. data["fed"] = fed
  7060. data["fdd"] = fdds
  7061. data["fod"] = orders
  7062. data["pd"] = pd
  7063. data["pp"] = pp
  7064. data["fopd"] = fopd
  7065. data["trig_scen"] = trig_scen
  7066. client := &http.Client{}
  7067. bytesData, _ := json.Marshal(data)
  7068. var req *http.Request
  7069. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7070. if miConfig.MdtrtareaAdmvs == "320921" {
  7071. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  7072. } else {
  7073. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  7074. }
  7075. resp, _ := client.Do(req)
  7076. defer resp.Body.Close()
  7077. body, ioErr := ioutil.ReadAll(resp.Body)
  7078. if ioErr != nil {
  7079. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7080. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7081. return res
  7082. }
  7083. var respJSON map[string]interface{}
  7084. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7085. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7086. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7087. return res
  7088. }
  7089. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  7090. result, _ := json.Marshal(respJSON)
  7091. if err := json.Unmarshal([]byte(result), &res); err != nil {
  7092. utils.ErrorLog("解析失败:%v", err)
  7093. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7094. return res
  7095. }
  7096. return res
  7097. } else {
  7098. output, input := service.Gdyb3102(pd, fed, fdds, orders, fopd, pp, trig_scen)
  7099. saveLog(output, input, "3102", "事中")
  7100. if err := json.Unmarshal([]byte(output), &res); err != nil {
  7101. utils.ErrorLog("解析失败:%v", err)
  7102. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7103. return
  7104. }
  7105. return res
  7106. }
  7107. return res
  7108. }
  7109. func (c *HisApiController) Check() {
  7110. psn_no := c.GetString("psn_no")
  7111. in := c.GetString("in")
  7112. mt := c.GetString("mt")
  7113. baseParams := models.BaseParams{
  7114. SecretKey: "MSDBYGxXm1Mtyi3PtOUB7n1ktcxwyW57",
  7115. FixmedinsCode: "H15049901371",
  7116. InsuplcAdmdvs: "150499",
  7117. MdtrtareaAdmvs: "150499",
  7118. OrgName: "赤峰费森血液透析中心",
  7119. Doctor: "1111",
  7120. }
  7121. service.Gdyb2001(baseParams, psn_no, in, mt)
  7122. }
  7123. func (c *HisApiController) GetPsnNcdsInfo() {
  7124. admin_user_id, _ := c.GetInt64("admin_user_id")
  7125. patient_id, _ := c.GetInt64("patient_id")
  7126. //id, _ := c.GetInt64("id")
  7127. adminUser := c.GetAdminUserInfo()
  7128. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7129. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  7130. //patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  7131. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7132. //psn_record, _ := service.GetP(id)
  7133. psn_info, _ := service.GetPsnByPatientId(patient_id)
  7134. //psn_record, _ := service.GetPsnNCDSRecordById(id)
  7135. //
  7136. //if psn_record.ID == 0 {
  7137. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  7138. // return
  7139. //}
  7140. var res Result5301
  7141. var res10265 Result5301For10265
  7142. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7143. psn_info, _ := service.GetPsnByPatientId(patient_id)
  7144. var api string
  7145. if miConfig.MdtrtareaAdmvs == "320921" {
  7146. 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 +
  7147. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  7148. } else {
  7149. 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 +
  7150. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  7151. }
  7152. resp, requestErr := http.Get(api)
  7153. if requestErr != nil {
  7154. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7155. return
  7156. }
  7157. body, ioErr := ioutil.ReadAll(resp.Body)
  7158. if ioErr != nil {
  7159. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7160. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7161. return
  7162. }
  7163. var respJSON map[string]interface{}
  7164. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7165. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7166. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7167. return
  7168. }
  7169. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7170. result, _ := json.Marshal(respJSON)
  7171. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  7172. utils.ErrorLog("解析失败:%v", err)
  7173. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7174. return
  7175. }
  7176. res.ErrMsg = res10265.ErrMsg
  7177. res.Output = res10265.Output
  7178. res.InfRefmsgid = res10265.InfRefmsgid
  7179. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  7180. res.Infcode = infocode
  7181. } else if miConfig.MdtrtareaAdmvs == "341203" {
  7182. psn_info, _ := service.GetPsnByPatientId(patient_id)
  7183. var api string
  7184. api = miConfig.SecretKey + "ahyb/5301?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName +
  7185. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  7186. resp, requestErr := http.Get(api)
  7187. if requestErr != nil {
  7188. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7189. return
  7190. }
  7191. body, ioErr := ioutil.ReadAll(resp.Body)
  7192. if ioErr != nil {
  7193. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7194. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7195. return
  7196. }
  7197. var respJSON map[string]interface{}
  7198. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7199. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7200. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7201. return
  7202. }
  7203. status := respJSON["data"].(map[string]interface{})["status"].(string)
  7204. if status == "0" {
  7205. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  7206. c.ServeSuccessJSON(map[string]interface{}{
  7207. "failed_code": -10,
  7208. "msg": err_msg,
  7209. })
  7210. return
  7211. }
  7212. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7213. result, _ := json.Marshal(respJSON)
  7214. if err := json.Unmarshal([]byte(result), &res); err != nil {
  7215. utils.ErrorLog("解析失败:%v", err)
  7216. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7217. return
  7218. }
  7219. } else if miConfig.MdtrtareaAdmvs == "360302" {
  7220. p, _ := service.GetHisPatientById(patient_id)
  7221. result, _ := service.Jxyb5301(p.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, "")
  7222. var dat map[string]interface{}
  7223. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7224. fmt.Println(dat)
  7225. } else {
  7226. fmt.Println(err)
  7227. }
  7228. userJSONBytes, _ := json.Marshal(dat)
  7229. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7230. utils.ErrorLog("解析失败:%v", err)
  7231. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7232. return
  7233. }
  7234. } else if miConfig.MdtrtareaAdmvs == "430800" {
  7235. p, _ := service.GetHisPatientById(patient_id)
  7236. result, _ := service.Hnyb5301(p.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, "")
  7237. var dat map[string]interface{}
  7238. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7239. fmt.Println(dat)
  7240. } else {
  7241. fmt.Println(err)
  7242. }
  7243. userJSONBytes, _ := json.Marshal(dat)
  7244. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7245. utils.ErrorLog("解析失败:%v", err)
  7246. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7247. return
  7248. }
  7249. } else if miConfig.MdtrtareaAdmvs == "420200" {
  7250. p, _ := service.GetHisPatientById(patient_id)
  7251. api := "http://192.168.0.197:9532/" + "/hbyb/5301?psn_no=" + p.PsnNo +
  7252. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  7253. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  7254. resp, requestErr := http.Get(api)
  7255. if requestErr != nil {
  7256. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7257. return
  7258. }
  7259. body, ioErr := ioutil.ReadAll(resp.Body)
  7260. if ioErr != nil {
  7261. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7262. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7263. return
  7264. }
  7265. var respJSON map[string]interface{}
  7266. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7267. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7268. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7269. return
  7270. }
  7271. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7272. result, _ := json.Marshal(respJSON)
  7273. if err := json.Unmarshal([]byte(result), &res); err != nil {
  7274. utils.ErrorLog("解析失败:%v", err)
  7275. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7276. return
  7277. }
  7278. } else if miConfig.MdtrtareaAdmvs == "420902" {
  7279. p, _ := service.GetHisPatientById(patient_id)
  7280. api := miConfig.Url + "hbyb/5301?psn_no=" + p.PsnNo +
  7281. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  7282. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  7283. resp, requestErr := http.Get(api)
  7284. if requestErr != nil {
  7285. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7286. return
  7287. }
  7288. body, ioErr := ioutil.ReadAll(resp.Body)
  7289. if ioErr != nil {
  7290. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7291. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7292. return
  7293. }
  7294. var respJSON map[string]interface{}
  7295. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7296. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7297. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7298. return
  7299. }
  7300. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7301. result, _ := json.Marshal(respJSON)
  7302. if err := json.Unmarshal([]byte(result), &res); err != nil {
  7303. utils.ErrorLog("解析失败:%v", err)
  7304. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7305. return
  7306. }
  7307. } else if miConfig.MdtrtareaAdmvs == "421182" {
  7308. p, _ := service.GetHisPatientById(patient_id)
  7309. api := miConfig.Url + "/hbyb/5301?psn_no=" + p.PsnNo +
  7310. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  7311. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  7312. resp, requestErr := http.Get(api)
  7313. if requestErr != nil {
  7314. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7315. return
  7316. }
  7317. body, ioErr := ioutil.ReadAll(resp.Body)
  7318. if ioErr != nil {
  7319. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7320. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7321. return
  7322. }
  7323. var respJSON map[string]interface{}
  7324. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7325. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7326. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7327. return
  7328. }
  7329. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7330. result, _ := json.Marshal(respJSON)
  7331. if err := json.Unmarshal([]byte(result), &res); err != nil {
  7332. utils.ErrorLog("解析失败:%v", err)
  7333. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7334. return
  7335. }
  7336. } else if miConfig.MdtrtareaAdmvs == "420902" {
  7337. p, _ := service.GetHisPatientById(patient_id)
  7338. api := miConfig.Url + "/hbyb/5301?psn_no=" + p.PsnNo +
  7339. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  7340. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  7341. resp, requestErr := http.Get(api)
  7342. if requestErr != nil {
  7343. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7344. return
  7345. }
  7346. body, ioErr := ioutil.ReadAll(resp.Body)
  7347. if ioErr != nil {
  7348. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7349. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7350. return
  7351. }
  7352. var respJSON map[string]interface{}
  7353. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7354. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7355. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7356. return
  7357. }
  7358. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7359. result, _ := json.Marshal(respJSON)
  7360. if err := json.Unmarshal([]byte(result), &res); err != nil {
  7361. utils.ErrorLog("解析失败:%v", err)
  7362. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7363. return
  7364. }
  7365. } else if miConfig.MdtrtareaAdmvs == "421300" {
  7366. p, _ := service.GetHisPatientById(patient_id)
  7367. api := "http://192.168.124.4:9532/" + "/hbyb/5301?psn_no=" + p.PsnNo +
  7368. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  7369. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  7370. resp, requestErr := http.Get(api)
  7371. if requestErr != nil {
  7372. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7373. return
  7374. }
  7375. body, ioErr := ioutil.ReadAll(resp.Body)
  7376. if ioErr != nil {
  7377. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7378. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7379. return
  7380. }
  7381. var respJSON map[string]interface{}
  7382. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7383. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7384. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7385. return
  7386. }
  7387. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7388. result, _ := json.Marshal(respJSON)
  7389. if err := json.Unmarshal([]byte(result), &res); err != nil {
  7390. utils.ErrorLog("解析失败:%v", err)
  7391. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7392. return
  7393. }
  7394. } else if miConfig.MdtrtareaAdmvs == "441799" {
  7395. p, _ := service.GetHisPatientById(patient_id)
  7396. api := miConfig.Url + "gdyb/5301?psn_no=" + p.PsnNo +
  7397. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  7398. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  7399. resp, requestErr := http.Get(api)
  7400. if requestErr != nil {
  7401. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7402. return
  7403. }
  7404. body, ioErr := ioutil.ReadAll(resp.Body)
  7405. if ioErr != nil {
  7406. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7407. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7408. return
  7409. }
  7410. var respJSON map[string]interface{}
  7411. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7412. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7413. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7414. return
  7415. }
  7416. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7417. result, _ := json.Marshal(respJSON)
  7418. if err := json.Unmarshal([]byte(result), &res); err != nil {
  7419. utils.ErrorLog("解析失败:%v", err)
  7420. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7421. return
  7422. }
  7423. } else {
  7424. result := service.Gdyb5301(psn_info.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  7425. var dat map[string]interface{}
  7426. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7427. fmt.Println(dat)
  7428. } else {
  7429. fmt.Println(err)
  7430. }
  7431. userJSONBytes, _ := json.Marshal(dat)
  7432. if miConfig.Code == "H15049901371" {
  7433. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  7434. utils.ErrorLog("解析失败:%v", err)
  7435. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7436. return
  7437. }
  7438. res.InfRefmsgid = res10265.InfRefmsgid
  7439. res.Output = res10265.Output
  7440. res.ErrMsg = res10265.ErrMsg
  7441. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  7442. res.Infcode = infocode
  7443. } else {
  7444. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7445. utils.ErrorLog("解析失败:%v", err)
  7446. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7447. return
  7448. }
  7449. }
  7450. }
  7451. if res.Infcode == 0 {
  7452. c.ServeSuccessJSON(map[string]interface{}{
  7453. "result": res.Output.Result,
  7454. })
  7455. }
  7456. }
  7457. func (c *HisApiController) CheckInsutype() {
  7458. his_patient_id, _ := c.GetInt64("his_patient_id")
  7459. admin_user_id, _ := c.GetInt64("admin_user_id")
  7460. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7461. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  7462. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7463. result := service.Gdyb90100(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  7464. var dat map[string]interface{}
  7465. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7466. fmt.Println(dat)
  7467. } else {
  7468. fmt.Println(err)
  7469. }
  7470. userJSONBytes, _ := json.Marshal(dat)
  7471. var res Result90100
  7472. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7473. utils.ErrorLog("解析失败:%v", err)
  7474. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7475. return
  7476. }
  7477. if res.Infcode != 0 {
  7478. c.ServeSuccessJSON(map[string]interface{}{
  7479. "failed_code": -10,
  7480. "msg": res.ErrMsg,
  7481. })
  7482. return
  7483. } else {
  7484. fmt.Println(res)
  7485. }
  7486. }
  7487. func (c *HisApiController) CheckCardPWD() {
  7488. card_pwd := c.GetString("card_pwd")
  7489. his_patient_id, _ := c.GetInt64("his_patient_id")
  7490. admin_user_id, _ := c.GetInt64("admin_user_id")
  7491. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7492. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7493. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  7494. psn, _ := service.GetPsnByPatientId(his.PatientId)
  7495. bas := strings.Split(psn.CardInfo, "|")
  7496. basNumber := bas[2]
  7497. if psn.InsuplcAdmdvs[:4] == "4403" {
  7498. result := service.Gdyb90991(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, card_pwd, basNumber)
  7499. var dat map[string]interface{}
  7500. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7501. fmt.Println(dat)
  7502. } else {
  7503. fmt.Println(err)
  7504. }
  7505. userJSONBytes, _ := json.Marshal(dat)
  7506. var res Result90991
  7507. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7508. utils.ErrorLog("解析失败:%v", err)
  7509. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7510. return
  7511. }
  7512. if res.Infcode != 0 {
  7513. c.ServeSuccessJSON(map[string]interface{}{
  7514. "failed_code": -10,
  7515. "msg": res.ErrMsg,
  7516. })
  7517. return
  7518. } else {
  7519. if res.Output.Result.SscnoCheckStat == "0" && res.Output.Result.CardStat != "10" {
  7520. var msg string
  7521. switch res.Output.Result.CardStat {
  7522. case "00":
  7523. msg = "未激活"
  7524. break
  7525. case "10":
  7526. msg = "激活"
  7527. break
  7528. case "20":
  7529. msg = "窗口挂失"
  7530. break
  7531. case "21":
  7532. msg = "电话挂失"
  7533. break
  7534. case "22":
  7535. msg = "单位网上申报挂失"
  7536. break
  7537. case "23":
  7538. msg = "保健办挂失"
  7539. break
  7540. case "24":
  7541. msg = "个人网上挂失"
  7542. break
  7543. case "25":
  7544. msg = "网上服务大厅挂失"
  7545. break
  7546. case "30":
  7547. msg = "注销"
  7548. break
  7549. case "40":
  7550. msg = "回收"
  7551. break
  7552. case "99":
  7553. msg = "制卡中(无效卡)"
  7554. break
  7555. }
  7556. c.ServeSuccessJSON(map[string]interface{}{
  7557. "failed_code": -10,
  7558. "msg": msg,
  7559. })
  7560. return
  7561. } else {
  7562. c.ServeSuccessJSON(map[string]interface{}{
  7563. "msg": "校验成功",
  7564. })
  7565. return
  7566. }
  7567. }
  7568. } else {
  7569. c.ServeSuccessJSON(map[string]interface{}{
  7570. "msg": "校验成功",
  7571. })
  7572. return
  7573. }
  7574. }
  7575. func (c *HisApiController) CheckCardPWDTwo() {
  7576. //card_pwd := c.GetString("card_pwd")
  7577. //his_patient_id, _ := c.GetInt64("his_patient_id")
  7578. admin_user_id, _ := c.GetInt64("admin_user_id")
  7579. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7580. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7581. result := service.Gdyb90991("44030000000629690364", miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, "000000", "BDM421363")
  7582. var dat map[string]interface{}
  7583. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7584. fmt.Println(dat)
  7585. } else {
  7586. fmt.Println(err)
  7587. }
  7588. userJSONBytes, _ := json.Marshal(dat)
  7589. var res Result90991
  7590. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7591. utils.ErrorLog("解析失败:%v", err)
  7592. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7593. return
  7594. }
  7595. if res.Infcode != 0 {
  7596. c.ServeSuccessJSON(map[string]interface{}{
  7597. "failed_code": -10,
  7598. "msg": res.ErrMsg,
  7599. })
  7600. return
  7601. } else {
  7602. if res.Output.Result.SscnoCheckStat == "0" {
  7603. var msg string
  7604. switch res.Output.Result.CardStat {
  7605. case "00":
  7606. msg = "未激活"
  7607. break
  7608. case "10":
  7609. msg = "激活"
  7610. break
  7611. case "20":
  7612. msg = "窗口挂失"
  7613. break
  7614. case "21":
  7615. msg = "电话挂失"
  7616. break
  7617. case "22":
  7618. msg = "单位网上申报挂失"
  7619. break
  7620. case "23":
  7621. msg = "保健办挂失"
  7622. break
  7623. case "24":
  7624. msg = "个人网上挂失"
  7625. break
  7626. case "25":
  7627. msg = "网上服务大厅挂失"
  7628. break
  7629. case "30":
  7630. msg = "注销"
  7631. break
  7632. case "40":
  7633. msg = "回收"
  7634. break
  7635. case "99":
  7636. msg = "制卡中(无效卡)"
  7637. break
  7638. }
  7639. c.ServeSuccessJSON(map[string]interface{}{
  7640. "failed_code": -10,
  7641. "msg": msg,
  7642. })
  7643. return
  7644. } else {
  7645. c.ServeSuccessJSON(map[string]interface{}{
  7646. "msg": "校验成功",
  7647. })
  7648. return
  7649. }
  7650. }
  7651. }
  7652. type ELeCertData struct {
  7653. Data struct {
  7654. Extra string `json:"extra"`
  7655. IDNo string `json:"idNo"`
  7656. IDType string `json:"idType"`
  7657. EcToken string `json:"ecToken"`
  7658. InsuOrg string `json:"insuOrg"`
  7659. UserName string `json:"userName"`
  7660. EcIndexNo string `json:"ecIndexNo"`
  7661. Gender string `json:"gender"`
  7662. Birthday string `json:"birthday"`
  7663. Nationality string `json:"nationality"`
  7664. Email string `json:"email"`
  7665. } `json:"OutData"`
  7666. }
  7667. func (c *HisApiController) ReadCard() {
  7668. id_card_type, _ := c.GetInt64("id_card_type")
  7669. admin_user_id, _ := c.GetInt64("admin_user_id")
  7670. certificates, _ := c.GetInt64("certificates")
  7671. //insuplc_admdvs_str := c.GetString("insuplc_admdvs")
  7672. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7673. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7674. switch id_card_type {
  7675. case 1:
  7676. if miConfig.MdtrtareaAdmvs == "421300" {
  7677. var res ResultTwo
  7678. api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  7679. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  7680. "&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)
  7681. resp, requestErr := http.Get(api)
  7682. if requestErr != nil {
  7683. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7684. return
  7685. }
  7686. body, ioErr := ioutil.ReadAll(resp.Body)
  7687. if ioErr != nil {
  7688. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7689. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7690. return
  7691. }
  7692. var respJSON map[string]interface{}
  7693. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7694. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7695. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7696. return
  7697. }
  7698. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7699. result, _ := json.Marshal(respJSON)
  7700. fmt.Println("log")
  7701. fmt.Println(string(result))
  7702. if err := json.Unmarshal([]byte(result), &res); err != nil {
  7703. utils.ErrorLog("解析失败:%v", err)
  7704. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7705. return
  7706. }
  7707. if res.Infcode == 0 {
  7708. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  7709. if err == gorm.ErrRecordNotFound {
  7710. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  7711. return
  7712. } else if err != nil {
  7713. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  7714. return
  7715. } else {
  7716. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  7717. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  7718. infoStr := string(Iinfos)
  7719. idetinfoStr := string(Idetinfos)
  7720. var rf []*ResultFive
  7721. json.Unmarshal([]byte(infoStr), &rf)
  7722. var insutypes []*ResultFive
  7723. var insutype string
  7724. var is390 int = 0
  7725. var is310 int = 0
  7726. for _, item := range rf {
  7727. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  7728. insutypes = append(insutypes, item)
  7729. }
  7730. }
  7731. if len(insutypes) == 1 {
  7732. insutype = insutypes[0].Insutype
  7733. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  7734. } else {
  7735. for _, i := range insutypes {
  7736. if i.Insutype == "390" {
  7737. is390 = 1
  7738. }
  7739. if i.Insutype == "310" {
  7740. is310 = 1
  7741. }
  7742. }
  7743. }
  7744. if is390 == 1 {
  7745. insutype = "390"
  7746. }
  7747. if is310 == 1 {
  7748. insutype = "310"
  7749. }
  7750. if len(insutypes) == 0 {
  7751. insutype = "390"
  7752. }
  7753. var insuplc_admdvs string
  7754. for _, item := range rf {
  7755. if item.Insutype == insutype {
  7756. insuplc_admdvs = item.InsuplcAdmdvs
  7757. }
  7758. }
  7759. if strings.Contains(insuplc_admdvs, "4213") {
  7760. insuplc_admdvs = miConfig.MdtrtareaAdmvs
  7761. }
  7762. psn := &models.HisPsn{
  7763. PsnNo: res.Output.Baseinfo.PsnNo,
  7764. PatientId: patient.ID,
  7765. Certno: res.Output.Baseinfo.Certno,
  7766. Gend: res.Output.Baseinfo.Gend,
  7767. Naty: res.Output.Baseinfo.Naty,
  7768. PsnCertType: res.Output.Baseinfo.PsnCertType,
  7769. PsnName: res.Output.Baseinfo.PsnName,
  7770. Idetinfo: idetinfoStr,
  7771. Insuinfo: infoStr,
  7772. InsuplcAdmdvs: insuplc_admdvs,
  7773. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  7774. }
  7775. service.CreateHisPsn(psn)
  7776. c.ServeSuccessJSON(map[string]interface{}{
  7777. "patient": patient,
  7778. "number": res.Output.Baseinfo.Certno,
  7779. })
  7780. }
  7781. } else {
  7782. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  7783. return
  7784. }
  7785. } else if miConfig.MdtrtareaAdmvs == "420200" {
  7786. var res ResultTwo
  7787. api := "http://192.168.0.197:9532/" + "hbyb/1101?cert_no=" + "" +
  7788. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  7789. "&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)
  7790. resp, requestErr := http.Get(api)
  7791. if requestErr != nil {
  7792. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7793. return
  7794. }
  7795. body, ioErr := ioutil.ReadAll(resp.Body)
  7796. if ioErr != nil {
  7797. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7798. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7799. return
  7800. }
  7801. var respJSON map[string]interface{}
  7802. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7803. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7804. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7805. return
  7806. }
  7807. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7808. result, _ := json.Marshal(respJSON)
  7809. fmt.Println("log")
  7810. fmt.Println(string(result))
  7811. if err := json.Unmarshal([]byte(result), &res); err != nil {
  7812. utils.ErrorLog("解析失败:%v", err)
  7813. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7814. return
  7815. }
  7816. if res.Infcode == 0 {
  7817. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  7818. if err == gorm.ErrRecordNotFound {
  7819. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  7820. return
  7821. } else if err != nil {
  7822. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  7823. return
  7824. } else {
  7825. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  7826. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  7827. infoStr := string(Iinfos)
  7828. idetinfoStr := string(Idetinfos)
  7829. psn := &models.HisPsn{
  7830. PsnNo: res.Output.Baseinfo.PsnNo,
  7831. PatientId: patient.ID,
  7832. Certno: res.Output.Baseinfo.Certno,
  7833. Gend: res.Output.Baseinfo.Gend,
  7834. Naty: res.Output.Baseinfo.Naty,
  7835. PsnCertType: res.Output.Baseinfo.PsnCertType,
  7836. PsnName: res.Output.Baseinfo.PsnName,
  7837. Idetinfo: idetinfoStr,
  7838. Insuinfo: infoStr,
  7839. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  7840. }
  7841. service.CreateHisPsn(psn)
  7842. var rf []*ResultFive
  7843. json.Unmarshal([]byte(infoStr), &rf)
  7844. var insutypes []*ResultFive
  7845. var insutype string
  7846. var is390 int = 0
  7847. var is310 int = 0
  7848. for _, item := range rf {
  7849. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  7850. insutypes = append(insutypes, item)
  7851. }
  7852. }
  7853. if len(insutypes) == 1 {
  7854. insutype = insutypes[0].Insutype
  7855. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  7856. } else {
  7857. for _, i := range insutypes {
  7858. if i.Insutype == "390" {
  7859. is390 = 1
  7860. }
  7861. if i.Insutype == "310" {
  7862. is310 = 1
  7863. }
  7864. }
  7865. }
  7866. if is390 == 1 {
  7867. insutype = "390"
  7868. }
  7869. if is310 == 1 {
  7870. insutype = "310"
  7871. }
  7872. if len(insutypes) == 0 {
  7873. insutype = "310"
  7874. }
  7875. c.ServeSuccessJSON(map[string]interface{}{
  7876. "patient": patient,
  7877. "number": res.Output.Baseinfo.Certno,
  7878. "insutype": insutype,
  7879. })
  7880. }
  7881. } else {
  7882. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  7883. return
  7884. }
  7885. } else if miConfig.MdtrtareaAdmvs == "420902" {
  7886. var res ResultTwo
  7887. api := miConfig.Url + "hbyb/1101?cert_no=" + "" +
  7888. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  7889. "&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)
  7890. resp, requestErr := http.Get(api)
  7891. if requestErr != nil {
  7892. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7893. return
  7894. }
  7895. body, ioErr := ioutil.ReadAll(resp.Body)
  7896. if ioErr != nil {
  7897. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7898. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7899. return
  7900. }
  7901. var respJSON map[string]interface{}
  7902. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7903. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7904. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7905. return
  7906. }
  7907. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7908. result, _ := json.Marshal(respJSON)
  7909. fmt.Println("log")
  7910. fmt.Println(string(result))
  7911. if err := json.Unmarshal([]byte(result), &res); err != nil {
  7912. utils.ErrorLog("解析失败:%v", err)
  7913. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7914. return
  7915. }
  7916. if res.Infcode == 0 {
  7917. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  7918. if err == gorm.ErrRecordNotFound {
  7919. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  7920. return
  7921. } else if err != nil {
  7922. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  7923. return
  7924. } else {
  7925. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  7926. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  7927. infoStr := string(Iinfos)
  7928. idetinfoStr := string(Idetinfos)
  7929. var rf []*ResultFive
  7930. json.Unmarshal([]byte(infoStr), &rf)
  7931. var insutypes []*ResultFive
  7932. var insutype string
  7933. var is390 int = 0
  7934. var is310 int = 0
  7935. for _, item := range rf {
  7936. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  7937. insutypes = append(insutypes, item)
  7938. }
  7939. }
  7940. if len(insutypes) == 1 {
  7941. insutype = insutypes[0].Insutype
  7942. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  7943. } else {
  7944. for _, i := range insutypes {
  7945. if i.Insutype == "390" {
  7946. is390 = 1
  7947. }
  7948. if i.Insutype == "310" {
  7949. is310 = 1
  7950. }
  7951. }
  7952. }
  7953. if is390 == 1 {
  7954. insutype = "390"
  7955. }
  7956. if is310 == 1 {
  7957. insutype = "310"
  7958. }
  7959. if len(insutypes) == 0 {
  7960. insutype = "390"
  7961. }
  7962. var insuplc_admdvs string
  7963. for _, item := range rf {
  7964. if item.Insutype == insutype {
  7965. insuplc_admdvs = item.InsuplcAdmdvs
  7966. }
  7967. }
  7968. psn := &models.HisPsn{
  7969. PsnNo: res.Output.Baseinfo.PsnNo,
  7970. PatientId: patient.ID,
  7971. Certno: res.Output.Baseinfo.Certno,
  7972. Gend: res.Output.Baseinfo.Gend,
  7973. Naty: res.Output.Baseinfo.Naty,
  7974. PsnCertType: res.Output.Baseinfo.PsnCertType,
  7975. PsnName: res.Output.Baseinfo.PsnName,
  7976. Idetinfo: idetinfoStr,
  7977. Insuinfo: infoStr,
  7978. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  7979. InsuplcAdmdvs: insuplc_admdvs,
  7980. }
  7981. service.CreateHisPsn(psn)
  7982. for _, item := range rf {
  7983. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  7984. insutypes = append(insutypes, item)
  7985. }
  7986. }
  7987. if len(insutypes) == 1 {
  7988. insutype = insutypes[0].Insutype
  7989. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  7990. } else {
  7991. for _, i := range insutypes {
  7992. if i.Insutype == "390" {
  7993. is390 = 1
  7994. }
  7995. if i.Insutype == "310" {
  7996. is310 = 1
  7997. }
  7998. }
  7999. }
  8000. if is390 == 1 {
  8001. insutype = "390"
  8002. }
  8003. if is310 == 1 {
  8004. insutype = "310"
  8005. }
  8006. if len(insutypes) == 0 {
  8007. insutype = "310"
  8008. }
  8009. c.ServeSuccessJSON(map[string]interface{}{
  8010. "patient": patient,
  8011. "number": res.Output.Baseinfo.Certno,
  8012. "insutype": insutype,
  8013. })
  8014. }
  8015. } else {
  8016. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  8017. return
  8018. }
  8019. } else if miConfig.MdtrtareaAdmvs == "421182" {
  8020. var res ResultTwo
  8021. api := "http://192.168.0:9532/" + "hbyb/1101?cert_no=" + "" +
  8022. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  8023. "&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)
  8024. resp, requestErr := http.Get(api)
  8025. if requestErr != nil {
  8026. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8027. return
  8028. }
  8029. body, ioErr := ioutil.ReadAll(resp.Body)
  8030. if ioErr != nil {
  8031. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8032. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8033. return
  8034. }
  8035. var respJSON map[string]interface{}
  8036. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8037. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8038. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8039. return
  8040. }
  8041. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8042. result, _ := json.Marshal(respJSON)
  8043. fmt.Println("log")
  8044. fmt.Println(string(result))
  8045. if err := json.Unmarshal([]byte(result), &res); err != nil {
  8046. utils.ErrorLog("解析失败:%v", err)
  8047. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8048. return
  8049. }
  8050. if res.Infcode == 0 {
  8051. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  8052. if err == gorm.ErrRecordNotFound {
  8053. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  8054. return
  8055. } else if err != nil {
  8056. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  8057. return
  8058. } else {
  8059. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  8060. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  8061. infoStr := string(Iinfos)
  8062. idetinfoStr := string(Idetinfos)
  8063. b, age, _ := getBirthdateAndAge(res.Output.Baseinfo.Certno)
  8064. psn := &models.HisPsn{
  8065. PsnNo: res.Output.Baseinfo.PsnNo,
  8066. PatientId: patient.ID,
  8067. Certno: res.Output.Baseinfo.Certno,
  8068. Brdy: b,
  8069. Age: float64(age),
  8070. Gend: res.Output.Baseinfo.Gend,
  8071. Naty: res.Output.Baseinfo.Naty,
  8072. PsnCertType: res.Output.Baseinfo.PsnCertType,
  8073. PsnName: res.Output.Baseinfo.PsnName,
  8074. Idetinfo: idetinfoStr,
  8075. Insuinfo: infoStr,
  8076. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  8077. }
  8078. service.CreateHisPsn(psn)
  8079. var rf []*ResultFive
  8080. json.Unmarshal([]byte(infoStr), &rf)
  8081. var insutypes []*ResultFive
  8082. var insutype string
  8083. var is390 int = 0
  8084. var is310 int = 0
  8085. for _, item := range rf {
  8086. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  8087. insutypes = append(insutypes, item)
  8088. }
  8089. }
  8090. if len(insutypes) == 1 {
  8091. insutype = insutypes[0].Insutype
  8092. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  8093. } else {
  8094. for _, i := range insutypes {
  8095. if i.Insutype == "390" {
  8096. is390 = 1
  8097. }
  8098. if i.Insutype == "310" {
  8099. is310 = 1
  8100. }
  8101. }
  8102. }
  8103. if is390 == 1 {
  8104. insutype = "390"
  8105. }
  8106. if is310 == 1 {
  8107. insutype = "310"
  8108. }
  8109. if len(insutypes) == 0 {
  8110. insutype = "310"
  8111. }
  8112. c.ServeSuccessJSON(map[string]interface{}{
  8113. "patient": patient,
  8114. "number": res.Output.Baseinfo.Certno,
  8115. "insutype": insutype,
  8116. })
  8117. }
  8118. } else {
  8119. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  8120. return
  8121. }
  8122. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  8123. var api string
  8124. if miConfig.MdtrtareaAdmvs == "320921" {
  8125. 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 +
  8126. "&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
  8127. fmt.Println(api)
  8128. } else {
  8129. 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 +
  8130. "&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)
  8131. }
  8132. resp, requestErr := http.Get(api)
  8133. if requestErr != nil {
  8134. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8135. return
  8136. }
  8137. body, ioErr := ioutil.ReadAll(resp.Body)
  8138. if ioErr != nil {
  8139. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8140. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8141. return
  8142. }
  8143. var respJSON map[string]interface{}
  8144. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8145. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8146. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8147. return
  8148. }
  8149. var status string
  8150. status = respJSON["data"].(map[string]interface{})["status"].(string)
  8151. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  8152. //console.log()
  8153. fmt.Println("type===")
  8154. fmt.Println(card_type)
  8155. var token string
  8156. var res ResultTwo //1101结果
  8157. var res10265 ResultTwo10265 //1101结果
  8158. var card_info string //卡信息
  8159. var busi_card_info string
  8160. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  8161. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  8162. if status == "0" { //读卡成功
  8163. if card_type == "1" {
  8164. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  8165. result, _ := json.Marshal(respJSON)
  8166. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  8167. utils.ErrorLog("解析失败:%v", err)
  8168. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8169. return
  8170. }
  8171. res.ErrMsg = res10265.ErrMsg
  8172. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  8173. res.Infcode = infocode
  8174. res.Output = res10265.Output
  8175. res.InfRefmsgid = res10265.InfRefmsgid
  8176. } else {
  8177. //var card_info string //卡信息
  8178. //var busi_card_info string
  8179. token = respJSON["data"].(map[string]interface{})["token"].(string)
  8180. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  8181. //fmt.Println(card_info)
  8182. //fmt.Println(busi_card_info)
  8183. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  8184. result, _ := json.Marshal(respJSON)
  8185. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  8186. utils.ErrorLog("解析失败:%v", err)
  8187. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8188. return
  8189. }
  8190. res.ErrMsg = res10265.ErrMsg
  8191. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  8192. res.Infcode = infocode
  8193. res.Output = res10265.Output
  8194. res.InfRefmsgid = res10265.InfRefmsgid
  8195. }
  8196. if res.Infcode == 0 {
  8197. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  8198. if err == gorm.ErrRecordNotFound {
  8199. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  8200. return
  8201. } else if err != nil {
  8202. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  8203. return
  8204. } else {
  8205. if card_type == "1" {
  8206. bas := strings.Split(card_info, "|")
  8207. basNumber := bas[2]
  8208. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  8209. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  8210. infoStr := string(Iinfos)
  8211. idetinfoStr := string(Idetinfos)
  8212. b, age, _ := getBirthdateAndAge(res.Output.Baseinfo.Certno)
  8213. psn := &models.HisPsn{
  8214. PsnNo: res.Output.Baseinfo.PsnNo,
  8215. PatientId: patient.ID,
  8216. Certno: res.Output.Baseinfo.Certno,
  8217. Brdy: b,
  8218. Age: float64(age),
  8219. Gend: res.Output.Baseinfo.Gend,
  8220. Naty: res.Output.Baseinfo.Naty,
  8221. PsnCertType: res.Output.Baseinfo.PsnCertType,
  8222. PsnName: res.Output.Baseinfo.PsnName,
  8223. Idetinfo: idetinfoStr,
  8224. Insuinfo: infoStr,
  8225. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  8226. CardInfo: card_info,
  8227. VerifyNumber: busi_card_info,
  8228. }
  8229. service.CreateHisPsn(psn)
  8230. var rf []*ResultFive
  8231. json.Unmarshal([]byte(infoStr), &rf)
  8232. var insutypes []*ResultFive
  8233. var insutype string
  8234. var is390 int = 0
  8235. var is310 int = 0
  8236. for _, item := range rf {
  8237. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  8238. insutypes = append(insutypes, item)
  8239. }
  8240. }
  8241. if len(insutypes) == 1 {
  8242. insutype = insutypes[0].Insutype
  8243. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  8244. } else {
  8245. for _, i := range insutypes {
  8246. if i.Insutype == "390" {
  8247. is390 = 1
  8248. }
  8249. if i.Insutype == "310" {
  8250. is310 = 1
  8251. }
  8252. }
  8253. }
  8254. if is390 == 1 {
  8255. insutype = "390"
  8256. }
  8257. if is310 == 1 {
  8258. insutype = "310"
  8259. }
  8260. if len(insutypes) == 0 {
  8261. insutype = "310"
  8262. }
  8263. c.ServeSuccessJSON(map[string]interface{}{
  8264. "patient": patient,
  8265. "number": basNumber,
  8266. "insutype": insutype,
  8267. })
  8268. } else {
  8269. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  8270. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  8271. infoStr := string(Iinfos)
  8272. idetinfoStr := string(Idetinfos)
  8273. psn := &models.HisPsn{
  8274. PsnNo: res.Output.Baseinfo.PsnNo,
  8275. PatientId: patient.ID,
  8276. Certno: res.Output.Baseinfo.Certno,
  8277. Gend: res.Output.Baseinfo.Gend,
  8278. Naty: res.Output.Baseinfo.Naty,
  8279. PsnCertType: res.Output.Baseinfo.PsnCertType,
  8280. PsnName: res.Output.Baseinfo.PsnName,
  8281. Idetinfo: idetinfoStr,
  8282. Insuinfo: infoStr,
  8283. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  8284. CardInfo: card_info,
  8285. VerifyNumber: token,
  8286. }
  8287. service.CreateHisPsn(psn)
  8288. c.ServeSuccessJSON(map[string]interface{}{
  8289. "patient": patient,
  8290. "number": token,
  8291. })
  8292. }
  8293. }
  8294. } else {
  8295. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  8296. return
  8297. }
  8298. } else { //读卡失败
  8299. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  8300. return
  8301. }
  8302. } else if miConfig.MdtrtareaAdmvs == "350500" {
  8303. cardnum, cardCode, id_card_no, name, errmsg := c.GetFjBasBaseInfo()
  8304. cardnum = DeleteExtraSpaceTwo(cardnum)
  8305. cardCode = DeleteExtraSpaceTwo(cardCode)
  8306. id_card_no = DeleteExtraSpaceTwo(id_card_no)
  8307. name = DeleteExtraSpaceTwo(name)
  8308. errmsg = DeleteExtraSpaceTwo(errmsg)
  8309. cardnum = Remove0000(cardnum)
  8310. cardCode = Remove0000(cardCode)
  8311. id_card_no = Remove0000(id_card_no)
  8312. name = Remove0000(name)
  8313. errmsg = Remove0000(errmsg)
  8314. patient, _ := service.GetPatientByIDCard(id_card_no, miConfig.UserOrgId)
  8315. basStr := cardnum + "|" + cardCode + "|" + id_card_no + "|" + name
  8316. //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)
  8317. //fmt.Println(result2)
  8318. //fmt.Println(requestLog2)
  8319. //fmt.Println(errMsgLog2)
  8320. 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)
  8321. saveLog(result, requestLog, "1101", "获取人员信息")
  8322. fmt.Println(errMsgLog)
  8323. if len(errMsgLog) > 0 {
  8324. } else {
  8325. var dat map[string]interface{}
  8326. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8327. fmt.Println(dat)
  8328. } else {
  8329. fmt.Println(err)
  8330. }
  8331. userJSONBytes, _ := json.Marshal(dat)
  8332. var res ResultTwo
  8333. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8334. utils.ErrorLog("解析失败:%v", err)
  8335. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8336. return
  8337. }
  8338. res.ErrMsg = errMsgLog
  8339. if res.Infcode == 0 {
  8340. patient, err := service.GetPatientByNumber(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  8341. if err == gorm.ErrRecordNotFound {
  8342. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  8343. return
  8344. } else if err != nil {
  8345. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  8346. return
  8347. } else {
  8348. fmt.Println(res)
  8349. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  8350. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  8351. infoStr := string(Iinfos)
  8352. idetinfoStr := string(Idetinfos)
  8353. var rf []*ResultFive
  8354. json.Unmarshal([]byte(infoStr), &rf)
  8355. var insutypes []*ResultFive
  8356. var insutype string
  8357. var is390 int = 0
  8358. var is310 int = 0
  8359. for _, item := range rf {
  8360. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  8361. insutypes = append(insutypes, item)
  8362. }
  8363. }
  8364. if len(insutypes) == 1 {
  8365. insutype = insutypes[0].Insutype
  8366. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  8367. } else {
  8368. for _, i := range insutypes {
  8369. if i.Insutype == "390" {
  8370. is390 = 1
  8371. }
  8372. if i.Insutype == "310" {
  8373. is310 = 1
  8374. }
  8375. }
  8376. }
  8377. if is390 == 1 {
  8378. insutype = "390"
  8379. }
  8380. if is310 == 1 {
  8381. insutype = "310"
  8382. }
  8383. if len(insutypes) == 0 {
  8384. insutype = "390"
  8385. }
  8386. var insuplc_admdvs string
  8387. for _, item := range rf {
  8388. if item.Insutype == insutype {
  8389. insuplc_admdvs = item.InsuplcAdmdvs
  8390. }
  8391. }
  8392. psn := &models.HisPsn{
  8393. PsnNo: res.Output.Baseinfo.PsnNo,
  8394. PatientId: patient.ID,
  8395. Certno: res.Output.Baseinfo.Certno,
  8396. Gend: res.Output.Baseinfo.Gend,
  8397. Naty: res.Output.Baseinfo.Naty,
  8398. PsnCertType: res.Output.Baseinfo.PsnCertType,
  8399. PsnName: res.Output.Baseinfo.PsnName,
  8400. Idetinfo: idetinfoStr,
  8401. Insuinfo: infoStr,
  8402. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  8403. CardInfo: basStr,
  8404. VerifyNumber: "",
  8405. InsuplcAdmdvs: insuplc_admdvs,
  8406. }
  8407. service.CreateHisPsn(psn)
  8408. c.ServeSuccessJSON(map[string]interface{}{
  8409. "patient": patient,
  8410. "number": cardnum,
  8411. "insutype": insutype,
  8412. })
  8413. }
  8414. } else {
  8415. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  8416. return
  8417. }
  8418. }
  8419. } else if miConfig.MdtrtareaAdmvs == "360302" {
  8420. fmt.Println(initFlag)
  8421. fmt.Println("initFlag")
  8422. if initFlag == 0 {
  8423. c.TestGetJiangXiBasBaseInit()
  8424. }
  8425. basStr := c.GetBasBaseInfo()
  8426. if len(basStr) == 0 {
  8427. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  8428. return
  8429. }
  8430. fmt.Println(basStr)
  8431. bas := strings.Split(basStr, "|")
  8432. basNumber := bas[1]
  8433. fmt.Println(basNumber)
  8434. card_sn := bas[3]
  8435. fmt.Println(card_sn)
  8436. 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, "")
  8437. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  8438. var dat map[string]interface{}
  8439. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8440. fmt.Println(dat)
  8441. } else {
  8442. fmt.Println(err)
  8443. }
  8444. userJSONBytes, _ := json.Marshal(dat)
  8445. var res ResultTwo
  8446. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8447. utils.ErrorLog("解析失败:%v", err)
  8448. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8449. return
  8450. }
  8451. if res.Infcode == 0 {
  8452. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  8453. if err == gorm.ErrRecordNotFound {
  8454. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  8455. return
  8456. } else if err != nil {
  8457. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  8458. return
  8459. } else {
  8460. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  8461. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  8462. infoStr := string(Iinfos)
  8463. idetinfoStr := string(Idetinfos)
  8464. var rf []*ResultFive
  8465. json.Unmarshal([]byte(infoStr), &rf)
  8466. var insutypes []*ResultFive
  8467. var insutype string
  8468. var is390 int = 0
  8469. var is310 int = 0
  8470. var insuplc_admdvs string
  8471. for _, item := range rf {
  8472. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  8473. insutypes = append(insutypes, item)
  8474. }
  8475. }
  8476. if len(insutypes) == 1 {
  8477. insutype = insutypes[0].Insutype
  8478. insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  8479. } else {
  8480. for _, i := range insutypes {
  8481. if i.Insutype == "390" {
  8482. is390 = 1
  8483. }
  8484. if i.Insutype == "310" {
  8485. is310 = 1
  8486. }
  8487. }
  8488. }
  8489. if is390 == 1 {
  8490. insutype = "390"
  8491. }
  8492. if is310 == 1 {
  8493. insutype = "310"
  8494. }
  8495. if len(insutypes) == 0 {
  8496. insutype = "310"
  8497. }
  8498. for _, item := range rf {
  8499. if item.Insutype == insutype && item.PsnInsuStas == "1" {
  8500. insuplc_admdvs = item.InsuplcAdmdvs
  8501. }
  8502. }
  8503. psn := &models.HisPsn{
  8504. PsnNo: res.Output.Baseinfo.PsnNo,
  8505. PatientId: patient.ID,
  8506. Certno: res.Output.Baseinfo.Certno,
  8507. Gend: res.Output.Baseinfo.Gend,
  8508. Naty: res.Output.Baseinfo.Naty,
  8509. PsnCertType: res.Output.Baseinfo.PsnCertType,
  8510. PsnName: res.Output.Baseinfo.PsnName,
  8511. Idetinfo: idetinfoStr,
  8512. Insuinfo: infoStr,
  8513. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  8514. CardInfo: basStr,
  8515. InsuplcAdmdvs: insuplc_admdvs,
  8516. VerifyNumber: "",
  8517. }
  8518. service.CreateHisPsn(psn)
  8519. c.ServeSuccessJSON(map[string]interface{}{
  8520. "patient": patient,
  8521. "number": basNumber,
  8522. "insutype": insutype,
  8523. })
  8524. }
  8525. } else {
  8526. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  8527. return
  8528. }
  8529. } else if miConfig.MdtrtareaAdmvs == "430800" {
  8530. fmt.Println(initFlag)
  8531. fmt.Println("initFlag")
  8532. if initFlag == 0 {
  8533. c.TestGetHnBasBaseInit()
  8534. }
  8535. basStr := c.GetBasBaseInfo()
  8536. if len(basStr) == 0 {
  8537. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  8538. return
  8539. }
  8540. fmt.Println(basStr)
  8541. bas := strings.Split(basStr, "|")
  8542. basNumber := bas[1]
  8543. fmt.Println(basNumber)
  8544. card_sn := bas[3]
  8545. card_no := bas[2]
  8546. fmt.Println(card_sn)
  8547. name := bas[4]
  8548. name = ConvertToString(name, "gbk", "utf-8")
  8549. 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)
  8550. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  8551. var dat map[string]interface{}
  8552. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8553. fmt.Println(dat)
  8554. } else {
  8555. fmt.Println(err)
  8556. }
  8557. userJSONBytes, _ := json.Marshal(dat)
  8558. var res ResultTwo
  8559. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8560. utils.ErrorLog("解析失败:%v", err)
  8561. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8562. return
  8563. }
  8564. if res.Infcode == 0 {
  8565. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  8566. if err == gorm.ErrRecordNotFound {
  8567. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  8568. return
  8569. } else if err != nil {
  8570. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  8571. return
  8572. } else {
  8573. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  8574. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  8575. infoStr := string(Iinfos)
  8576. idetinfoStr := string(Idetinfos)
  8577. psn := &models.HisPsn{
  8578. PsnNo: res.Output.Baseinfo.PsnNo,
  8579. PatientId: patient.ID,
  8580. Certno: res.Output.Baseinfo.Certno,
  8581. Gend: res.Output.Baseinfo.Gend,
  8582. Naty: res.Output.Baseinfo.Naty,
  8583. PsnCertType: res.Output.Baseinfo.PsnCertType,
  8584. PsnName: res.Output.Baseinfo.PsnName,
  8585. Idetinfo: idetinfoStr,
  8586. Insuinfo: infoStr,
  8587. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  8588. CardInfo: basStr,
  8589. VerifyNumber: "",
  8590. }
  8591. service.CreateHisPsn(psn)
  8592. var rf []*ResultFive
  8593. json.Unmarshal([]byte(infoStr), &rf)
  8594. var insutypes []*ResultFive
  8595. var insutype string
  8596. var is390 int = 0
  8597. var is310 int = 0
  8598. for _, item := range rf {
  8599. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  8600. insutypes = append(insutypes, item)
  8601. }
  8602. }
  8603. if len(insutypes) == 1 {
  8604. insutype = insutypes[0].Insutype
  8605. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  8606. } else {
  8607. for _, i := range insutypes {
  8608. if i.Insutype == "390" {
  8609. is390 = 1
  8610. }
  8611. if i.Insutype == "310" {
  8612. is310 = 1
  8613. }
  8614. }
  8615. }
  8616. if is390 == 1 {
  8617. insutype = "390"
  8618. }
  8619. if is310 == 1 {
  8620. insutype = "310"
  8621. }
  8622. if len(insutypes) == 0 {
  8623. insutype = "310"
  8624. }
  8625. c.ServeSuccessJSON(map[string]interface{}{
  8626. "patient": patient,
  8627. "number": basNumber,
  8628. "insutype": insutype,
  8629. })
  8630. }
  8631. } else {
  8632. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  8633. return
  8634. }
  8635. } else if miConfig.MdtrtareaAdmvs == "150499" {
  8636. var api string
  8637. 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 +
  8638. "&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
  8639. fmt.Println(api)
  8640. resp, requestErr := http.Get(api)
  8641. if requestErr != nil {
  8642. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8643. return
  8644. }
  8645. body, ioErr := ioutil.ReadAll(resp.Body)
  8646. if ioErr != nil {
  8647. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8648. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8649. return
  8650. }
  8651. var respJSON map[string]interface{}
  8652. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8653. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8654. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8655. return
  8656. }
  8657. var res ResultTwo //1101结果
  8658. var res10265 ResultTwo10265 //1101结果
  8659. var card_info string //卡信息
  8660. token := respJSON["data"].(map[string]interface{})["token"].(string)
  8661. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  8662. result, _ := json.Marshal(respJSON)
  8663. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  8664. utils.ErrorLog("解析失败:%v", err)
  8665. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8666. return
  8667. }
  8668. res.ErrMsg = res10265.ErrMsg
  8669. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  8670. res.Infcode = infocode
  8671. res.Output = res10265.Output
  8672. res.InfRefmsgid = res10265.InfRefmsgid
  8673. if res.Infcode == 0 {
  8674. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  8675. if err == gorm.ErrRecordNotFound {
  8676. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  8677. return
  8678. } else if err != nil {
  8679. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  8680. return
  8681. } else {
  8682. bas := strings.Split(card_info, "|")
  8683. basNumber := bas[2]
  8684. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  8685. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  8686. infoStr := string(Iinfos)
  8687. idetinfoStr := string(Idetinfos)
  8688. psn := &models.HisPsn{
  8689. PsnNo: res.Output.Baseinfo.PsnNo,
  8690. PatientId: patient.ID,
  8691. Certno: res.Output.Baseinfo.Certno,
  8692. Gend: res.Output.Baseinfo.Gend,
  8693. Naty: res.Output.Baseinfo.Naty,
  8694. PsnCertType: res.Output.Baseinfo.PsnCertType,
  8695. PsnName: res.Output.Baseinfo.PsnName,
  8696. Idetinfo: idetinfoStr,
  8697. Insuinfo: infoStr,
  8698. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  8699. CardInfo: card_info,
  8700. VerifyNumber: token,
  8701. }
  8702. service.CreateHisPsn(psn)
  8703. var rf []*ResultFive
  8704. json.Unmarshal([]byte(infoStr), &rf)
  8705. var insutypes []*ResultFive
  8706. var insutype string
  8707. var is390 int = 0
  8708. var is310 int = 0
  8709. for _, item := range rf {
  8710. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  8711. insutypes = append(insutypes, item)
  8712. }
  8713. }
  8714. if len(insutypes) == 1 {
  8715. insutype = insutypes[0].Insutype
  8716. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  8717. } else {
  8718. for _, i := range insutypes {
  8719. if i.Insutype == "390" {
  8720. is390 = 1
  8721. }
  8722. if i.Insutype == "310" {
  8723. is310 = 1
  8724. }
  8725. }
  8726. }
  8727. if is390 == 1 {
  8728. insutype = "390"
  8729. }
  8730. if is310 == 1 {
  8731. insutype = "310"
  8732. }
  8733. if len(insutypes) == 0 {
  8734. insutype = "310"
  8735. }
  8736. c.ServeSuccessJSON(map[string]interface{}{
  8737. "patient": patient,
  8738. "number": basNumber,
  8739. "insutype": insutype,
  8740. })
  8741. }
  8742. } else {
  8743. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  8744. return
  8745. }
  8746. } else if miConfig.MdtrtareaAdmvs == "450721" {
  8747. res := c.GetoleInfo()
  8748. if res.Infcode == 0 {
  8749. var result string
  8750. if res.Output.MdtrtCertType == "01" {
  8751. 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)
  8752. } else if res.Output.MdtrtCertType == "02" {
  8753. 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)
  8754. } else if res.Output.MdtrtCertType == "03" {
  8755. 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)
  8756. }
  8757. var dat map[string]interface{}
  8758. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8759. fmt.Println(dat)
  8760. } else {
  8761. fmt.Println(err)
  8762. }
  8763. userJSONBytes, _ := json.Marshal(dat)
  8764. var res2 ResultTwo
  8765. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  8766. utils.ErrorLog("解析失败:%v", err)
  8767. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8768. return
  8769. }
  8770. if res2.Infcode == 0 {
  8771. patient, err := service.GetPatientByNumber(res.Output.CertNo, c.GetAdminUserInfo().CurrentOrgId)
  8772. if err == gorm.ErrRecordNotFound {
  8773. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  8774. return
  8775. } else if err != nil {
  8776. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  8777. return
  8778. } else {
  8779. Iinfos, _ := json.Marshal(res2.Output.Iinfo)
  8780. Idetinfos, _ := json.Marshal(res2.Output.Idetinfo)
  8781. infoStr := string(Iinfos)
  8782. idetinfoStr := string(Idetinfos)
  8783. var rf []*ResultFive
  8784. json.Unmarshal([]byte(infoStr), &rf)
  8785. var insutypes []*ResultFive
  8786. var insutype string
  8787. var is390 int = 0
  8788. var is310 int = 0
  8789. //var insuplc_admdvs string
  8790. for _, item := range rf {
  8791. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  8792. insutypes = append(insutypes, item)
  8793. }
  8794. }
  8795. if len(insutypes) == 1 {
  8796. insutype = insutypes[0].Insutype
  8797. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  8798. } else {
  8799. for _, i := range insutypes {
  8800. if i.Insutype == "390" {
  8801. is390 = 1
  8802. }
  8803. if i.Insutype == "310" {
  8804. is310 = 1
  8805. }
  8806. }
  8807. }
  8808. if is390 == 1 {
  8809. insutype = "390"
  8810. }
  8811. if is310 == 1 {
  8812. insutype = "310"
  8813. }
  8814. if len(insutypes) == 0 {
  8815. insutype = "310"
  8816. }
  8817. psn := &models.HisPsn{
  8818. PsnNo: res2.Output.Baseinfo.PsnNo,
  8819. PatientId: patient.ID,
  8820. Certno: res2.Output.Baseinfo.Certno,
  8821. Gend: res2.Output.Baseinfo.Gend,
  8822. Naty: res2.Output.Baseinfo.Naty,
  8823. PsnCertType: res2.Output.Baseinfo.PsnCertType,
  8824. PsnName: res2.Output.Baseinfo.PsnName,
  8825. Idetinfo: idetinfoStr,
  8826. Insuinfo: infoStr,
  8827. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  8828. CardInfo: res.Output.CertNo + "|" + res.Output.CardSN,
  8829. VerifyNumber: res.Output.EcToken,
  8830. InsuplcAdmdvs: res.Output.InsuplcAdmdvs,
  8831. }
  8832. if res.Output.MdtrtCertType == "01" {
  8833. psn.VerifyNumber = res.Output.EcToken
  8834. //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)
  8835. } else if res.Output.MdtrtCertType == "02" {
  8836. psn.VerifyNumber = res.Output.MdtrtCertNo
  8837. //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)
  8838. } else if res.Output.MdtrtCertType == "03" {
  8839. psn.VerifyNumber = res.Output.MdtrtCertNo
  8840. //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)
  8841. }
  8842. var balc float64
  8843. for _, item := range rf {
  8844. if item.Insutype == insutype {
  8845. balc = item.Balc
  8846. }
  8847. }
  8848. service.CreateHisPsn(psn)
  8849. c.ServeSuccessJSON(map[string]interface{}{
  8850. "patient": patient,
  8851. "number": res.Output.CardNo,
  8852. "insutype": insutype,
  8853. "blac": balc,
  8854. "desc": idetinfoStr,
  8855. })
  8856. }
  8857. } else {
  8858. c.ServeSuccessJSON(map[string]interface{}{
  8859. "failed_code": -10,
  8860. "msg": res2.ErrMsg,
  8861. })
  8862. }
  8863. } else {
  8864. c.ServeSuccessJSON(map[string]interface{}{
  8865. "failed_code": -10,
  8866. "msg": res.ErrMsg,
  8867. })
  8868. }
  8869. } else if miConfig.MdtrtareaAdmvs == "341203" {
  8870. var api string
  8871. api = miConfig.SecretKey + "ahyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  8872. "&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
  8873. fmt.Println(api)
  8874. resp, requestErr := http.Get(api)
  8875. if requestErr != nil {
  8876. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8877. return
  8878. }
  8879. body, ioErr := ioutil.ReadAll(resp.Body)
  8880. if ioErr != nil {
  8881. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8882. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8883. return
  8884. }
  8885. var respJSON map[string]interface{}
  8886. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8887. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8888. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8889. return
  8890. }
  8891. var status string
  8892. status = respJSON["data"].(map[string]interface{})["status"].(string)
  8893. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  8894. //console.log()
  8895. fmt.Println("type===")
  8896. fmt.Println(card_type)
  8897. var token string
  8898. var res ResultTwo //1101结果
  8899. //var res10265 ResultTwoesultTwo10265 //1101结果
  8900. var card_info string //卡信息
  8901. var busi_card_info string
  8902. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  8903. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  8904. if status == "0" { //读卡成功
  8905. if card_type == "1" {
  8906. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  8907. result, _ := json.Marshal(respJSON)
  8908. if err := json.Unmarshal([]byte(result), &res); err != nil {
  8909. utils.ErrorLog("解析失败:%v", err)
  8910. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8911. return
  8912. }
  8913. } else {
  8914. token = respJSON["data"].(map[string]interface{})["token"].(string)
  8915. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  8916. result, _ := json.Marshal(respJSON)
  8917. if err := json.Unmarshal([]byte(result), &res); err != nil {
  8918. utils.ErrorLog("解析失败:%v", err)
  8919. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8920. return
  8921. }
  8922. }
  8923. if res.Infcode == 0 {
  8924. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  8925. if err == gorm.ErrRecordNotFound {
  8926. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  8927. return
  8928. } else if err != nil {
  8929. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  8930. return
  8931. } else {
  8932. if card_type == "1" {
  8933. bas := strings.Split(card_info, "|")
  8934. basNumber := bas[2]
  8935. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  8936. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  8937. infoStr := string(Iinfos)
  8938. idetinfoStr := string(Idetinfos)
  8939. psn := &models.HisPsn{
  8940. PsnNo: res.Output.Baseinfo.PsnNo,
  8941. PatientId: patient.ID,
  8942. Certno: res.Output.Baseinfo.Certno,
  8943. Gend: res.Output.Baseinfo.Gend,
  8944. Naty: res.Output.Baseinfo.Naty,
  8945. PsnCertType: res.Output.Baseinfo.PsnCertType,
  8946. PsnName: res.Output.Baseinfo.PsnName,
  8947. Idetinfo: idetinfoStr,
  8948. Insuinfo: infoStr,
  8949. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  8950. CardInfo: card_info,
  8951. VerifyNumber: busi_card_info,
  8952. }
  8953. service.CreateHisPsn(psn)
  8954. var rf []*ResultFive
  8955. json.Unmarshal([]byte(infoStr), &rf)
  8956. var insutypes []*ResultFive
  8957. var insutype string
  8958. var is390 int = 0
  8959. var is310 int = 0
  8960. for _, item := range rf {
  8961. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  8962. insutypes = append(insutypes, item)
  8963. }
  8964. }
  8965. if len(insutypes) == 1 {
  8966. insutype = insutypes[0].Insutype
  8967. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  8968. } else {
  8969. for _, i := range insutypes {
  8970. if i.Insutype == "390" {
  8971. is390 = 1
  8972. }
  8973. if i.Insutype == "310" {
  8974. is310 = 1
  8975. }
  8976. }
  8977. }
  8978. if is390 == 1 {
  8979. insutype = "390"
  8980. }
  8981. if is310 == 1 {
  8982. insutype = "310"
  8983. }
  8984. if len(insutypes) == 0 {
  8985. insutype = "310"
  8986. }
  8987. c.ServeSuccessJSON(map[string]interface{}{
  8988. "patient": patient,
  8989. "number": basNumber,
  8990. "insutype": insutype,
  8991. })
  8992. } else {
  8993. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  8994. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  8995. infoStr := string(Iinfos)
  8996. idetinfoStr := string(Idetinfos)
  8997. psn := &models.HisPsn{
  8998. PsnNo: res.Output.Baseinfo.PsnNo,
  8999. PatientId: patient.ID,
  9000. Certno: res.Output.Baseinfo.Certno,
  9001. Gend: res.Output.Baseinfo.Gend,
  9002. Naty: res.Output.Baseinfo.Naty,
  9003. PsnCertType: res.Output.Baseinfo.PsnCertType,
  9004. PsnName: res.Output.Baseinfo.PsnName,
  9005. Idetinfo: idetinfoStr,
  9006. Insuinfo: infoStr,
  9007. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9008. CardInfo: card_info,
  9009. VerifyNumber: token,
  9010. }
  9011. service.CreateHisPsn(psn)
  9012. c.ServeSuccessJSON(map[string]interface{}{
  9013. "patient": patient,
  9014. "number": token,
  9015. })
  9016. }
  9017. }
  9018. } else {
  9019. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9020. return
  9021. }
  9022. } else { //读卡失败
  9023. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9024. return
  9025. }
  9026. } else {
  9027. if initFlag == 0 {
  9028. c.TestGetBasBaseInit()
  9029. }
  9030. basStr := c.GetBasBaseInfo()
  9031. if len(basStr) == 0 {
  9032. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  9033. return
  9034. }
  9035. fmt.Println(basStr)
  9036. bas := strings.Split(basStr, "|")
  9037. basNumber := bas[1]
  9038. fmt.Println(basNumber)
  9039. card_sn := bas[3]
  9040. fmt.Println(card_sn)
  9041. cardNumber := bas[2]
  9042. fmt.Println(cardNumber)
  9043. patient, _ := service.GetPatientByIDCard(basNumber, miConfig.UserOrgId)
  9044. var result string
  9045. if bas[0][:2] == "44" {
  9046. 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)
  9047. } else {
  9048. 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)
  9049. }
  9050. var dat map[string]interface{}
  9051. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9052. fmt.Println(dat)
  9053. } else {
  9054. fmt.Println(err)
  9055. }
  9056. userJSONBytes, _ := json.Marshal(dat)
  9057. var res ResultTwo
  9058. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9059. utils.ErrorLog("解析失败:%v", err)
  9060. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9061. return
  9062. }
  9063. if res.Infcode == 0 {
  9064. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  9065. if err == gorm.ErrRecordNotFound {
  9066. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  9067. return
  9068. } else if err != nil {
  9069. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  9070. return
  9071. } else {
  9072. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9073. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9074. infoStr := string(Iinfos)
  9075. idetinfoStr := string(Idetinfos)
  9076. var rf []*ResultFive
  9077. json.Unmarshal([]byte(infoStr), &rf)
  9078. var insutypes []*ResultFive
  9079. var insutype string
  9080. var is390 int = 0
  9081. var is310 int = 0
  9082. var insuplc_admdvs string
  9083. for _, item := range rf {
  9084. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  9085. insutypes = append(insutypes, item)
  9086. }
  9087. }
  9088. if len(insutypes) == 1 {
  9089. insutype = insutypes[0].Insutype
  9090. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  9091. } else {
  9092. for _, i := range insutypes {
  9093. if i.Insutype == "390" {
  9094. is390 = 1
  9095. }
  9096. if i.Insutype == "310" {
  9097. is310 = 1
  9098. }
  9099. }
  9100. }
  9101. if is390 == 1 {
  9102. insutype = "390"
  9103. }
  9104. if is310 == 1 {
  9105. insutype = "310"
  9106. }
  9107. if len(insutypes) == 0 {
  9108. insutype = "310"
  9109. }
  9110. for _, item := range rf {
  9111. if item.Insutype == insutype {
  9112. insuplc_admdvs = item.InsuplcAdmdvs
  9113. }
  9114. }
  9115. psn := &models.HisPsn{
  9116. PsnNo: res.Output.Baseinfo.PsnNo,
  9117. PatientId: patient.ID,
  9118. Certno: res.Output.Baseinfo.Certno,
  9119. Gend: res.Output.Baseinfo.Gend,
  9120. Naty: res.Output.Baseinfo.Naty,
  9121. PsnCertType: res.Output.Baseinfo.PsnCertType,
  9122. PsnName: res.Output.Baseinfo.PsnName,
  9123. Idetinfo: idetinfoStr,
  9124. Insuinfo: infoStr,
  9125. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9126. CardInfo: basStr,
  9127. VerifyNumber: "",
  9128. InsuplcAdmdvs: insuplc_admdvs,
  9129. }
  9130. service.CreateHisPsn(psn)
  9131. c.ServeSuccessJSON(map[string]interface{}{
  9132. "patient": patient,
  9133. "number": basNumber,
  9134. })
  9135. }
  9136. } else {
  9137. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9138. return
  9139. }
  9140. break
  9141. }
  9142. case 2:
  9143. if miConfig.MdtrtareaAdmvs == "430800" {
  9144. if initFlag == 0 {
  9145. c.TestGetHnBasBaseInit()
  9146. }
  9147. SFZStr := c.GetSFZBaseInfo()
  9148. if len(SFZStr) == 0 {
  9149. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  9150. return
  9151. }
  9152. fmt.Println(SFZStr)
  9153. id_card_str := strings.Split(SFZStr, "^")
  9154. card_no := id_card_str[0]
  9155. patient, _ := service.GetPatientByNumber(card_no, c.GetAdminUserInfo().CurrentOrgId)
  9156. //name := id_card_str[1]
  9157. //name = ConvertToString(name, "gbk", "utf-8")
  9158. 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)
  9159. var dat map[string]interface{}
  9160. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9161. fmt.Println(dat)
  9162. } else {
  9163. fmt.Println(err)
  9164. }
  9165. userJSONBytes, _ := json.Marshal(dat)
  9166. var res ResultTwo
  9167. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9168. utils.ErrorLog("解析失败:%v", err)
  9169. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9170. return
  9171. }
  9172. if res.Infcode == 0 {
  9173. patient, err := service.GetPatientByNumber(card_no, c.GetAdminUserInfo().CurrentOrgId)
  9174. if err == gorm.ErrRecordNotFound {
  9175. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  9176. return
  9177. } else if err != nil {
  9178. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  9179. return
  9180. } else {
  9181. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9182. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9183. infoStr := string(Iinfos)
  9184. idetinfoStr := string(Idetinfos)
  9185. var rf []*ResultFive
  9186. json.Unmarshal([]byte(infoStr), &rf)
  9187. var insutypes []*ResultFive
  9188. var insutype string
  9189. var is390 int = 0
  9190. var is310 int = 0
  9191. for _, item := range rf {
  9192. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  9193. insutypes = append(insutypes, item)
  9194. }
  9195. }
  9196. if len(insutypes) == 1 {
  9197. insutype = insutypes[0].Insutype
  9198. } else {
  9199. for _, i := range insutypes {
  9200. if i.Insutype == "390" {
  9201. is390 = 1
  9202. }
  9203. if i.Insutype == "310" {
  9204. is310 = 1
  9205. }
  9206. }
  9207. }
  9208. if is390 == 1 {
  9209. insutype = "390"
  9210. }
  9211. if is310 == 1 {
  9212. insutype = "310"
  9213. }
  9214. if len(insutypes) == 0 {
  9215. insutype = "310"
  9216. }
  9217. var InsuplcAdmdvs string
  9218. for _, item := range rf {
  9219. if item.Insutype == insutype {
  9220. InsuplcAdmdvs = item.InsuplcAdmdvs
  9221. }
  9222. }
  9223. psn := &models.HisPsn{
  9224. PsnNo: res.Output.Baseinfo.PsnNo,
  9225. PatientId: patient.ID,
  9226. Certno: res.Output.Baseinfo.Certno,
  9227. Gend: res.Output.Baseinfo.Gend,
  9228. Naty: res.Output.Baseinfo.Naty,
  9229. PsnCertType: res.Output.Baseinfo.PsnCertType,
  9230. PsnName: res.Output.Baseinfo.PsnName,
  9231. Idetinfo: idetinfoStr,
  9232. Insuinfo: infoStr,
  9233. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9234. CardInfo: SFZStr,
  9235. VerifyNumber: "",
  9236. InsuplcAdmdvs: InsuplcAdmdvs,
  9237. }
  9238. service.CreateHisPsn(psn)
  9239. c.ServeSuccessJSON(map[string]interface{}{
  9240. "patient": patient,
  9241. "number": card_no,
  9242. "insutype": insutype,
  9243. })
  9244. }
  9245. } else {
  9246. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9247. return
  9248. }
  9249. } else if miConfig.MdtrtareaAdmvs == "420200" {
  9250. var res ResultTwo
  9251. api := "http://192.168.0.197:9532/" + "hbyb/1101?cert_no=" + "" +
  9252. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  9253. "&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)
  9254. resp, requestErr := http.Get(api)
  9255. if requestErr != nil {
  9256. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9257. return
  9258. }
  9259. body, ioErr := ioutil.ReadAll(resp.Body)
  9260. if ioErr != nil {
  9261. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9262. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9263. return
  9264. }
  9265. var respJSON map[string]interface{}
  9266. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9267. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9268. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9269. return
  9270. }
  9271. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9272. result, _ := json.Marshal(respJSON)
  9273. fmt.Println("log")
  9274. fmt.Println(string(result))
  9275. if err := json.Unmarshal([]byte(result), &res); err != nil {
  9276. utils.ErrorLog("解析失败:%v", err)
  9277. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9278. return
  9279. }
  9280. if res.Infcode == 0 {
  9281. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  9282. if err == gorm.ErrRecordNotFound {
  9283. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  9284. return
  9285. } else if err != nil {
  9286. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  9287. return
  9288. } else {
  9289. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9290. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9291. infoStr := string(Iinfos)
  9292. idetinfoStr := string(Idetinfos)
  9293. psn := &models.HisPsn{
  9294. PsnNo: res.Output.Baseinfo.PsnNo,
  9295. PatientId: patient.ID,
  9296. Certno: res.Output.Baseinfo.Certno,
  9297. Gend: res.Output.Baseinfo.Gend,
  9298. Naty: res.Output.Baseinfo.Naty,
  9299. PsnCertType: res.Output.Baseinfo.PsnCertType,
  9300. PsnName: res.Output.Baseinfo.PsnName,
  9301. Idetinfo: idetinfoStr,
  9302. Insuinfo: infoStr,
  9303. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9304. }
  9305. service.CreateHisPsn(psn)
  9306. c.ServeSuccessJSON(map[string]interface{}{
  9307. "patient": patient,
  9308. "number": res.Output.Baseinfo.Certno,
  9309. })
  9310. }
  9311. } else {
  9312. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9313. return
  9314. }
  9315. } else if miConfig.MdtrtareaAdmvs == "421182" {
  9316. var res ResultTwo
  9317. api := miConfig.Url + "hbyb/1101?cert_no=" + "" +
  9318. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  9319. "&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)
  9320. resp, requestErr := http.Get(api)
  9321. if requestErr != nil {
  9322. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9323. return
  9324. }
  9325. body, ioErr := ioutil.ReadAll(resp.Body)
  9326. if ioErr != nil {
  9327. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9328. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9329. return
  9330. }
  9331. var respJSON map[string]interface{}
  9332. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9333. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9334. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9335. return
  9336. }
  9337. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9338. result, _ := json.Marshal(respJSON)
  9339. fmt.Println("log")
  9340. fmt.Println(string(result))
  9341. if err := json.Unmarshal([]byte(result), &res); err != nil {
  9342. utils.ErrorLog("解析失败:%v", err)
  9343. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9344. return
  9345. }
  9346. if res.Infcode == 0 {
  9347. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  9348. if err == gorm.ErrRecordNotFound {
  9349. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  9350. return
  9351. } else if err != nil {
  9352. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  9353. return
  9354. } else {
  9355. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9356. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9357. infoStr := string(Iinfos)
  9358. idetinfoStr := string(Idetinfos)
  9359. psn := &models.HisPsn{
  9360. PsnNo: res.Output.Baseinfo.PsnNo,
  9361. PatientId: patient.ID,
  9362. Certno: res.Output.Baseinfo.Certno,
  9363. Gend: res.Output.Baseinfo.Gend,
  9364. Naty: res.Output.Baseinfo.Naty,
  9365. PsnCertType: res.Output.Baseinfo.PsnCertType,
  9366. PsnName: res.Output.Baseinfo.PsnName,
  9367. Idetinfo: idetinfoStr,
  9368. Insuinfo: infoStr,
  9369. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9370. }
  9371. service.CreateHisPsn(psn)
  9372. c.ServeSuccessJSON(map[string]interface{}{
  9373. "patient": patient,
  9374. "number": res.Output.Baseinfo.Certno,
  9375. })
  9376. }
  9377. } else {
  9378. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9379. return
  9380. }
  9381. } else if miConfig.MdtrtareaAdmvs == "420902" {
  9382. var res ResultTwo
  9383. api := miConfig.Url + "hbyb/1101?cert_no=" + "" +
  9384. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  9385. "&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)
  9386. resp, requestErr := http.Get(api)
  9387. if requestErr != nil {
  9388. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9389. return
  9390. }
  9391. body, ioErr := ioutil.ReadAll(resp.Body)
  9392. if ioErr != nil {
  9393. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9394. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9395. return
  9396. }
  9397. var respJSON map[string]interface{}
  9398. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9399. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9400. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9401. return
  9402. }
  9403. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9404. result, _ := json.Marshal(respJSON)
  9405. fmt.Println("log")
  9406. fmt.Println(string(result))
  9407. if err := json.Unmarshal([]byte(result), &res); err != nil {
  9408. utils.ErrorLog("解析失败:%v", err)
  9409. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9410. return
  9411. }
  9412. if res.Infcode == 0 {
  9413. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  9414. if err == gorm.ErrRecordNotFound {
  9415. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  9416. return
  9417. } else if err != nil {
  9418. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  9419. return
  9420. } else {
  9421. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9422. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9423. infoStr := string(Iinfos)
  9424. idetinfoStr := string(Idetinfos)
  9425. var rf []*ResultFive
  9426. json.Unmarshal([]byte(infoStr), &rf)
  9427. var insutypes []*ResultFive
  9428. var insutype string
  9429. var is390 int = 0
  9430. var is310 int = 0
  9431. for _, item := range rf {
  9432. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  9433. insutypes = append(insutypes, item)
  9434. }
  9435. }
  9436. if len(insutypes) == 1 {
  9437. insutype = insutypes[0].Insutype
  9438. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  9439. } else {
  9440. for _, i := range insutypes {
  9441. if i.Insutype == "390" {
  9442. is390 = 1
  9443. }
  9444. if i.Insutype == "310" {
  9445. is310 = 1
  9446. }
  9447. }
  9448. }
  9449. if is390 == 1 {
  9450. insutype = "390"
  9451. }
  9452. if is310 == 1 {
  9453. insutype = "310"
  9454. }
  9455. if len(insutypes) == 0 {
  9456. insutype = "390"
  9457. }
  9458. var insuplc_admdvs string
  9459. for _, item := range rf {
  9460. if item.Insutype == insutype {
  9461. insuplc_admdvs = item.InsuplcAdmdvs
  9462. }
  9463. }
  9464. psn := &models.HisPsn{
  9465. PsnNo: res.Output.Baseinfo.PsnNo,
  9466. PatientId: patient.ID,
  9467. Certno: res.Output.Baseinfo.Certno,
  9468. Gend: res.Output.Baseinfo.Gend,
  9469. Naty: res.Output.Baseinfo.Naty,
  9470. PsnCertType: res.Output.Baseinfo.PsnCertType,
  9471. PsnName: res.Output.Baseinfo.PsnName,
  9472. Idetinfo: idetinfoStr,
  9473. Insuinfo: infoStr,
  9474. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9475. InsuplcAdmdvs: insuplc_admdvs,
  9476. }
  9477. service.CreateHisPsn(psn)
  9478. c.ServeSuccessJSON(map[string]interface{}{
  9479. "patient": patient,
  9480. "number": res.Output.Baseinfo.Certno,
  9481. })
  9482. }
  9483. } else {
  9484. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9485. return
  9486. }
  9487. } else if miConfig.MdtrtareaAdmvs == "450721" {
  9488. res := c.GetoleInfo()
  9489. if res.Infcode == 0 {
  9490. var result string
  9491. if res.Output.MdtrtCertType == "01" {
  9492. 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)
  9493. } else if res.Output.MdtrtCertType == "02" {
  9494. 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)
  9495. } else if res.Output.MdtrtCertType == "03" {
  9496. 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)
  9497. }
  9498. var dat map[string]interface{}
  9499. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9500. fmt.Println(dat)
  9501. } else {
  9502. fmt.Println(err)
  9503. }
  9504. userJSONBytes, _ := json.Marshal(dat)
  9505. var res2 ResultTwo
  9506. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  9507. utils.ErrorLog("解析失败:%v", err)
  9508. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9509. return
  9510. }
  9511. if res2.Infcode == 0 {
  9512. patient, err := service.GetPatientByNumber(res.Output.CertNo, c.GetAdminUserInfo().CurrentOrgId)
  9513. if err == gorm.ErrRecordNotFound {
  9514. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  9515. return
  9516. } else if err != nil {
  9517. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  9518. return
  9519. } else {
  9520. Iinfos, _ := json.Marshal(res2.Output.Iinfo)
  9521. Idetinfos, _ := json.Marshal(res2.Output.Idetinfo)
  9522. infoStr := string(Iinfos)
  9523. idetinfoStr := string(Idetinfos)
  9524. var rf []*ResultFive
  9525. json.Unmarshal([]byte(infoStr), &rf)
  9526. var insutypes []*ResultFive
  9527. var insutype string
  9528. var is390 int = 0
  9529. var is310 int = 0
  9530. //var insuplc_admdvs string
  9531. for _, item := range rf {
  9532. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  9533. insutypes = append(insutypes, item)
  9534. }
  9535. }
  9536. if len(insutypes) == 1 {
  9537. insutype = insutypes[0].Insutype
  9538. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  9539. } else {
  9540. for _, i := range insutypes {
  9541. if i.Insutype == "390" {
  9542. is390 = 1
  9543. }
  9544. if i.Insutype == "310" {
  9545. is310 = 1
  9546. }
  9547. }
  9548. }
  9549. if is390 == 1 {
  9550. insutype = "390"
  9551. }
  9552. if is310 == 1 {
  9553. insutype = "310"
  9554. }
  9555. if len(insutypes) == 0 {
  9556. insutype = "310"
  9557. }
  9558. psn := &models.HisPsn{
  9559. PsnNo: res2.Output.Baseinfo.PsnNo,
  9560. PatientId: patient.ID,
  9561. //Brdy: res2.Output.Baseinfo.Brdy,
  9562. Certno: res2.Output.Baseinfo.Certno,
  9563. Gend: res2.Output.Baseinfo.Gend,
  9564. Naty: res2.Output.Baseinfo.Naty,
  9565. PsnCertType: res2.Output.Baseinfo.PsnCertType,
  9566. PsnName: res2.Output.Baseinfo.PsnName,
  9567. Idetinfo: idetinfoStr,
  9568. Insuinfo: infoStr,
  9569. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9570. CardInfo: res.Output.CertNo + "|" + res.Output.CardSN,
  9571. VerifyNumber: res.Output.EcToken,
  9572. InsuplcAdmdvs: res.Output.InsuplcAdmdvs,
  9573. }
  9574. service.CreateHisPsn(psn)
  9575. var balc float64
  9576. for _, item := range rf {
  9577. if item.Insutype == insutype {
  9578. balc = item.Balc
  9579. }
  9580. }
  9581. c.ServeSuccessJSON(map[string]interface{}{
  9582. "patient": patient,
  9583. "number": res.Output.CardNo,
  9584. "insutype": insutype,
  9585. "blac": balc,
  9586. "desc": idetinfoStr,
  9587. })
  9588. }
  9589. } else {
  9590. c.ServeSuccessJSON(map[string]interface{}{
  9591. "failed_code": -10,
  9592. "msg": res2.ErrMsg,
  9593. })
  9594. }
  9595. } else {
  9596. c.ServeSuccessJSON(map[string]interface{}{
  9597. "failed_code": -10,
  9598. "msg": res.ErrMsg,
  9599. })
  9600. }
  9601. } else {
  9602. SFZStr := c.GetSFZBaseInfo()
  9603. id_card_str := strings.Split(SFZStr, "^")
  9604. id_card_number := id_card_str[0]
  9605. card_sn := ""
  9606. 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)
  9607. var dat map[string]interface{}
  9608. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9609. fmt.Println(dat)
  9610. } else {
  9611. fmt.Println(err)
  9612. }
  9613. userJSONBytes, _ := json.Marshal(dat)
  9614. var res ResultTwo
  9615. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9616. utils.ErrorLog("解析失败:%v", err)
  9617. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9618. return
  9619. }
  9620. if res.Infcode == 0 {
  9621. patient, err := service.GetPatientByNumber(id_card_number, c.GetAdminUserInfo().CurrentOrgId)
  9622. if err == gorm.ErrRecordNotFound {
  9623. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  9624. return
  9625. } else if err != nil {
  9626. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  9627. return
  9628. } else {
  9629. c.ServeSuccessJSON(map[string]interface{}{
  9630. "patient": patient,
  9631. "number": id_card_number,
  9632. })
  9633. }
  9634. } else {
  9635. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9636. return
  9637. }
  9638. }
  9639. break
  9640. case 3:
  9641. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  9642. var api string
  9643. if miConfig.MdtrtareaAdmvs == "320921" {
  9644. 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 +
  9645. "&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
  9646. fmt.Println(api)
  9647. } else {
  9648. 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 +
  9649. "&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)
  9650. }
  9651. resp, requestErr := http.Get(api)
  9652. if requestErr != nil {
  9653. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9654. return
  9655. }
  9656. body, ioErr := ioutil.ReadAll(resp.Body)
  9657. if ioErr != nil {
  9658. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9659. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9660. return
  9661. }
  9662. var respJSON map[string]interface{}
  9663. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9664. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9665. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9666. return
  9667. }
  9668. var status string
  9669. status = respJSON["data"].(map[string]interface{})["status"].(string)
  9670. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  9671. var token string
  9672. var res ResultTwo //1101结果
  9673. var res10265 ResultTwo10265 //1101结果
  9674. var card_info string //卡信息
  9675. var busi_card_info string
  9676. //card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  9677. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  9678. if status == "0" { //读卡成功
  9679. if card_type == "1" {
  9680. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  9681. result, _ := json.Marshal(respJSON)
  9682. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  9683. utils.ErrorLog("解析失败:%v", err)
  9684. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9685. return
  9686. }
  9687. res.ErrMsg = res10265.ErrMsg
  9688. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  9689. res.Infcode = infocode
  9690. res.Output = res10265.Output
  9691. res.InfRefmsgid = res10265.InfRefmsgid
  9692. } else {
  9693. //var card_info string //卡信息
  9694. //var busi_card_info string
  9695. token = respJSON["data"].(map[string]interface{})["token"].(string)
  9696. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  9697. //fmt.Println(card_info)
  9698. //fmt.Println(busi_card_info)
  9699. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  9700. result, _ := json.Marshal(respJSON)
  9701. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  9702. utils.ErrorLog("解析失败:%v", err)
  9703. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9704. return
  9705. }
  9706. res.ErrMsg = res10265.ErrMsg
  9707. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  9708. res.Infcode = infocode
  9709. res.Output = res10265.Output
  9710. res.InfRefmsgid = res10265.InfRefmsgid
  9711. }
  9712. if res.Infcode == 0 {
  9713. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  9714. if err == gorm.ErrRecordNotFound {
  9715. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  9716. return
  9717. } else if err != nil {
  9718. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  9719. return
  9720. } else {
  9721. if card_type == "1" {
  9722. bas := strings.Split(card_info, "|")
  9723. basNumber := bas[2]
  9724. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9725. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9726. infoStr := string(Iinfos)
  9727. idetinfoStr := string(Idetinfos)
  9728. psn := &models.HisPsn{
  9729. PsnNo: res.Output.Baseinfo.PsnNo,
  9730. PatientId: patient.ID,
  9731. Certno: res.Output.Baseinfo.Certno,
  9732. //Brdy: res.Output.Baseinfo.Brdy,
  9733. Gend: res.Output.Baseinfo.Gend,
  9734. Naty: res.Output.Baseinfo.Naty,
  9735. PsnCertType: res.Output.Baseinfo.PsnCertType,
  9736. PsnName: res.Output.Baseinfo.PsnName,
  9737. Idetinfo: idetinfoStr,
  9738. Insuinfo: infoStr,
  9739. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9740. CardInfo: card_info,
  9741. VerifyNumber: busi_card_info,
  9742. }
  9743. service.CreateHisPsn(psn)
  9744. c.ServeSuccessJSON(map[string]interface{}{
  9745. "patient": patient,
  9746. "number": basNumber,
  9747. })
  9748. } else {
  9749. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9750. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9751. infoStr := string(Iinfos)
  9752. idetinfoStr := string(Idetinfos)
  9753. psn := &models.HisPsn{
  9754. PsnNo: res.Output.Baseinfo.PsnNo,
  9755. PatientId: patient.ID,
  9756. Certno: res.Output.Baseinfo.Certno,
  9757. Gend: res.Output.Baseinfo.Gend,
  9758. Naty: res.Output.Baseinfo.Naty,
  9759. PsnCertType: res.Output.Baseinfo.PsnCertType,
  9760. PsnName: res.Output.Baseinfo.PsnName,
  9761. Idetinfo: idetinfoStr,
  9762. Insuinfo: infoStr,
  9763. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9764. CardInfo: card_info,
  9765. VerifyNumber: token,
  9766. }
  9767. service.CreateHisPsn(psn)
  9768. var rf []*ResultFive
  9769. json.Unmarshal([]byte(infoStr), &rf)
  9770. var insutypes []*ResultFive
  9771. var insutype string
  9772. var is390 int = 0
  9773. var is310 int = 0
  9774. for _, item := range rf {
  9775. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  9776. insutypes = append(insutypes, item)
  9777. }
  9778. }
  9779. if len(insutypes) == 1 {
  9780. insutype = insutypes[0].Insutype
  9781. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  9782. } else {
  9783. for _, i := range insutypes {
  9784. if i.Insutype == "390" {
  9785. is390 = 1
  9786. }
  9787. if i.Insutype == "310" {
  9788. is310 = 1
  9789. }
  9790. }
  9791. }
  9792. if is390 == 1 {
  9793. insutype = "390"
  9794. }
  9795. if is310 == 1 {
  9796. insutype = "310"
  9797. }
  9798. if len(insutypes) == 0 {
  9799. insutype = "310"
  9800. }
  9801. c.ServeSuccessJSON(map[string]interface{}{
  9802. "patient": patient,
  9803. "number": token,
  9804. "insutype": insutype,
  9805. })
  9806. }
  9807. }
  9808. } else {
  9809. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9810. return
  9811. }
  9812. } else { //读卡失败
  9813. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9814. return
  9815. }
  9816. }
  9817. break
  9818. case 4:
  9819. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  9820. var api string
  9821. if miConfig.MdtrtareaAdmvs == "320921" {
  9822. 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 +
  9823. "&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
  9824. fmt.Println(api)
  9825. } else {
  9826. 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 +
  9827. "&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)
  9828. }
  9829. resp, requestErr := http.Get(api)
  9830. if requestErr != nil {
  9831. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9832. return
  9833. }
  9834. body, ioErr := ioutil.ReadAll(resp.Body)
  9835. if ioErr != nil {
  9836. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9837. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9838. return
  9839. }
  9840. var respJSON map[string]interface{}
  9841. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9842. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9843. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9844. return
  9845. }
  9846. var status string
  9847. status = respJSON["data"].(map[string]interface{})["status"].(string)
  9848. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  9849. var token string
  9850. var res ResultTwo //1101结果
  9851. var res10265 ResultTwo10265 //1101结果
  9852. if status == "0" { //读卡成功
  9853. var card_info string //卡信息
  9854. var busi_card_info string
  9855. token = respJSON["data"].(map[string]interface{})["token"].(string)
  9856. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  9857. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  9858. fmt.Println(card_info)
  9859. fmt.Println(busi_card_info)
  9860. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  9861. result, _ := json.Marshal(respJSON)
  9862. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  9863. utils.ErrorLog("解析失败:%v", err)
  9864. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9865. return
  9866. }
  9867. res.ErrMsg = res10265.ErrMsg
  9868. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  9869. res.Infcode = infocode
  9870. res.Output = res10265.Output
  9871. res.InfRefmsgid = res10265.InfRefmsgid
  9872. if res.Infcode == 0 {
  9873. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  9874. if err == gorm.ErrRecordNotFound {
  9875. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  9876. return
  9877. } else if err != nil {
  9878. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  9879. return
  9880. } else {
  9881. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9882. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9883. infoStr := string(Iinfos)
  9884. idetinfoStr := string(Idetinfos)
  9885. b, age, _ := getBirthdateAndAge(res.Output.Baseinfo.Certno)
  9886. psn := &models.HisPsn{
  9887. PsnNo: res.Output.Baseinfo.PsnNo,
  9888. PatientId: patient.ID,
  9889. Certno: res.Output.Baseinfo.Certno,
  9890. Brdy: b,
  9891. Age: float64(age),
  9892. //Brdy: res.Output.Baseinfo.Brdy,
  9893. Gend: res.Output.Baseinfo.Gend,
  9894. Naty: res.Output.Baseinfo.Naty,
  9895. PsnCertType: res.Output.Baseinfo.PsnCertType,
  9896. PsnName: res.Output.Baseinfo.PsnName,
  9897. Idetinfo: idetinfoStr,
  9898. Insuinfo: infoStr,
  9899. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9900. CardInfo: card_info,
  9901. VerifyNumber: token,
  9902. }
  9903. var rf []*ResultFive
  9904. json.Unmarshal([]byte(infoStr), &rf)
  9905. var insutypes []*ResultFive
  9906. var insutype string
  9907. var is390 int = 0
  9908. var is310 int = 0
  9909. for _, item := range rf {
  9910. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  9911. insutypes = append(insutypes, item)
  9912. }
  9913. }
  9914. if len(insutypes) == 1 {
  9915. insutype = insutypes[0].Insutype
  9916. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  9917. } else {
  9918. for _, i := range insutypes {
  9919. if i.Insutype == "390" {
  9920. is390 = 1
  9921. }
  9922. if i.Insutype == "310" {
  9923. is310 = 1
  9924. }
  9925. }
  9926. }
  9927. if is390 == 1 {
  9928. insutype = "390"
  9929. }
  9930. if is310 == 1 {
  9931. insutype = "310"
  9932. }
  9933. if len(insutypes) == 0 {
  9934. insutype = "310"
  9935. }
  9936. service.CreateHisPsn(psn)
  9937. c.ServeSuccessJSON(map[string]interface{}{
  9938. "patient": patient,
  9939. "number": token,
  9940. "insutype": insutype,
  9941. })
  9942. }
  9943. } else {
  9944. c.ServeSuccessJSON(map[string]interface{}{
  9945. "failed_code": -10,
  9946. "msg": res.ErrMsg,
  9947. })
  9948. }
  9949. } else { //读卡失败
  9950. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9951. return
  9952. }
  9953. } else if miConfig.MdtrtareaAdmvs == "341203" {
  9954. var api string
  9955. api = miConfig.SecretKey + "ahyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  9956. "&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
  9957. resp, requestErr := http.Get(api)
  9958. if requestErr != nil {
  9959. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9960. return
  9961. }
  9962. body, ioErr := ioutil.ReadAll(resp.Body)
  9963. if ioErr != nil {
  9964. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9965. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9966. return
  9967. }
  9968. var respJSON map[string]interface{}
  9969. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9970. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9971. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9972. return
  9973. }
  9974. var status string
  9975. status = respJSON["data"].(map[string]interface{})["status"].(string)
  9976. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  9977. var token string
  9978. var res ResultTwo //1101结果
  9979. if status == "1" { //读卡成功
  9980. var card_info string //卡信息
  9981. var busi_card_info string
  9982. token = respJSON["data"].(map[string]interface{})["token"].(string)
  9983. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  9984. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  9985. fmt.Println(card_info)
  9986. fmt.Println(busi_card_info)
  9987. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  9988. result, _ := json.Marshal(respJSON)
  9989. if err := json.Unmarshal([]byte(result), &res); err != nil {
  9990. utils.ErrorLog("解析失败:%v", err)
  9991. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9992. return
  9993. }
  9994. if res.Infcode == 0 {
  9995. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  9996. if err == gorm.ErrRecordNotFound {
  9997. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  9998. return
  9999. } else if err != nil {
  10000. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  10001. return
  10002. } else {
  10003. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  10004. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  10005. infoStr := string(Iinfos)
  10006. idetinfoStr := string(Idetinfos)
  10007. psn := &models.HisPsn{
  10008. PsnNo: res.Output.Baseinfo.PsnNo,
  10009. PatientId: patient.ID,
  10010. Certno: res.Output.Baseinfo.Certno,
  10011. Gend: res.Output.Baseinfo.Gend,
  10012. Naty: res.Output.Baseinfo.Naty,
  10013. PsnCertType: res.Output.Baseinfo.PsnCertType,
  10014. PsnName: res.Output.Baseinfo.PsnName,
  10015. Idetinfo: idetinfoStr,
  10016. Insuinfo: infoStr,
  10017. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10018. CardInfo: card_info,
  10019. VerifyNumber: token,
  10020. }
  10021. var rf []*ResultFive
  10022. json.Unmarshal([]byte(infoStr), &rf)
  10023. var insutypes []*ResultFive
  10024. var insutype string
  10025. var is390 int = 0
  10026. var is310 int = 0
  10027. for _, item := range rf {
  10028. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  10029. insutypes = append(insutypes, item)
  10030. }
  10031. }
  10032. if len(insutypes) == 1 {
  10033. insutype = insutypes[0].Insutype
  10034. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  10035. } else {
  10036. for _, i := range insutypes {
  10037. if i.Insutype == "390" {
  10038. is390 = 1
  10039. }
  10040. if i.Insutype == "310" {
  10041. is310 = 1
  10042. }
  10043. }
  10044. }
  10045. if is390 == 1 {
  10046. insutype = "390"
  10047. }
  10048. if is310 == 1 {
  10049. insutype = "310"
  10050. }
  10051. if len(insutypes) == 0 {
  10052. insutype = "310"
  10053. }
  10054. service.CreateHisPsn(psn)
  10055. c.ServeSuccessJSON(map[string]interface{}{
  10056. "patient": patient,
  10057. "number": token,
  10058. "insutype": insutype,
  10059. })
  10060. }
  10061. } else {
  10062. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10063. return
  10064. }
  10065. } else { //读卡失败
  10066. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10067. return
  10068. }
  10069. } else if miConfig.MdtrtareaAdmvs == "430800" {
  10070. idNo := c.GetString("idNo")
  10071. userName := c.GetString("userName")
  10072. ecToken := c.GetString("ecToken")
  10073. insuOrg := c.GetString("insuOrg")
  10074. result2, requestLog2 := service.Hnyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, insuOrg, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, ecToken, "", idNo, userName)
  10075. saveLog(result2, requestLog2, "1101", "获取人员信息")
  10076. var res ResultTwo
  10077. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  10078. utils.ErrorLog("解析失败:%v", err)
  10079. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10080. return
  10081. }
  10082. if res.Infcode == 0 {
  10083. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  10084. if err == gorm.ErrRecordNotFound {
  10085. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  10086. return
  10087. } else if err != nil {
  10088. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  10089. return
  10090. } else {
  10091. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  10092. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  10093. infoStr := string(Iinfos)
  10094. idetinfoStr := string(Idetinfos)
  10095. psn := &models.HisPsn{
  10096. PsnNo: res.Output.Baseinfo.PsnNo,
  10097. PatientId: patient.ID,
  10098. Certno: res.Output.Baseinfo.Certno,
  10099. Gend: res.Output.Baseinfo.Gend,
  10100. Naty: res.Output.Baseinfo.Naty,
  10101. PsnCertType: res.Output.Baseinfo.PsnCertType,
  10102. PsnName: res.Output.Baseinfo.PsnName,
  10103. Idetinfo: idetinfoStr,
  10104. Insuinfo: infoStr,
  10105. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10106. CardInfo: "",
  10107. Stage: "1",
  10108. VerifyNumber: ecToken,
  10109. InsuplcAdmdvs: insuOrg,
  10110. }
  10111. service.CreateHisPsn(psn)
  10112. var rf []*ResultFive
  10113. json.Unmarshal([]byte(infoStr), &rf)
  10114. var insutypes []*ResultFive
  10115. var insutype string
  10116. var is390 int = 0
  10117. var is310 int = 0
  10118. for _, item := range rf {
  10119. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  10120. insutypes = append(insutypes, item)
  10121. }
  10122. }
  10123. if len(insutypes) == 1 {
  10124. insutype = insutypes[0].Insutype
  10125. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  10126. } else {
  10127. for _, i := range insutypes {
  10128. if i.Insutype == "390" {
  10129. is390 = 1
  10130. }
  10131. if i.Insutype == "310" {
  10132. is310 = 1
  10133. }
  10134. }
  10135. }
  10136. if is390 == 1 {
  10137. insutype = "390"
  10138. }
  10139. if is310 == 1 {
  10140. insutype = "310"
  10141. }
  10142. if len(insutypes) == 0 {
  10143. insutype = "310"
  10144. }
  10145. c.ServeSuccessJSON(map[string]interface{}{
  10146. "patient": patient,
  10147. "number": ecToken,
  10148. "insutype": insutype,
  10149. })
  10150. }
  10151. } else {
  10152. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10153. return
  10154. }
  10155. } else if miConfig.MdtrtareaAdmvs == "360302" {
  10156. //if initFlag == 0 {
  10157. //c.TestGetJiangXiBasBaseInit()
  10158. //}
  10159. //if initEleFlag == 0 {
  10160. // GetJxEleBaseInitInfo(c.GetAdminUserInfo().CurrentOrgId)
  10161. //}
  10162. //_, result2 := GetjxELekeyInfo(miConfig.Code, "1", roles.UserName)
  10163. _, result := GetjxELeInfoaaa(miConfig.Code, "1", roles.UserName)
  10164. //json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  10165. type ELeData struct {
  10166. Data struct {
  10167. IdNo string `json:"idNo"`
  10168. IdType string `json:"idType"`
  10169. UserName string `json:"userName"`
  10170. EcToken string `json:"ecToken"`
  10171. InsuOrg string `json:"insuOrg"`
  10172. Gender string `json:"gender"`
  10173. Birthday string `json:"birthday"`
  10174. Nationality string `json:"nationality"`
  10175. Email string `json:"email"`
  10176. Extra string `json:"extra"`
  10177. } `json:"data"`
  10178. Code int `json:"code"`
  10179. Message string `json:"message"`
  10180. }
  10181. var ele ELeData
  10182. err := json.Unmarshal([]byte(result), &ele)
  10183. if err != nil {
  10184. utils.ErrorLog("解析失败:%v", err)
  10185. }
  10186. token := ele.Data.EcToken
  10187. token = Remove0000(token)
  10188. 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)
  10189. saveLog(result2, requestLog2, "1101", "获取人员信息")
  10190. var res ResultTwo
  10191. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  10192. utils.ErrorLog("解析失败:%v", err)
  10193. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10194. return
  10195. }
  10196. if res.Infcode == 0 {
  10197. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  10198. if err == gorm.ErrRecordNotFound {
  10199. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  10200. return
  10201. } else if err != nil {
  10202. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  10203. return
  10204. } else {
  10205. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  10206. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  10207. infoStr := string(Iinfos)
  10208. idetinfoStr := string(Idetinfos)
  10209. psn := &models.HisPsn{
  10210. PsnNo: res.Output.Baseinfo.PsnNo,
  10211. PatientId: patient.ID,
  10212. Certno: res.Output.Baseinfo.Certno,
  10213. Gend: res.Output.Baseinfo.Gend,
  10214. Naty: res.Output.Baseinfo.Naty,
  10215. PsnCertType: res.Output.Baseinfo.PsnCertType,
  10216. PsnName: res.Output.Baseinfo.PsnName,
  10217. Idetinfo: idetinfoStr,
  10218. Insuinfo: infoStr,
  10219. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10220. CardInfo: "",
  10221. VerifyNumber: token,
  10222. }
  10223. service.CreateHisPsn(psn)
  10224. var rf []*ResultFive
  10225. json.Unmarshal([]byte(infoStr), &rf)
  10226. var insutypes []*ResultFive
  10227. var insutype string
  10228. var is390 int = 0
  10229. var is310 int = 0
  10230. for _, item := range rf {
  10231. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  10232. insutypes = append(insutypes, item)
  10233. }
  10234. }
  10235. if len(insutypes) == 1 {
  10236. insutype = insutypes[0].Insutype
  10237. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  10238. } else {
  10239. for _, i := range insutypes {
  10240. if i.Insutype == "390" {
  10241. is390 = 1
  10242. }
  10243. if i.Insutype == "310" {
  10244. is310 = 1
  10245. }
  10246. }
  10247. }
  10248. if is390 == 1 {
  10249. insutype = "390"
  10250. }
  10251. if is310 == 1 {
  10252. insutype = "310"
  10253. }
  10254. if len(insutypes) == 0 {
  10255. insutype = "310"
  10256. }
  10257. c.ServeSuccessJSON(map[string]interface{}{
  10258. "patient": patient,
  10259. "number": token,
  10260. "insutype": insutype,
  10261. })
  10262. }
  10263. } else {
  10264. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10265. return
  10266. }
  10267. } else if miConfig.MdtrtareaAdmvs == "430800" {
  10268. //if initFlag == 0 {
  10269. c.TestGetJiangXiBasBaseInit()
  10270. //}
  10271. //if initEleFlag == 0 {
  10272. // GetJxEleBaseInitInfo(c.GetAdminUserInfo().CurrentOrgId)
  10273. //}
  10274. json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  10275. type ELeData struct {
  10276. Data struct {
  10277. IdNo string `json:"idNo"`
  10278. IdType string `json:"idType"`
  10279. UserName string `json:"userName"`
  10280. EcToken string `json:"ecToken"`
  10281. InsuOrg string `json:"insuOrg"`
  10282. Gender string `json:"gender"`
  10283. Birthday string `json:"birthday"`
  10284. Nationality string `json:"nationality"`
  10285. Email string `json:"email"`
  10286. Extra string `json:"extra"`
  10287. } `json:"data"`
  10288. Code int `json:"code"`
  10289. Message string `json:"message"`
  10290. }
  10291. var ele ELeData
  10292. err := json.Unmarshal([]byte(json_result), &ele)
  10293. if err != nil {
  10294. utils.ErrorLog("解析失败:%v", err)
  10295. }
  10296. token := ele.Data.EcToken
  10297. token = Remove0000(token)
  10298. 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)
  10299. saveLog(result2, requestLog2, "1101", "获取人员信息")
  10300. var res ResultTwo
  10301. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  10302. utils.ErrorLog("解析失败:%v", err)
  10303. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10304. return
  10305. }
  10306. if res.Infcode == 0 {
  10307. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  10308. if err == gorm.ErrRecordNotFound {
  10309. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  10310. return
  10311. } else if err != nil {
  10312. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  10313. return
  10314. } else {
  10315. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  10316. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  10317. infoStr := string(Iinfos)
  10318. idetinfoStr := string(Idetinfos)
  10319. psn := &models.HisPsn{
  10320. PsnNo: res.Output.Baseinfo.PsnNo,
  10321. PatientId: patient.ID,
  10322. Certno: res.Output.Baseinfo.Certno,
  10323. Gend: res.Output.Baseinfo.Gend,
  10324. Naty: res.Output.Baseinfo.Naty,
  10325. PsnCertType: res.Output.Baseinfo.PsnCertType,
  10326. PsnName: res.Output.Baseinfo.PsnName,
  10327. Idetinfo: idetinfoStr,
  10328. Insuinfo: infoStr,
  10329. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10330. CardInfo: "",
  10331. VerifyNumber: token,
  10332. }
  10333. service.CreateHisPsn(psn)
  10334. var rf []*ResultFive
  10335. json.Unmarshal([]byte(infoStr), &rf)
  10336. var insutypes []*ResultFive
  10337. var insutype string
  10338. var is390 int = 0
  10339. var is310 int = 0
  10340. for _, item := range rf {
  10341. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  10342. insutypes = append(insutypes, item)
  10343. }
  10344. }
  10345. if len(insutypes) == 1 {
  10346. insutype = insutypes[0].Insutype
  10347. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  10348. } else {
  10349. for _, i := range insutypes {
  10350. if i.Insutype == "390" {
  10351. is390 = 1
  10352. }
  10353. if i.Insutype == "310" {
  10354. is310 = 1
  10355. }
  10356. }
  10357. }
  10358. if is390 == 1 {
  10359. insutype = "390"
  10360. }
  10361. if is310 == 1 {
  10362. insutype = "310"
  10363. }
  10364. if len(insutypes) == 0 {
  10365. insutype = "310"
  10366. }
  10367. c.ServeSuccessJSON(map[string]interface{}{
  10368. "patient": patient,
  10369. "number": token,
  10370. "insutype": insutype,
  10371. })
  10372. }
  10373. } else {
  10374. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10375. return
  10376. }
  10377. } else if miConfig.MdtrtareaAdmvs == "350500" {
  10378. type ELeData struct {
  10379. Code string `json:"code"`
  10380. Data struct {
  10381. Aac002 string `json:"aac002"`
  10382. Aaz500 string `json:"aaz500"`
  10383. ActCardNo string `json:"actCardNo"`
  10384. Bab520 string `json:"bab520"`
  10385. Bkz543 string `json:"bkz543"`
  10386. BusinessType string `json:"businessType"`
  10387. CertfCodg string `json:"certfCodg"`
  10388. EcIndexNo string `json:"ecIndexNo"`
  10389. EcToken string `json:"ecToken"`
  10390. ID0000 string `json:"id0000"`
  10391. IDNo string `json:"idNo"`
  10392. IDType string `json:"idType"`
  10393. Idcode string `json:"idcode"`
  10394. IdentityToken string `json:"identity_token"`
  10395. InsuOrg string `json:"insuOrg"`
  10396. OfficeID string `json:"officeId"`
  10397. OfficeName string `json:"officeName"`
  10398. OperatorID string `json:"operatorId"`
  10399. OperatorName string `json:"operatorName"`
  10400. OrgID string `json:"orgId"`
  10401. UserName string `json:"userName"`
  10402. } `json:"data"`
  10403. Infno interface{} `json:"infno"`
  10404. Message string `json:"message"`
  10405. OrgID string `json:"orgId"`
  10406. TransType string `json:"transType"`
  10407. }
  10408. inputInfo, outPutInfo, _ := service.ReadEleCard(miConfig.Code)
  10409. outPutInfo = Remove0000(outPutInfo)
  10410. if len(outPutInfo) > 0 {
  10411. var ele ELeData
  10412. err := json.Unmarshal([]byte(outPutInfo), &ele)
  10413. if err != nil {
  10414. utils.ErrorLog("解析失败:%v", err)
  10415. }
  10416. token := ele.Data.EcToken
  10417. fmt.Println(inputInfo)
  10418. fmt.Println(outPutInfo)
  10419. 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)
  10420. saveLog(result, requestLog, "1101", "获取人员信息")
  10421. var dat map[string]interface{}
  10422. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10423. fmt.Println(dat)
  10424. } else {
  10425. fmt.Println(err)
  10426. }
  10427. userJSONBytes, _ := json.Marshal(dat)
  10428. var res ResultTwo
  10429. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10430. utils.ErrorLog("解析失败:%v", err)
  10431. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10432. return
  10433. }
  10434. res.ErrMsg = errMsgLog
  10435. if res.Infcode == 0 {
  10436. patient, err := service.GetPatientByNumber(ele.Data.IDNo, c.GetAdminUserInfo().CurrentOrgId)
  10437. if err == gorm.ErrRecordNotFound {
  10438. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  10439. return
  10440. } else if err != nil {
  10441. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  10442. return
  10443. } else {
  10444. fmt.Println(res)
  10445. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  10446. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  10447. infoStr := string(Iinfos)
  10448. idetinfoStr := string(Idetinfos)
  10449. psn := &models.HisPsn{
  10450. PsnNo: res.Output.Baseinfo.PsnNo,
  10451. PatientId: patient.ID,
  10452. Certno: res.Output.Baseinfo.Certno,
  10453. Gend: res.Output.Baseinfo.Gend,
  10454. Naty: res.Output.Baseinfo.Naty,
  10455. PsnCertType: res.Output.Baseinfo.PsnCertType,
  10456. PsnName: res.Output.Baseinfo.PsnName,
  10457. Idetinfo: idetinfoStr,
  10458. Insuinfo: infoStr,
  10459. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10460. CardInfo: outPutInfo,
  10461. VerifyNumber: token,
  10462. InsuplcAdmdvs: ele.Data.InsuOrg,
  10463. }
  10464. service.CreateHisPsn(psn)
  10465. var rf []*ResultFive
  10466. json.Unmarshal([]byte(infoStr), &rf)
  10467. var insutypes []*ResultFive
  10468. var insutype string
  10469. var is390 int = 0
  10470. var is310 int = 0
  10471. for _, item := range rf {
  10472. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  10473. insutypes = append(insutypes, item)
  10474. }
  10475. }
  10476. if len(insutypes) == 1 {
  10477. insutype = insutypes[0].Insutype
  10478. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  10479. } else {
  10480. for _, i := range insutypes {
  10481. if i.Insutype == "390" {
  10482. is390 = 1
  10483. }
  10484. if i.Insutype == "310" {
  10485. is310 = 1
  10486. }
  10487. }
  10488. }
  10489. if is390 == 1 {
  10490. insutype = "390"
  10491. }
  10492. if is310 == 1 {
  10493. insutype = "310"
  10494. }
  10495. if len(insutypes) == 0 {
  10496. insutype = "310"
  10497. }
  10498. c.ServeSuccessJSON(map[string]interface{}{
  10499. "patient": patient,
  10500. "number": token,
  10501. "insutype": insutype,
  10502. })
  10503. }
  10504. } else {
  10505. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10506. return
  10507. }
  10508. }
  10509. } else if miConfig.MdtrtareaAdmvs == "150499" {
  10510. var api string
  10511. 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 +
  10512. "&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
  10513. resp, requestErr := http.Get(api)
  10514. if requestErr != nil {
  10515. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10516. return
  10517. }
  10518. body, ioErr := ioutil.ReadAll(resp.Body)
  10519. if ioErr != nil {
  10520. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10521. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10522. return
  10523. }
  10524. var respJSON map[string]interface{}
  10525. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  10526. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10527. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10528. return
  10529. }
  10530. var status string
  10531. status = respJSON["data"].(map[string]interface{})["status"].(string)
  10532. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  10533. var token string
  10534. var res ResultTwo //1101结果
  10535. var res10265 ResultTwo10265 //1101结果
  10536. if status == "0" { //读卡成功
  10537. var card_info string //卡信息
  10538. var busi_card_info string
  10539. token = respJSON["data"].(map[string]interface{})["token"].(string)
  10540. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  10541. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  10542. fmt.Println(card_info)
  10543. fmt.Println(busi_card_info)
  10544. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  10545. result, _ := json.Marshal(respJSON)
  10546. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  10547. utils.ErrorLog("解析失败:%v", err)
  10548. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10549. return
  10550. }
  10551. res.ErrMsg = res10265.ErrMsg
  10552. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  10553. res.Infcode = infocode
  10554. res.Output = res10265.Output
  10555. res.InfRefmsgid = res10265.InfRefmsgid
  10556. if res.Infcode == 0 {
  10557. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  10558. if err == gorm.ErrRecordNotFound {
  10559. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  10560. return
  10561. } else if err != nil {
  10562. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  10563. return
  10564. } else {
  10565. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  10566. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  10567. infoStr := string(Iinfos)
  10568. idetinfoStr := string(Idetinfos)
  10569. psn := &models.HisPsn{
  10570. PsnNo: res.Output.Baseinfo.PsnNo,
  10571. PatientId: patient.ID,
  10572. Certno: res.Output.Baseinfo.Certno,
  10573. Gend: res.Output.Baseinfo.Gend,
  10574. Naty: res.Output.Baseinfo.Naty,
  10575. PsnCertType: res.Output.Baseinfo.PsnCertType,
  10576. PsnName: res.Output.Baseinfo.PsnName,
  10577. Idetinfo: idetinfoStr,
  10578. Insuinfo: infoStr,
  10579. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10580. CardInfo: card_info,
  10581. VerifyNumber: token,
  10582. }
  10583. var rf []*ResultFive
  10584. json.Unmarshal([]byte(infoStr), &rf)
  10585. var insutypes []*ResultFive
  10586. var insutype string
  10587. var is390 int = 0
  10588. var is310 int = 0
  10589. for _, item := range rf {
  10590. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  10591. insutypes = append(insutypes, item)
  10592. }
  10593. }
  10594. if len(insutypes) == 1 {
  10595. insutype = insutypes[0].Insutype
  10596. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  10597. } else {
  10598. for _, i := range insutypes {
  10599. if i.Insutype == "390" {
  10600. is390 = 1
  10601. }
  10602. if i.Insutype == "310" {
  10603. is310 = 1
  10604. }
  10605. }
  10606. }
  10607. if is390 == 1 {
  10608. insutype = "390"
  10609. }
  10610. if is310 == 1 {
  10611. insutype = "310"
  10612. }
  10613. if len(insutypes) == 0 {
  10614. insutype = "310"
  10615. }
  10616. service.CreateHisPsn(psn)
  10617. c.ServeSuccessJSON(map[string]interface{}{
  10618. "patient": patient,
  10619. "number": token,
  10620. "insutype": insutype,
  10621. })
  10622. }
  10623. } else {
  10624. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10625. return
  10626. }
  10627. } else { //读卡失败
  10628. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10629. return
  10630. }
  10631. } else if miConfig.MdtrtareaAdmvs == "450721" {
  10632. res := c.GetoleInfo()
  10633. if res.Infcode == 0 {
  10634. var result string
  10635. if res.Output.MdtrtCertType == "01" {
  10636. 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)
  10637. } else if res.Output.MdtrtCertType == "02" {
  10638. 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)
  10639. } else if res.Output.MdtrtCertType == "03" {
  10640. 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)
  10641. }
  10642. var dat map[string]interface{}
  10643. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10644. fmt.Println(dat)
  10645. } else {
  10646. fmt.Println(err)
  10647. }
  10648. userJSONBytes, _ := json.Marshal(dat)
  10649. var res2 ResultTwo
  10650. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  10651. utils.ErrorLog("解析失败:%v", err)
  10652. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10653. return
  10654. }
  10655. if res2.Infcode == 0 {
  10656. patient, err := service.GetPatientByNumber(res.Output.CertNo, c.GetAdminUserInfo().CurrentOrgId)
  10657. if err == gorm.ErrRecordNotFound {
  10658. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  10659. return
  10660. } else if err != nil {
  10661. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  10662. return
  10663. } else {
  10664. Iinfos, _ := json.Marshal(res2.Output.Iinfo)
  10665. Idetinfos, _ := json.Marshal(res2.Output.Idetinfo)
  10666. infoStr := string(Iinfos)
  10667. idetinfoStr := string(Idetinfos)
  10668. var rf []*ResultFive
  10669. json.Unmarshal([]byte(infoStr), &rf)
  10670. var insutypes []*ResultFive
  10671. var insutype string
  10672. var is390 int = 0
  10673. var is310 int = 0
  10674. //var insuplc_admdvs string
  10675. for _, item := range rf {
  10676. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  10677. insutypes = append(insutypes, item)
  10678. }
  10679. }
  10680. if len(insutypes) == 1 {
  10681. insutype = insutypes[0].Insutype
  10682. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  10683. } else {
  10684. for _, i := range insutypes {
  10685. if i.Insutype == "390" {
  10686. is390 = 1
  10687. }
  10688. if i.Insutype == "310" {
  10689. is310 = 1
  10690. }
  10691. }
  10692. }
  10693. if is390 == 1 {
  10694. insutype = "390"
  10695. }
  10696. if is310 == 1 {
  10697. insutype = "310"
  10698. }
  10699. if len(insutypes) == 0 {
  10700. insutype = "310"
  10701. }
  10702. psn := &models.HisPsn{
  10703. PsnNo: res2.Output.Baseinfo.PsnNo,
  10704. PatientId: patient.ID,
  10705. Certno: res2.Output.Baseinfo.Certno,
  10706. Gend: res2.Output.Baseinfo.Gend,
  10707. Naty: res2.Output.Baseinfo.Naty,
  10708. PsnCertType: res2.Output.Baseinfo.PsnCertType,
  10709. PsnName: res2.Output.Baseinfo.PsnName,
  10710. Idetinfo: idetinfoStr,
  10711. Insuinfo: infoStr,
  10712. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10713. CardInfo: res.Output.CertNo + "|" + res.Output.CardSN,
  10714. VerifyNumber: res.Output.EcToken,
  10715. InsuplcAdmdvs: res.Output.InsuplcAdmdvs,
  10716. }
  10717. if res.Output.MdtrtCertType == "01" {
  10718. psn.VerifyNumber = res.Output.EcToken
  10719. //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)
  10720. } else if res.Output.MdtrtCertType == "02" {
  10721. psn.VerifyNumber = res.Output.CardNo
  10722. //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)
  10723. } else if res.Output.MdtrtCertType == "03" {
  10724. psn.VerifyNumber = res.Output.MdtrtCertNo
  10725. //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)
  10726. }
  10727. service.CreateHisPsn(psn)
  10728. var balc float64
  10729. for _, item := range rf {
  10730. if item.Insutype == insutype {
  10731. balc = item.Balc
  10732. }
  10733. }
  10734. c.ServeSuccessJSON(map[string]interface{}{
  10735. "patient": patient,
  10736. "number": res.Output.CardNo,
  10737. "insutype": insutype,
  10738. "blac": balc,
  10739. "desc": idetinfoStr,
  10740. })
  10741. }
  10742. } else {
  10743. c.ServeSuccessJSON(map[string]interface{}{
  10744. "failed_code": -10,
  10745. "msg": res2.ErrMsg,
  10746. })
  10747. }
  10748. } else {
  10749. c.ServeSuccessJSON(map[string]interface{}{
  10750. "failed_code": -10,
  10751. "msg": res.ErrMsg,
  10752. })
  10753. }
  10754. } else if miConfig.MdtrtareaAdmvs == "420902" {
  10755. var res ResultTwo
  10756. api := miConfig.Url + "hbyb/1101?cert_no=" + "" +
  10757. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  10758. "&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)
  10759. resp, requestErr := http.Get(api)
  10760. if requestErr != nil {
  10761. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10762. return
  10763. }
  10764. body, ioErr := ioutil.ReadAll(resp.Body)
  10765. if ioErr != nil {
  10766. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10767. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10768. return
  10769. }
  10770. var respJSON map[string]interface{}
  10771. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  10772. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10773. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10774. return
  10775. }
  10776. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10777. result, _ := json.Marshal(respJSON)
  10778. fmt.Println("log")
  10779. fmt.Println(string(result))
  10780. if err := json.Unmarshal([]byte(result), &res); err != nil {
  10781. utils.ErrorLog("解析失败:%v", err)
  10782. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10783. return
  10784. }
  10785. if res.Infcode == 0 {
  10786. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  10787. if err == gorm.ErrRecordNotFound {
  10788. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  10789. return
  10790. } else if err != nil {
  10791. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  10792. return
  10793. } else {
  10794. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  10795. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  10796. infoStr := string(Iinfos)
  10797. idetinfoStr := string(Idetinfos)
  10798. var rf []*ResultFive
  10799. json.Unmarshal([]byte(infoStr), &rf)
  10800. var insutypes []*ResultFive
  10801. var insutype string
  10802. var is390 int = 0
  10803. var is310 int = 0
  10804. for _, item := range rf {
  10805. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  10806. insutypes = append(insutypes, item)
  10807. }
  10808. }
  10809. if len(insutypes) == 1 {
  10810. insutype = insutypes[0].Insutype
  10811. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  10812. } else {
  10813. for _, i := range insutypes {
  10814. if i.Insutype == "390" {
  10815. is390 = 1
  10816. }
  10817. if i.Insutype == "310" {
  10818. is310 = 1
  10819. }
  10820. }
  10821. }
  10822. if is390 == 1 {
  10823. insutype = "390"
  10824. }
  10825. if is310 == 1 {
  10826. insutype = "310"
  10827. }
  10828. if len(insutypes) == 0 {
  10829. insutype = "390"
  10830. }
  10831. var insuplc_admdvs string
  10832. for _, item := range rf {
  10833. if item.Insutype == insutype {
  10834. insuplc_admdvs = item.InsuplcAdmdvs
  10835. }
  10836. }
  10837. psn := &models.HisPsn{
  10838. PsnNo: res.Output.Baseinfo.PsnNo,
  10839. PatientId: patient.ID,
  10840. Certno: res.Output.Baseinfo.Certno,
  10841. Gend: res.Output.Baseinfo.Gend,
  10842. Naty: res.Output.Baseinfo.Naty,
  10843. PsnCertType: res.Output.Baseinfo.PsnCertType,
  10844. PsnName: res.Output.Baseinfo.PsnName,
  10845. Idetinfo: idetinfoStr,
  10846. Insuinfo: infoStr,
  10847. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10848. InsuplcAdmdvs: insuplc_admdvs,
  10849. }
  10850. service.CreateHisPsn(psn)
  10851. c.ServeSuccessJSON(map[string]interface{}{
  10852. "patient": patient,
  10853. "number": res.Output.Baseinfo.Certno,
  10854. })
  10855. }
  10856. } else {
  10857. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10858. return
  10859. }
  10860. } else {
  10861. type ELeData struct {
  10862. Code string `json:"code"`
  10863. Data struct {
  10864. Aac002 string `json:"aac002"`
  10865. Aaz500 string `json:"aaz500"`
  10866. ActCardNo string `json:"actCardNo"`
  10867. Bab520 string `json:"bab520"`
  10868. Bkz543 string `json:"bkz543"`
  10869. BusinessType string `json:"businessType"`
  10870. CertfCodg string `json:"certfCodg"`
  10871. EcIndexNo string `json:"ecIndexNo"`
  10872. EcToken string `json:"ecToken"`
  10873. ID0000 string `json:"id0000"`
  10874. IDNo string `json:"idNo"`
  10875. IDType string `json:"idType"`
  10876. Idcode string `json:"idcode"`
  10877. IdentityToken string `json:"identity_token"`
  10878. InsuOrg string `json:"insuOrg"`
  10879. OfficeID string `json:"officeId"`
  10880. OfficeName string `json:"officeName"`
  10881. OperatorID string `json:"operatorId"`
  10882. OperatorName string `json:"operatorName"`
  10883. OrgID string `json:"orgId"`
  10884. UserName string `json:"userName"`
  10885. } `json:"data"`
  10886. Infno interface{} `json:"infno"`
  10887. Message string `json:"message"`
  10888. OrgID string `json:"orgId"`
  10889. TransType string `json:"transType"`
  10890. }
  10891. _, result := GetELeInfo(miConfig.Code, "1", roles.UserName, miConfig.MdtrtareaAdmvs)
  10892. fmt.Println(result)
  10893. outPutInfo := Remove0000(result)
  10894. fmt.Println(outPutInfo)
  10895. if len(outPutInfo) > 0 {
  10896. var ele ELeData
  10897. err := json.Unmarshal([]byte(outPutInfo), &ele)
  10898. if err != nil {
  10899. utils.ErrorLog("解析失败:%v", err)
  10900. }
  10901. token := ele.Data.EcToken
  10902. fmt.Println(outPutInfo)
  10903. 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)
  10904. saveLog(result, requestLog, "1101", "获取人员信息")
  10905. var dat map[string]interface{}
  10906. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10907. fmt.Println(dat)
  10908. } else {
  10909. fmt.Println(err)
  10910. }
  10911. userJSONBytes, _ := json.Marshal(dat)
  10912. var res ResultTwo
  10913. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10914. utils.ErrorLog("解析失败:%v", err)
  10915. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10916. return
  10917. }
  10918. if res.Infcode == 0 {
  10919. patient, err := service.GetPatientByNumber(ele.Data.IDNo, c.GetAdminUserInfo().CurrentOrgId)
  10920. if err == gorm.ErrRecordNotFound {
  10921. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  10922. return
  10923. } else if err != nil {
  10924. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  10925. return
  10926. } else {
  10927. fmt.Println(res)
  10928. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  10929. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  10930. infoStr := string(Iinfos)
  10931. idetinfoStr := string(Idetinfos)
  10932. psn := &models.HisPsn{
  10933. PsnNo: res.Output.Baseinfo.PsnNo,
  10934. PatientId: patient.ID,
  10935. Certno: res.Output.Baseinfo.Certno,
  10936. Gend: res.Output.Baseinfo.Gend,
  10937. Naty: res.Output.Baseinfo.Naty,
  10938. PsnCertType: res.Output.Baseinfo.PsnCertType,
  10939. PsnName: res.Output.Baseinfo.PsnName,
  10940. Idetinfo: idetinfoStr,
  10941. Insuinfo: infoStr,
  10942. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10943. CardInfo: outPutInfo,
  10944. VerifyNumber: token,
  10945. InsuplcAdmdvs: ele.Data.InsuOrg,
  10946. }
  10947. service.CreateHisPsn(psn)
  10948. var rf []*ResultFive
  10949. json.Unmarshal([]byte(infoStr), &rf)
  10950. var insutypes []*ResultFive
  10951. var insutype string
  10952. var is390 int = 0
  10953. var is310 int = 0
  10954. for _, item := range rf {
  10955. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  10956. insutypes = append(insutypes, item)
  10957. }
  10958. }
  10959. if len(insutypes) == 1 {
  10960. insutype = insutypes[0].Insutype
  10961. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  10962. } else {
  10963. for _, i := range insutypes {
  10964. if i.Insutype == "390" {
  10965. is390 = 1
  10966. }
  10967. if i.Insutype == "310" {
  10968. is310 = 1
  10969. }
  10970. }
  10971. }
  10972. if is390 == 1 {
  10973. insutype = "390"
  10974. }
  10975. if is310 == 1 {
  10976. insutype = "310"
  10977. }
  10978. if len(insutypes) == 0 {
  10979. insutype = "310"
  10980. }
  10981. c.ServeSuccessJSON(map[string]interface{}{
  10982. "patient": patient,
  10983. "number": token,
  10984. "insutype": insutype,
  10985. })
  10986. }
  10987. } else {
  10988. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10989. return
  10990. }
  10991. }
  10992. //fmt.Println(result)
  10993. //
  10994. //if initFlag == 0 {
  10995. // c.TestGetBasBaseInit()
  10996. //}
  10997. //token := c.GetEleBaseInfo()
  10998. //
  10999. //token = Remove0000(token)
  11000. //
  11001. //result2, requestLog2 := service.Gdyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, insuplc_admdvs_str, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, token, "", "")
  11002. //saveLog(result2, requestLog2, "1101", "获取人员信息")
  11003. ////
  11004. //var res ResultTwo
  11005. //if err := json.Unmarshal([]byte(result2), &res); err != nil {
  11006. // utils.ErrorLog("解析失败:%v", err)
  11007. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11008. // return
  11009. //}
  11010. //
  11011. //if res.Infcode == 0 {
  11012. // patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  11013. // if err == gorm.ErrRecordNotFound {
  11014. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  11015. // return
  11016. // } else if err != nil {
  11017. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  11018. // return
  11019. //
  11020. // } else {
  11021. // Iinfos, _ := json.Marshal(res.Output.Iinfo)
  11022. // Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  11023. // infoStr := string(Iinfos)
  11024. // idetinfoStr := string(Idetinfos)
  11025. //
  11026. //
  11027. //
  11028. //
  11029. // var rf []*ResultFive
  11030. // json.Unmarshal([]byte(infoStr), &rf)
  11031. //
  11032. // var insutypes []*ResultFive
  11033. // var insutype string
  11034. // var is390 int = 0
  11035. // var is310 int = 0
  11036. // var insuplc_admdvs string
  11037. //
  11038. // for _, item := range rf {
  11039. // if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  11040. // insutypes = append(insutypes, item)
  11041. // }
  11042. // }
  11043. //
  11044. // if len(insutypes) == 1 {
  11045. // insutype = insutypes[0].Insutype
  11046. // //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  11047. // } else {
  11048. // for _, i := range insutypes {
  11049. // if i.Insutype == "390" {
  11050. // is390 = 1
  11051. // }
  11052. //
  11053. // if i.Insutype == "310" {
  11054. // is310 = 1
  11055. // }
  11056. // }
  11057. // }
  11058. // if is390 == 1 {
  11059. // insutype = "390"
  11060. // }
  11061. //
  11062. // if is310 == 1 {
  11063. // insutype = "310"
  11064. // }
  11065. // if len(insutypes) == 0 {
  11066. // insutype = "310"
  11067. // }
  11068. // for _, item := range rf {
  11069. // if item.Insutype == insutype {
  11070. // insuplc_admdvs = item.InsuplcAdmdvs
  11071. // }
  11072. // }
  11073. // psn := &models.HisPsn{
  11074. // PsnNo: res.Output.Baseinfo.PsnNo,
  11075. // Age: res.Output.Baseinfo.Age,
  11076. // PatientId: patient.ID,
  11077. // Certno: res.Output.Baseinfo.Certno,
  11078. // Brdy: res.Output.Baseinfo.Brdy,
  11079. // Gend: res.Output.Baseinfo.Gend,
  11080. // Naty: res.Output.Baseinfo.Naty,
  11081. // PsnCertType: res.Output.Baseinfo.PsnCertType,
  11082. // PsnName: res.Output.Baseinfo.PsnName,
  11083. // Idetinfo: idetinfoStr,
  11084. // Insuinfo: infoStr,
  11085. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  11086. // CardInfo: "",
  11087. // VerifyNumber: token,
  11088. // InsuplcAdmdvs: insuplc_admdvs,
  11089. // }
  11090. // service.CreateHisPsn(psn)
  11091. //
  11092. // c.ServeSuccessJSON(map[string]interface{}{
  11093. // "patient": patient,
  11094. // "number": token,
  11095. // })
  11096. // }
  11097. //} else {
  11098. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  11099. // return
  11100. //}
  11101. }
  11102. break
  11103. case 5:
  11104. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  11105. var api string
  11106. if miConfig.MdtrtareaAdmvs == "320921" {
  11107. 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 +
  11108. "&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
  11109. fmt.Println(api)
  11110. } else {
  11111. 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 +
  11112. "&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)
  11113. }
  11114. resp, requestErr := http.Get(api)
  11115. if requestErr != nil {
  11116. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11117. return
  11118. }
  11119. body, ioErr := ioutil.ReadAll(resp.Body)
  11120. if ioErr != nil {
  11121. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11122. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11123. return
  11124. }
  11125. var respJSON map[string]interface{}
  11126. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  11127. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11128. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11129. return
  11130. }
  11131. var status string
  11132. status = respJSON["data"].(map[string]interface{})["status"].(string)
  11133. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  11134. var token string
  11135. var res ResultTwo //1101结果
  11136. var res10265 ResultTwo10265 //1101结果
  11137. if status == "0" { //读卡成功
  11138. var card_info string //卡信息
  11139. //var busi_card_info string
  11140. var auth_info string
  11141. token = respJSON["data"].(map[string]interface{})["token"].(string)
  11142. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  11143. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  11144. auth_info = respJSON["data"].(map[string]interface{})["eletwo"].(string)
  11145. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  11146. result, _ := json.Marshal(respJSON)
  11147. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  11148. utils.ErrorLog("解析失败:%v", err)
  11149. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11150. return
  11151. }
  11152. res.ErrMsg = res10265.ErrMsg
  11153. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  11154. res.Infcode = infocode
  11155. res.Output = res10265.Output
  11156. res.InfRefmsgid = res10265.InfRefmsgid
  11157. if res.Infcode == 0 {
  11158. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  11159. if err == gorm.ErrRecordNotFound {
  11160. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  11161. return
  11162. } else if err != nil {
  11163. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  11164. return
  11165. } else {
  11166. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  11167. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  11168. infoStr := string(Iinfos)
  11169. idetinfoStr := string(Idetinfos)
  11170. b, age, _ := getBirthdateAndAge(res.Output.Baseinfo.Certno)
  11171. psn := &models.HisPsn{
  11172. PsnNo: res.Output.Baseinfo.PsnNo,
  11173. PatientId: patient.ID,
  11174. Certno: res.Output.Baseinfo.Certno,
  11175. Gend: res.Output.Baseinfo.Gend,
  11176. Brdy: b,
  11177. Age: float64(age),
  11178. Naty: res.Output.Baseinfo.Naty,
  11179. PsnCertType: res.Output.Baseinfo.PsnCertType,
  11180. PsnName: res.Output.Baseinfo.PsnName,
  11181. Idetinfo: idetinfoStr,
  11182. Insuinfo: infoStr,
  11183. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  11184. CardInfo: card_info,
  11185. VerifyNumber: token,
  11186. AuthInfo: auth_info,
  11187. }
  11188. var rf []*ResultFive
  11189. json.Unmarshal([]byte(infoStr), &rf)
  11190. var insutypes []*ResultFive
  11191. var insutype string
  11192. var is390 int = 0
  11193. var is310 int = 0
  11194. for _, item := range rf {
  11195. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  11196. insutypes = append(insutypes, item)
  11197. }
  11198. }
  11199. if len(insutypes) == 1 {
  11200. insutype = insutypes[0].Insutype
  11201. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  11202. } else {
  11203. for _, i := range insutypes {
  11204. if i.Insutype == "390" {
  11205. is390 = 1
  11206. }
  11207. if i.Insutype == "310" {
  11208. is310 = 1
  11209. }
  11210. }
  11211. }
  11212. if is390 == 1 {
  11213. insutype = "390"
  11214. }
  11215. if is310 == 1 {
  11216. insutype = "310"
  11217. }
  11218. if len(insutypes) == 0 {
  11219. insutype = "310"
  11220. }
  11221. service.CreateHisPsn(psn)
  11222. c.ServeSuccessJSON(map[string]interface{}{
  11223. "patient": patient,
  11224. "number": token,
  11225. "insutype": insutype,
  11226. })
  11227. }
  11228. } else {
  11229. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  11230. return
  11231. }
  11232. } else { //读卡失败
  11233. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  11234. return
  11235. }
  11236. }
  11237. break
  11238. }
  11239. }
  11240. var initFlag int64 = 0
  11241. var initEleFlag int64 = 0
  11242. func (c *HisApiController) TestGetBasBaseInit() {
  11243. DllDef := syscall.MustLoadDLL("SSCard.dll")
  11244. Iinit := DllDef.MustFindProc("Init")
  11245. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  11246. fmt.Println("http://hosp-sz.gd.hsip.gov.cn/gdyb_api/prd/api/card/initDll")
  11247. ret, _, err := Iinit.Call(StrPtr("http://hosp-sz.gd.hsip.gov.cn/gdyb_api/prd/api/card/initDll"), StrPtr(miConfig.InsuplcAdmdvs))
  11248. if ret != 0 {
  11249. fmt.Println("SSCard的报错原因:", err)
  11250. fmt.Println("SSCard的运算结果为:", ret)
  11251. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  11252. return
  11253. }
  11254. result := int(ret)
  11255. fmt.Println("SSCard的运算结果为1:", result)
  11256. initFlag = 1
  11257. return
  11258. }
  11259. func (c *HisApiController) HandleJiangXiReadCard() {
  11260. fmt.Println("~~~~~~")
  11261. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  11262. admin_user_id, _ := c.GetInt64("admin_user_id")
  11263. id_card_type, _ := c.GetInt64("id_card_type")
  11264. //certificates, _ := c.GetInt64("certificates")
  11265. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  11266. if initFlag == 0 {
  11267. c.TestGetJiangXiBasBaseInit()
  11268. }
  11269. basStr := c.GetBasBaseInfo()
  11270. if len(basStr) == 0 {
  11271. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  11272. return
  11273. }
  11274. fmt.Println(basStr)
  11275. bas := strings.Split(basStr, "|")
  11276. basNumber := bas[1]
  11277. fmt.Println(basNumber)
  11278. card_sn := bas[3]
  11279. fmt.Println(card_sn)
  11280. 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, "")
  11281. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  11282. var dat map[string]interface{}
  11283. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11284. fmt.Println(dat)
  11285. } else {
  11286. fmt.Println(err)
  11287. }
  11288. userJSONBytes, _ := json.Marshal(dat)
  11289. var res ResultTwo
  11290. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11291. utils.ErrorLog("解析失败:%v", err)
  11292. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11293. return
  11294. }
  11295. if res.Infcode == 0 {
  11296. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  11297. if err == gorm.ErrRecordNotFound {
  11298. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  11299. return
  11300. } else if err != nil {
  11301. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  11302. return
  11303. } else {
  11304. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  11305. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  11306. infoStr := string(Iinfos)
  11307. idetinfoStr := string(Idetinfos)
  11308. psn := &models.HisPsn{
  11309. PsnNo: res.Output.Baseinfo.PsnNo,
  11310. PatientId: patient.ID,
  11311. Certno: res.Output.Baseinfo.Certno,
  11312. Gend: res.Output.Baseinfo.Gend,
  11313. Naty: res.Output.Baseinfo.Naty,
  11314. PsnCertType: res.Output.Baseinfo.PsnCertType,
  11315. PsnName: res.Output.Baseinfo.PsnName,
  11316. Idetinfo: idetinfoStr,
  11317. Insuinfo: infoStr,
  11318. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  11319. CardInfo: basStr,
  11320. VerifyNumber: "",
  11321. }
  11322. service.CreateHisPsn(psn)
  11323. c.ServeSuccessJSON(map[string]interface{}{
  11324. "patient": patient,
  11325. "number": basNumber,
  11326. })
  11327. }
  11328. } else {
  11329. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  11330. return
  11331. }
  11332. }
  11333. func (c *HisApiController) TestGetHnBasBaseInit() {
  11334. DllDef := syscall.MustLoadDLL("SSCard.dll")
  11335. Iinit := DllDef.MustFindProc("Init")
  11336. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  11337. //http://10.77.211.236/CSB/hsa-fsi-1303
  11338. ret, _, err := Iinit.Call(StrPtr("http://10.93.32.89:20001/hsa-hgs-adapt/api/card/initDll"), StrPtr("430100|10.93.32.89:20001"))
  11339. if ret != 0 {
  11340. fmt.Println("SSCard的报错原因:", err)
  11341. fmt.Println("SSCard的运算结果为:", ret)
  11342. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  11343. return
  11344. }
  11345. result := int(ret)
  11346. fmt.Println("SSCard的运算结果为1:", result)
  11347. initFlag = 1
  11348. return
  11349. }
  11350. func (c *HisApiController) TestGetJiangXiBasBaseInit() {
  11351. DllDef := syscall.MustLoadDLL("SSCard.dll")
  11352. Iinit := DllDef.MustFindProc("Init")
  11353. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  11354. //http://10.77.211.236/CSB/hsa-fsi-1303
  11355. ret, _, err := Iinit.Call(StrPtr("http://10.77.224.18:9001/1.0.0/agent-card-init"), StrPtr("360302"))
  11356. if ret != 0 {
  11357. fmt.Println("SSCard的报错原因:", err)
  11358. fmt.Println("SSCard的运算结果为:", ret)
  11359. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  11360. return
  11361. }
  11362. result := int(ret)
  11363. fmt.Println("SSCard的运算结果为1:", result)
  11364. initFlag = 1
  11365. return
  11366. }
  11367. func (c *HisApiController) GetSFZBaseInfo() string {
  11368. DllDef := syscall.MustLoadDLL("SSCard.dll")
  11369. readCard := DllDef.MustFindProc("ReadSFZ")
  11370. if readCard == nil {
  11371. fmt.Println("readcard is nil")
  11372. readCard = DllDef.MustFindProc("ReadSFZ")
  11373. }
  11374. str := make([]byte, 8096)
  11375. str1 := make([]byte, 8096)
  11376. r, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(8096), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(8096))
  11377. fmt.Println(r)
  11378. return Remove0000(string(str))
  11379. }
  11380. func (c *HisApiController) GetEleBaseInfo() string {
  11381. DllDef := syscall.MustLoadDLL("SSCard.dll")
  11382. readCard := DllDef.MustFindProc("GetQRBase")
  11383. fmt.Println(readCard)
  11384. if readCard == nil {
  11385. fmt.Println("readcard is nil")
  11386. readCard = DllDef.MustFindProc("GetQRBase")
  11387. }
  11388. str := make([]byte, 1024)
  11389. str1 := make([]byte, 1024)
  11390. ret2, _, _ := readCard.Call(uintptr(180), (uintptr)(unsafe.Pointer(&str[0])), uintptr(1024), (uintptr)(unsafe.Pointer(&str1[0])), uintptr(1024))
  11391. fmt.Println(ret2)
  11392. fmt.Println(string(str1))
  11393. fmt.Println(string(str))
  11394. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  11395. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  11396. if ret2 != 0 {
  11397. return ""
  11398. }
  11399. return string(str)
  11400. }
  11401. func GetHnEleBaseInfo(code string, operator_id int64, operator_name string) (string, string) {
  11402. DllDef := syscall.MustLoadDLL("NationECCode.dll")
  11403. readCard := DllDef.MustFindProc("NationEcTrans")
  11404. fmt.Println(readCard)
  11405. fmt.Println("!!!!!")
  11406. pBusiCardInfo := make([]byte, 2048)
  11407. input := make(map[string]interface{})
  11408. inputData := make(map[string]interface{})
  11409. inputData["orgId"] = code
  11410. inputData["businessType"] = "01101"
  11411. inputData["operatorId"] = "1"
  11412. inputData["operatorName"] = "admin"
  11413. inputData["officeId"] = "001"
  11414. inputData["officeName"] = "血透室"
  11415. inputData["deviceType"] = ""
  11416. input["data"] = inputData
  11417. input["orgId"] = code
  11418. input["transType"] = "ec.query"
  11419. bytesData, _ := json.Marshal(input)
  11420. ret2, _, _ := readCard.Call(StrPtr("https://10.93.32.89:20001/localcfc/api/hsecfc/localQrCodeQuery"), StrPtr(string(bytesData)), (uintptr)(unsafe.Pointer(&pBusiCardInfo[0])))
  11421. fmt.Println(ret2)
  11422. fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  11423. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  11424. return DeleteExtraSpace(""), DeleteExtraSpace(string(pBusiCardInfo))
  11425. }
  11426. func GetgdEleBaseInfo(code string, operator_id int64, operator_name string) (string, string) {
  11427. DllDef := syscall.MustLoadDLL("NationECCode.dll")
  11428. readCard := DllDef.MustFindProc("NationEcTrans")
  11429. fmt.Println(readCard)
  11430. fmt.Println("!!!!!")
  11431. pBusiCardInfo := make([]byte, 2048)
  11432. input := make(map[string]interface{})
  11433. inputData := make(map[string]interface{})
  11434. inputData["orgId"] = code
  11435. inputData["businessType"] = "01101"
  11436. inputData["operatorId"] = "9"
  11437. inputData["operatorName"] = "admin"
  11438. inputData["officeId"] = "001"
  11439. inputData["officeName"] = "血透室"
  11440. inputData["deviceType"] = ""
  11441. input["data"] = inputData
  11442. input["orgId"] = code
  11443. input["transType"] = "ec.query"
  11444. bytesData, _ := json.Marshal(input)
  11445. 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])))
  11446. fmt.Println(ret2)
  11447. fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  11448. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  11449. return DeleteExtraSpace(""), ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8")
  11450. }
  11451. func GetgdEleBaseInfoTwo(code string, operator_id int64, operator_name string) (string, string) {
  11452. DllDef := syscall.MustLoadDLL("NationECCode.dll")
  11453. readCard := DllDef.MustFindProc("NationEcTrans")
  11454. fmt.Println(readCard)
  11455. fmt.Println("!!!!!")
  11456. pBusiCardInfo := make([]byte, 2048)
  11457. input := make(map[string]interface{})
  11458. inputData := make(map[string]interface{})
  11459. inputData["orgId"] = code
  11460. inputData["businessType"] = "01301"
  11461. inputData["operatorId"] = "9"
  11462. inputData["operatorName"] = "admin"
  11463. inputData["officeId"] = "001"
  11464. inputData["officeName"] = "血透室"
  11465. inputData["deviceType"] = ""
  11466. input["data"] = inputData
  11467. input["orgId"] = code
  11468. input["transType"] = "ec.query"
  11469. bytesData, _ := json.Marshal(input)
  11470. 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])))
  11471. fmt.Println(ret2)
  11472. fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  11473. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  11474. return DeleteExtraSpace(""), ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8")
  11475. }
  11476. func GetJxEleBaseInfo(org_id int64) string {
  11477. DllDef := syscall.MustLoadDLL("SSCard.dll")
  11478. readCard := DllDef.MustFindProc("NationEcTrans")
  11479. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  11480. if readCard == nil {
  11481. fmt.Println("readcard is nil")
  11482. readCard = DllDef.MustFindProc("NationEcTrans")
  11483. }
  11484. str1 := make([]byte, 1024)
  11485. data := make(map[string]interface{})
  11486. inputData := make(map[string]interface{})
  11487. inputData["orgId"] = miConfig.Code
  11488. inputData["businessType"] = "01101"
  11489. inputData["operatorId"] = "test001"
  11490. inputData["operatorName"] = "cn"
  11491. inputData["officeId"] = "32760"
  11492. inputData["officeName"] = "waike"
  11493. inputData["deviceType"] = ""
  11494. data["data"] = inputData
  11495. data["transType"] = "ec.query"
  11496. data["extra "] = ""
  11497. data["orgId"] = miConfig.Code
  11498. bytesData, _ := json.Marshal(data)
  11499. //bytesData, _ := json.Marshal(data)
  11500. //bytesData = []byte(ConvertToString(string(bytesData), "utf-8", "gbk"))
  11501. ret2, _, _ := readCard.Call(StrPtr("http://10.77.224.18:9001/1.0.0/localQrCodeQuery"), (uintptr)(unsafe.Pointer(&bytesData[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  11502. fmt.Println(ret2)
  11503. fmt.Println(string(str1))
  11504. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  11505. if ret2 != 0 {
  11506. return ""
  11507. }
  11508. return Remove0000(ConvertToString(string(str1), "gbk", "utf-8"))
  11509. }
  11510. func GetJxEleBaseInitInfo(org_id int64) string {
  11511. DllDef := syscall.MustLoadDLL("SSCard.dll")
  11512. readCard := DllDef.MustFindProc("NationEcTrans")
  11513. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  11514. if readCard == nil {
  11515. fmt.Println("readcard is nil")
  11516. readCard = DllDef.MustFindProc("NationEcTrans")
  11517. }
  11518. str1 := make([]byte, 2048)
  11519. data := make(map[string]interface{})
  11520. inputData := make(map[string]interface{})
  11521. inputData["orgId"] = miConfig.Code
  11522. inputData["businessType"] = "01101"
  11523. inputData["operatorId"] = "1"
  11524. inputData["operatorName"] = "huangchuang"
  11525. inputData["officeId"] = "101"
  11526. inputData["officeName"] = "xuetou"
  11527. inputData["deviceType"] = ""
  11528. data["data"] = inputData
  11529. data["transType"] = "ec.query"
  11530. data["orgId"] = miConfig.Code
  11531. bytesData, _ := json.Marshal(data)
  11532. bytesData = []byte(ConvertToString(string(bytesData), "utf-8", "gbk"))
  11533. ret2, _, _ := readCard.Call(StrPtr("http://10.77.224.18:9001/1.0.0/getEncDynamicKey"), (uintptr)(unsafe.Pointer(&bytesData[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  11534. fmt.Println("http://10.77.224.18:9001/1.0.0/getEncDynamicKey")
  11535. fmt.Println(ret2)
  11536. fmt.Println(string(str1))
  11537. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  11538. if ret2 != 0 {
  11539. return ""
  11540. }
  11541. if len(Remove0000(ConvertToString(string(str1), "gbk", "utf-8"))) > 0 {
  11542. initEleFlag = 1
  11543. }
  11544. return Remove0000(ConvertToString(string(str1), "gbk", "utf-8"))
  11545. }
  11546. //func (c *HisApiController)GetgxBasBaseInfotwo() {
  11547. // // 构建命令
  11548. // cmd := exec.Command("python", "b.py")
  11549. //
  11550. // // 执行命令并等待完成
  11551. // output, err := cmd.CombinedOutput()
  11552. // if err != nil {
  11553. // fmt.Println("Error executing Python script:", err)
  11554. // return
  11555. // }
  11556. //
  11557. // // 打印Python脚本的输出
  11558. // fmt.Println(string(output))
  11559. //}
  11560. func (c *HisApiController) GetgxBasBaseInfo(code string) string {
  11561. DllDef := syscall.MustLoadDLL("yh_interface_xyb.dll")
  11562. readCard := DllDef.MustFindProc("gxyb_call")
  11563. if readCard == nil {
  11564. fmt.Println("readcard is nil")
  11565. readCard = DllDef.MustFindProc("gxyb_call")
  11566. }
  11567. str := make([]byte, 1024)
  11568. str1 := make([]byte, 1024)
  11569. //data := make(map[string]interface{})
  11570. currentTime := time.Now()
  11571. // 格式化时间为 "YYYYMMDDHH24MISS"
  11572. formattedTime := currentTime.Format("20060102150405")
  11573. inputData := make(map[string]interface{})
  11574. inputData2 := make(map[string]interface{})
  11575. inputData["transNo"] = "1401"
  11576. inputData["transType"] = "passwordCheck"
  11577. inputData["timestamp"] = formattedTime
  11578. inputData2["fixmedinsCode"] = code
  11579. inputData2["psnNo"] = ""
  11580. inputData["data"] = inputData2
  11581. jsonBytes, err := json.Marshal(inputData)
  11582. if err != nil {
  11583. fmt.Println("Error encoding map to JSON:", err)
  11584. }
  11585. ret2, _, _ := readCard.Call(StrPtr("1401"), (uintptr)(unsafe.Pointer(&jsonBytes[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  11586. fmt.Println(string(str1))
  11587. fmt.Println(string(str))
  11588. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  11589. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  11590. if ret2 != 0 {
  11591. return ""
  11592. }
  11593. return string(str)
  11594. }
  11595. func (c *HisApiController) GetoleInfo() Response {
  11596. ole.CoInitializeEx(0, ole.COINIT_MULTITHREADED)
  11597. defer ole.CoUninitialize()
  11598. // Replace with the ProgID or CLSID of your COM object
  11599. progID := "YinHai.XJ.Actual.Interface.New"
  11600. // Create COM object
  11601. unknown, err := oleutil.CreateObject(progID)
  11602. if err != nil {
  11603. fmt.Println("Unable to create COM object:", err)
  11604. }
  11605. defer unknown.Release()
  11606. // Query for the IDispatch interface
  11607. dispatch, err := unknown.QueryInterface(ole.IID_IDispatch)
  11608. if err != nil {
  11609. fmt.Println("Unable to get IDispatch interface:", err)
  11610. }
  11611. defer dispatch.Release()
  11612. // Prepare parameters
  11613. transNo := "1401"
  11614. transType := "passwordCheck"
  11615. timestamp := time.Now().Unix()
  11616. fixmedinsCode := "H45072101171"
  11617. psnNo := ""
  11618. data := fmt.Sprintf(`{"transNo":"%s","transType":"%s","timestamp":"%s","data":{"fixmedinsCode":"%s","psnNo":"%s"}}`, transNo, transType, timestamp, fixmedinsCode, psnNo)
  11619. result2 := ""
  11620. // Call COM object's method using the IDispatch interface
  11621. resulr, err := oleutil.CallMethod(dispatch, "gxyb_call", "1401", data, &result2)
  11622. fmt.Println(resulr)
  11623. fmt.Println(result2)
  11624. if err != nil {
  11625. fmt.Println("调用COM对象方法失败:", err)
  11626. }
  11627. var response Response
  11628. err2 := json.Unmarshal([]byte(result2), &response)
  11629. if err2 != nil {
  11630. fmt.Println("解析JSON失败:", err)
  11631. }
  11632. return response
  11633. }
  11634. func (c *HisApiController) GetBasBaseInfo() string {
  11635. DllDef := syscall.MustLoadDLL("SSCard.dll")
  11636. readCard := DllDef.MustFindProc("ReadCardBas")
  11637. if readCard == nil {
  11638. fmt.Println("readcard is nil")
  11639. readCard = DllDef.MustFindProc("ReadCardBas")
  11640. }
  11641. str := make([]byte, 1024)
  11642. str1 := make([]byte, 1024)
  11643. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), uintptr(1024), (uintptr)(unsafe.Pointer(&str1[0])), uintptr(1024))
  11644. fmt.Println(string(str1))
  11645. fmt.Println(string(str))
  11646. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  11647. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  11648. if ret2 != 0 {
  11649. return ""
  11650. }
  11651. return string(str)
  11652. }
  11653. func (c *HisApiController) GetFjBasBaseInfo() (string, string, string, string, string) {
  11654. DllDef := syscall.MustLoadDLL("chs_fjs_standard.dll")
  11655. readCard := DllDef.MustFindProc("read_cardinfo")
  11656. if readCard == nil {
  11657. fmt.Println("readcard is nil")
  11658. readCard = DllDef.MustFindProc("read_cardinfo")
  11659. }
  11660. str := make([]byte, 1024) //卡号
  11661. str1 := make([]byte, 1024) //卡识别码
  11662. str2 := make([]byte, 1024) //身份证号
  11663. str3 := make([]byte, 1024) //姓名
  11664. str4 := make([]byte, 1024) //错误信息
  11665. 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])))
  11666. fmt.Println(string(str1))
  11667. fmt.Println(string(str))
  11668. fmt.Println(string(str2))
  11669. fmt.Println(string(str3))
  11670. fmt.Println(string(str4))
  11671. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  11672. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  11673. fmt.Println(":", ConvertToString(string(str2), "gbk", "utf-8"))
  11674. fmt.Println(":", ConvertToString(string(str3), "gbk", "utf-8"))
  11675. fmt.Println(":", ConvertToString(string(str4), "gbk", "utf-8"))
  11676. if ret2 != 0 {
  11677. return "", "", "", "", ""
  11678. }
  11679. return string(str), string(str1), string(str2), string(str3), string(str4)
  11680. }
  11681. type CustomFundPay struct {
  11682. FundPayType string `json:"fund_pay_type"`
  11683. FundPayamt float64 `json:"fund_payamt"`
  11684. InscpScpAmt float64 `json:"inscp_scp_amt"`
  11685. }
  11686. //func (c *HisApiController) GetBatchSettleList() {
  11687. // start_time_str := c.GetString("start_time")
  11688. // //end_time_str := c.GetString("end_time")
  11689. // admin_user_id, _ := c.GetInt64("admin_user_id")
  11690. //
  11691. // orders,_ := service.GetHisOrderByIDThree(start_time_str)
  11692. //
  11693. // for _, item := range orders {
  11694. // order, _ := service.GetHisOrderByIDTwo(item.ID)
  11695. // roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  11696. // his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  11697. // admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  11698. // curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  11699. // //depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  11700. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  11701. // pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  11702. // doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  11703. //
  11704. // if order.ID == 0 {
  11705. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  11706. // return
  11707. // }
  11708. //
  11709. // //last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  11710. // //max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  11711. // //count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  11712. // //fmt.Println(count)
  11713. // //var zero string
  11714. // //number := count + 1
  11715. // //if number >= 1000 {
  11716. // // zero = "0000" + strconv.FormatInt(number, 10)
  11717. // //} else if number >= 10000 {
  11718. // // zero = "000" + strconv.FormatInt(number, 10)
  11719. // //} else if number >= 100000 {
  11720. // // zero = "00" + strconv.FormatInt(number, 10)
  11721. // //} else if number >= 1000000 {
  11722. // // zero = "0" + strconv.FormatInt(number, 10)
  11723. // //} else {
  11724. // // zero = strconv.FormatInt(number, 10)
  11725. // //}
  11726. // //fmt.Println(zero)
  11727. //
  11728. // struct4101 := service.Struct4101{
  11729. // PsnNo: order.PsnNo,
  11730. // MdtrtId: order.MdtrtId,
  11731. // SetlId: order.SetlId,
  11732. // PsnName: order.PsnName,
  11733. // Gend: order.Gend,
  11734. // Brdy: his.Brdy,
  11735. // Age: his.Age,
  11736. // Naty: order.Naty,
  11737. // PatnCertType: "01",
  11738. // Certno: order.Certno,
  11739. // Prfs: "90",
  11740. // ConerName: roles[0].UserName,
  11741. // PatnRlts: "99",
  11742. // ConerAddr: miConfig.OrgName,
  11743. // ConerTel: admin.Mobile,
  11744. // HiType: order.Insutype,
  11745. // Insuplc: miConfig.InsuplcAdmdvs,
  11746. // MaindiagFlag: "1",
  11747. // BillCode: order.SetlId,
  11748. // BillNo: order.SetlId,
  11749. // BizSn: order.Number,
  11750. // PsnSelfPay: order.PsnPartAmt,
  11751. // PsnOwnPay: order.PsnPartAmt,
  11752. // AcctPay: order.AcctPay,
  11753. // PsnCashpay: order.PsnCashPay,
  11754. // HiPaymtd: "1",
  11755. // Hsorg: miConfig.InsuplcAdmdvs,
  11756. // HsorgOpter: miConfig.InsuplcAdmdvs,
  11757. // MedinsFillPsn: curRoles.UserName,
  11758. // MedinsFillDept: miConfig.OrgName,
  11759. // IptMedType: "2",
  11760. // }
  11761. // struct4101.SetlBegnDate = order.SetlTime
  11762. // struct4101.SetlEndDate = order.SetlTime
  11763. // time_arr := strings.Split(order.SetlTime, " ")
  11764. // struct4101.AdmTime = time_arr[0]
  11765. // struct4101.AdmEndTime = time_arr[0]
  11766. //
  11767. // var rf []CustomFundPay
  11768. // json.Unmarshal([]byte(order.SetlDetail), &rf)
  11769. //
  11770. // var tempFunPays []service.CustomStruct
  11771. // for _, item := range rf {
  11772. // var tempFunPay service.CustomStruct
  11773. // tempFunPay.FundPayamt = item.FundPayamt
  11774. // tempFunPay.FundPayType = item.FundPayType
  11775. // tempFunPays = append(tempFunPays, tempFunPay)
  11776. // }
  11777. // struct4101.CustomStruct = tempFunPays
  11778. //
  11779. // var tempDiaginfos []service.DiaginfoStructTwo
  11780. // var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  11781. // var tempOpspdiseinfos []service.OpspdiseinfoStruct
  11782. //
  11783. // diagnosis_ids := strings.Split(his.Diagnosis, ",")
  11784. // var config []*models.HisXtDiagnoseConfig
  11785. // for _, item := range diagnosis_ids {
  11786. // id, _ := strconv.ParseInt(item, 10, 64)
  11787. // diagnosisConfig, _ := service.FindDiagnoseById(id)
  11788. // config = append(config, &diagnosisConfig)
  11789. // }
  11790. //
  11791. // for index, item := range config {
  11792. // if index == 0 {
  11793. // var tempDiaginfo service.DiaginfoStructTwo
  11794. // tempDiaginfo.DiagCode = item.CountryCode
  11795. // tempDiaginfo.DiagName = item.CountryContentName
  11796. // tempDiaginfo.DiagType = "1"
  11797. // tempDiaginfo.MaindiagFlag = "1"
  11798. // tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  11799. // } else {
  11800. // var tempDiaginfo service.DiaginfoStructTwo
  11801. // tempDiaginfo.DiagCode = item.CountryCode
  11802. // tempDiaginfo.DiagName = item.CountryContentName
  11803. // tempDiaginfo.DiagType = "1"
  11804. // tempDiaginfo.MaindiagFlag = "0"
  11805. // tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  11806. // }
  11807. // }
  11808. // struct4101.Diseinfo = tempDiaginfos
  11809. //
  11810. // sickConfigTwo, _ := service.FindSickById(his.SickType)
  11811. // tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  11812. // tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  11813. // tempOpspdiseinfo2.OprnOprtCode = sickConfigTwo.ContentCode
  11814. // tempOpspdiseinfo2.OprnOprtName = sickConfigTwo.CountryContentName
  11815. // tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  11816. // struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  11817. //
  11818. // var iteminfo service.IteminfoStruct
  11819. //
  11820. // var bedCostTotal float64 = 0 //床位总费
  11821. // var bedCostSelfTotal float64 = 0 //床位自费
  11822. // var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  11823. //
  11824. // var operationCostTotal float64 = 0 //手术费
  11825. // var operationCostSelfTotal float64 = 0 //手术费
  11826. // var operationCostPartSelfTotal float64 = 0 //手术费
  11827. //
  11828. // var otherCostTotal float64 = 0 //其他费用
  11829. // var otherCostSelfTotal float64 = 0 //其他费用
  11830. // var otherCostPartSelfTotal float64 = 0 //其他费用
  11831. //
  11832. // var materialCostTotal float64 = 0 //材料费
  11833. // var materialCostSelfTotal float64 = 0 //材料费
  11834. // var materialCostPartSelfTotal float64 = 0 //材料费
  11835. //
  11836. // var westernMedicineCostTotal float64 = 0 //西药费
  11837. // var westernMedicineCostSelfTotal float64 = 0 //西药费
  11838. // var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  11839. //
  11840. // var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  11841. // var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  11842. // var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  11843. //
  11844. // var checkCostTotal float64 = 0 //检查费
  11845. // var checkCostSelfTotal float64 = 0 //检查费
  11846. // var checkCostPartSelfTotal float64 = 0 //检查费
  11847. //
  11848. // var laboratoryCostTotal float64 = 0 //化验费
  11849. // var laboratoryCostSelfTotal float64 = 0 //化验费
  11850. // var laboratoryCostPartSelfTotal float64 = 0 //化验费
  11851. //
  11852. // var treatCostTotal float64 = 0 //治疗费用
  11853. // var treatCostSelfTotal float64 = 0 //治疗费用
  11854. // var treatCostPartSelfTotal float64 = 0 //治疗费用
  11855. //
  11856. // decimal.DivisionPrecision = 2
  11857. //
  11858. // var bed_fulamt_ownpay_amt float64 = 0
  11859. // var operation_fulamt_ownpay_amt float64 = 0
  11860. // var other_fulamt_ownpay_amt float64 = 0
  11861. // var westernMedicine_fulamt_ownpay_amt float64 = 0
  11862. // var chineseTraditional_fulamt_ownpay_amt float64 = 0
  11863. // var check_fulamt_ownpay_amt float64 = 0
  11864. // var material_fulamt_ownpay_amt float64 = 0
  11865. // var laboratory_fulamt_ownpay_amt float64 = 0
  11866. // var treat_fulamt_ownpay_amt float64 = 0
  11867. //
  11868. // var bed_claa_sunmfee float64 = 0
  11869. // var bed_clab_amt float64 = 0
  11870. // var bed_other_amt float64 = 0
  11871. //
  11872. // var operation_claa_sunmfee float64 = 0
  11873. // var operation_clab_amt float64 = 0
  11874. // var operation_other_amt float64 = 0
  11875. //
  11876. // var other_claa_sunmfee float64 = 0
  11877. // var other_clab_amt float64 = 0
  11878. // var other_other_amt float64 = 0
  11879. //
  11880. // var westernMedicine_claa_sunmfee float64 = 0
  11881. // var westernMedicine_clab_amt float64 = 0
  11882. // var westernMedicine_other_amt float64 = 0
  11883. //
  11884. // var chineseTraditional_claa_sunmfee float64 = 0
  11885. // var chineseTraditional_clab_amt float64 = 0
  11886. // var chineseTraditional_other_amt float64 = 0
  11887. //
  11888. // var check_claa_sunmfee float64 = 0
  11889. // var check_clab_amt float64 = 0
  11890. // var check_other_amt float64 = 0
  11891. //
  11892. // var material_claa_sunmfee float64 = 0
  11893. // var material_clab_amt float64 = 0
  11894. // var material_other_amt float64 = 0
  11895. //
  11896. // var laboratory_claa_sunmfee float64 = 0
  11897. // var laboratory_clab_amt float64 = 0
  11898. // var laboratory_other_amt float64 = 0
  11899. //
  11900. // var treat_claa_sunmfee float64 = 0
  11901. // var treat_clab_amt float64 = 0
  11902. // var treat_other_amt float64 = 0
  11903. //
  11904. // for _, item := range order.HisOrderInfo {
  11905. // if item.MedChrgitmType == "01" { //床位费
  11906. // bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11907. // bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11908. // bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11909. // bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  11910. // if item.ChrgitmLv == "1" {
  11911. // bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11912. // }
  11913. // if item.ChrgitmLv == "2" {
  11914. // bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11915. //
  11916. // }
  11917. // if item.ChrgitmLv == "3" {
  11918. // bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11919. // }
  11920. //
  11921. // }
  11922. //
  11923. // if item.MedChrgitmType == "03" { //检查费
  11924. // checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11925. // checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11926. // checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11927. // check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  11928. // if item.ChrgitmLv == "1" {
  11929. //
  11930. // check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11931. //
  11932. // }
  11933. // if item.ChrgitmLv == "2" {
  11934. // check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11935. //
  11936. // }
  11937. // if item.ChrgitmLv == "3" {
  11938. // check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11939. // }
  11940. // }
  11941. //
  11942. // if item.MedChrgitmType == "04" { //化验费
  11943. // laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11944. // laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11945. // laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11946. // laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  11947. // if item.ChrgitmLv == "1" {
  11948. //
  11949. // laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11950. //
  11951. // }
  11952. // if item.ChrgitmLv == "2" {
  11953. // laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11954. //
  11955. // }
  11956. // if item.ChrgitmLv == "3" {
  11957. // laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11958. // }
  11959. // }
  11960. //
  11961. // if item.MedChrgitmType == "05" { //治疗费
  11962. // treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11963. // treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11964. // treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11965. // treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  11966. // if item.ChrgitmLv == "1" {
  11967. //
  11968. // treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11969. //
  11970. // }
  11971. // if item.ChrgitmLv == "2" {
  11972. // treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11973. //
  11974. // }
  11975. // if item.ChrgitmLv == "3" {
  11976. // treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11977. // }
  11978. // }
  11979. //
  11980. // if item.MedChrgitmType == "06" { //手术费
  11981. // operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11982. // operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11983. // operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11984. // operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  11985. //
  11986. // if item.ChrgitmLv == "1" {
  11987. //
  11988. // operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11989. //
  11990. // }
  11991. // if item.ChrgitmLv == "2" {
  11992. // operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11993. //
  11994. // }
  11995. // if item.ChrgitmLv == "3" {
  11996. // operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11997. // }
  11998. // }
  11999. //
  12000. // if item.MedChrgitmType == "08" { //材料费
  12001. // materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12002. // materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12003. // materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12004. // material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  12005. // if item.ChrgitmLv == "1" {
  12006. //
  12007. // material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12008. //
  12009. // }
  12010. // if item.ChrgitmLv == "2" {
  12011. // material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12012. //
  12013. // }
  12014. // if item.ChrgitmLv == "3" {
  12015. // material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12016. // }
  12017. // }
  12018. //
  12019. // if item.MedChrgitmType == "09" { //西药费
  12020. // westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12021. // westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12022. // westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12023. // westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  12024. // if item.ChrgitmLv == "1" {
  12025. //
  12026. // westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12027. //
  12028. // }
  12029. // if item.ChrgitmLv == "2" {
  12030. // westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12031. //
  12032. // }
  12033. // if item.ChrgitmLv == "3" {
  12034. // westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12035. // }
  12036. // }
  12037. //
  12038. // if item.MedChrgitmType == "11" { //中成费
  12039. // chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12040. // chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12041. // chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12042. // chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  12043. // if item.ChrgitmLv == "1" {
  12044. //
  12045. // chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12046. //
  12047. // }
  12048. // if item.ChrgitmLv == "2" {
  12049. // chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12050. //
  12051. // }
  12052. // if item.ChrgitmLv == "3" {
  12053. // chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12054. // }
  12055. // }
  12056. //
  12057. // if item.MedChrgitmType == "14" { //其他费
  12058. // otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12059. // otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12060. // otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12061. // other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  12062. // if item.ChrgitmLv == "1" {
  12063. // other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12064. //
  12065. // }
  12066. // if item.ChrgitmLv == "2" {
  12067. // other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12068. //
  12069. // }
  12070. // if item.ChrgitmLv == "3" {
  12071. // other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12072. // }
  12073. // }
  12074. //
  12075. // }
  12076. //
  12077. // var iteminfoStructs []service.IteminfoStruct
  12078. //
  12079. // if bedCostTotal != 0 {
  12080. // iteminfo.MedChrgitm = "01"
  12081. // iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  12082. // iteminfo.Amt = bedCostTotal
  12083. // iteminfo.ClaaSumfee = bed_claa_sunmfee
  12084. // iteminfo.ClabAmt = bed_clab_amt
  12085. // iteminfo.OthAmt = bed_other_amt
  12086. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  12087. // }
  12088. //
  12089. // if checkCostTotal != 0 {
  12090. // iteminfo.MedChrgitm = "03"
  12091. // iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  12092. // iteminfo.Amt = checkCostTotal
  12093. // iteminfo.ClaaSumfee = check_claa_sunmfee
  12094. // iteminfo.ClabAmt = check_clab_amt
  12095. // iteminfo.OthAmt = check_other_amt
  12096. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  12097. //
  12098. // }
  12099. //
  12100. // if laboratoryCostTotal != 0 {
  12101. // iteminfo.MedChrgitm = "04"
  12102. // iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  12103. // iteminfo.Amt = laboratoryCostTotal
  12104. // iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  12105. // iteminfo.ClabAmt = laboratory_clab_amt
  12106. // iteminfo.OthAmt = laboratory_other_amt
  12107. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  12108. //
  12109. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  12110. //
  12111. // }
  12112. //
  12113. // if treatCostTotal != 0 {
  12114. // iteminfo.MedChrgitm = "05"
  12115. // iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  12116. // iteminfo.Amt = treatCostTotal
  12117. // iteminfo.ClaaSumfee = treat_claa_sunmfee
  12118. // iteminfo.ClabAmt = treat_clab_amt
  12119. // iteminfo.OthAmt = treat_other_amt
  12120. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  12121. // //(struct4101.IteminfoStruct, iteminfo)
  12122. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  12123. // }
  12124. //
  12125. // if operationCostTotal != 0 {
  12126. // iteminfo.MedChrgitm = "06"
  12127. // iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  12128. // iteminfo.Amt = operationCostTotal
  12129. // iteminfo.ClaaSumfee = operation_claa_sunmfee
  12130. // iteminfo.ClabAmt = operation_clab_amt
  12131. // iteminfo.OthAmt = operation_other_amt
  12132. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  12133. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  12134. // }
  12135. //
  12136. // if materialCostTotal != 0 {
  12137. // iteminfo.MedChrgitm = "08"
  12138. // iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  12139. // iteminfo.Amt = materialCostTotal
  12140. // iteminfo.ClaaSumfee = material_claa_sunmfee
  12141. // iteminfo.ClabAmt = material_clab_amt
  12142. // iteminfo.OthAmt = material_other_amt
  12143. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  12144. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  12145. // }
  12146. //
  12147. // if westernMedicineCostTotal != 0 {
  12148. // iteminfo.MedChrgitm = "09"
  12149. // iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  12150. // iteminfo.Amt = westernMedicineCostTotal
  12151. // iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  12152. // iteminfo.ClabAmt = westernMedicine_clab_amt
  12153. // iteminfo.OthAmt = westernMedicine_other_amt
  12154. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  12155. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  12156. //
  12157. // }
  12158. // if chineseTraditionalMedicineCostTotal != 0 {
  12159. // iteminfo.MedChrgitm = "11"
  12160. // iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  12161. // iteminfo.Amt = westernMedicineCostTotal
  12162. // iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  12163. // iteminfo.ClabAmt = westernMedicine_clab_amt
  12164. // iteminfo.OthAmt = westernMedicine_other_amt
  12165. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  12166. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  12167. //
  12168. // }
  12169. // if otherCostTotal != 0 {
  12170. // iteminfo.MedChrgitm = "14"
  12171. // iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  12172. // iteminfo.Amt = otherCostTotal
  12173. // iteminfo.ClaaSumfee = other_claa_sunmfee
  12174. // iteminfo.ClabAmt = other_clab_amt
  12175. // iteminfo.OthAmt = other_other_amt
  12176. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  12177. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  12178. //
  12179. // }
  12180. // struct4101.IteminfoStruct = iteminfoStructs
  12181. // struct4101.Ntly = "中国"
  12182. // struct4101.AdmCaty = "A03.06"
  12183. //
  12184. // struct4101.DoctorName = doctor.UserName
  12185. // struct4101.DoctorCode = doctor.DoctorNumber
  12186. //
  12187. // var res ResultSeventeen
  12188. //
  12189. // if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  12190. // struct4101.BillCode = order.Number
  12191. // struct4101.BillNo = order.SetlId
  12192. // var resOther ResultSeventeenOther
  12193. // var pp models.PublicParams
  12194. // pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  12195. // pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  12196. // pp.FixmedinsName = miConfig.OrgName
  12197. // pp.FixmedinsCode = miConfig.Code
  12198. // pp.RequestUrl = miConfig.Url
  12199. // pp.Cainfo = miConfig.Cainfo
  12200. // pp.SecretKey = miConfig.SecretKey
  12201. // pp.AccessKey = miConfig.AccessKey
  12202. // pp.OpterName = curRoles.UserName
  12203. //
  12204. // client := &http.Client{}
  12205. // var req *http.Request
  12206. // data := make(map[string]interface{})
  12207. // data["struct4101"] = struct4101
  12208. // data["pp"] = pp
  12209. // bytesData, _ := json.Marshal(data)
  12210. // if miConfig.MdtrtareaAdmvs == "320921" {
  12211. // req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  12212. // } else {
  12213. // req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  12214. // }
  12215. // resp, _ := client.Do(req)
  12216. // defer resp.Body.Close()
  12217. // body, ioErr := ioutil.ReadAll(resp.Body)
  12218. // if ioErr != nil {
  12219. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12220. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12221. // return
  12222. // }
  12223. // var respJSON map[string]interface{}
  12224. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  12225. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12226. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12227. // return
  12228. // }
  12229. //
  12230. // respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  12231. // userJSONBytes, _ := json.Marshal(respJSON)
  12232. // fmt.Println("log")
  12233. // fmt.Println(string(userJSONBytes))
  12234. // if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  12235. // utils.ErrorLog("解析失败:%v", err)
  12236. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12237. // return
  12238. // }
  12239. // res.InfRefmsgid = resOther.InfRefmsgid
  12240. // res.Output = resOther.Output
  12241. // res.ErrMsg = resOther.ErrMsg
  12242. // infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  12243. // res.Infcode = infocode
  12244. // } else if miConfig.MdtrtareaAdmvs == "360302" {
  12245. //
  12246. // var pp models.PublicParams
  12247. // pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  12248. // pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  12249. // pp.FixmedinsName = miConfig.OrgName
  12250. // pp.FixmedinsCode = miConfig.Code
  12251. // pp.RequestUrl = miConfig.Url
  12252. // pp.Cainfo = miConfig.Cainfo
  12253. // pp.SecretKey = miConfig.SecretKey
  12254. // pp.AccessKey = miConfig.AccessKey
  12255. // pp.OpterName = curRoles.UserName
  12256. // result, _ := service.Jxyb4101(struct4101, pp)
  12257. // var dat map[string]interface{}
  12258. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12259. // fmt.Println(dat)
  12260. // } else {
  12261. // fmt.Println(err)
  12262. // }
  12263. // userJSONBytes, _ := json.Marshal(dat)
  12264. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12265. // utils.ErrorLog("解析失败:%v", err)
  12266. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12267. // return
  12268. // }
  12269. //
  12270. // } else if miConfig.MdtrtareaAdmvs == "430800" {
  12271. // var pp models.PublicParams
  12272. // pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  12273. // pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  12274. // pp.FixmedinsName = miConfig.OrgName
  12275. // pp.FixmedinsCode = miConfig.Code
  12276. // pp.RequestUrl = miConfig.Url
  12277. // pp.Cainfo = miConfig.Cainfo
  12278. // pp.SecretKey = miConfig.SecretKey
  12279. // pp.AccessKey = miConfig.AccessKey
  12280. // pp.OpterName = curRoles.UserName
  12281. // result, _ := service.Hnyb4101(struct4101, pp)
  12282. // var dat map[string]interface{}
  12283. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12284. // fmt.Println(dat)
  12285. // } else {
  12286. // fmt.Println(err)
  12287. // }
  12288. // userJSONBytes, _ := json.Marshal(dat)
  12289. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12290. // utils.ErrorLog("解析失败:%v", err)
  12291. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12292. // return
  12293. // }
  12294. //
  12295. // } else if miConfig.MdtrtareaAdmvs == "150499" {
  12296. // var resOther ResultSeventeenOther
  12297. //
  12298. // var pp models.PublicParams
  12299. // pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  12300. // pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  12301. // pp.FixmedinsName = miConfig.OrgName
  12302. // pp.FixmedinsCode = miConfig.Code
  12303. // pp.RequestUrl = miConfig.Url
  12304. // pp.Cainfo = miConfig.Cainfo
  12305. // pp.SecretKey = miConfig.SecretKey
  12306. // pp.AccessKey = miConfig.AccessKey
  12307. // pp.OpterName = curRoles.UserName
  12308. // client := &http.Client{}
  12309. // var req *http.Request
  12310. // data := make(map[string]interface{})
  12311. // data["struct4101"] = struct4101
  12312. // data["pp"] = pp
  12313. // bytesData, _ := json.Marshal(data)
  12314. // req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/4101", bytes.NewReader(bytesData))
  12315. // resp, _ := client.Do(req)
  12316. // defer resp.Body.Close()
  12317. // body, ioErr := ioutil.ReadAll(resp.Body)
  12318. // if ioErr != nil {
  12319. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12320. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12321. // return
  12322. // }
  12323. // var respJSON map[string]interface{}
  12324. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  12325. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12326. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12327. // return
  12328. // }
  12329. //
  12330. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12331. // userJSONBytes, _ := json.Marshal(respJSON)
  12332. // if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  12333. // utils.ErrorLog("解析失败:%v", err)
  12334. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12335. // return
  12336. // }
  12337. // res.InfRefmsgid = resOther.InfRefmsgid
  12338. // res.Output = resOther.Output
  12339. // res.ErrMsg = resOther.ErrMsg
  12340. // infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  12341. // res.Infcode = infocode
  12342. //
  12343. // } else if miConfig.MdtrtareaAdmvs == "350500" {
  12344. // var pp models.PublicParams
  12345. // pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  12346. // pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  12347. // pp.FixmedinsName = miConfig.OrgName
  12348. // pp.FixmedinsCode = miConfig.Code
  12349. // pp.RequestUrl = miConfig.Url
  12350. // pp.Cainfo = miConfig.Cainfo
  12351. // pp.SecretKey = miConfig.SecretKey
  12352. // pp.AccessKey = miConfig.AccessKey
  12353. // pp.OpterName = curRoles.UserName
  12354. // result, requestLog, errMsgLog := service.Fjyb4101(struct4101, pp)
  12355. // fmt.Println(requestLog)
  12356. // fmt.Println(errMsgLog)
  12357. //
  12358. // saveLog(result, requestLog, "4101a", "上传清单")
  12359. //
  12360. // var dat map[string]interface{}
  12361. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12362. // fmt.Println(dat)
  12363. // } else {
  12364. // fmt.Println(err)
  12365. // }
  12366. // userJSONBytes, _ := json.Marshal(dat)
  12367. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12368. // utils.ErrorLog("解析失败:%v", err)
  12369. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12370. // return
  12371. // }
  12372. //
  12373. // } else {
  12374. //
  12375. // result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId)
  12376. // var dat map[string]interface{}
  12377. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12378. // fmt.Println(dat)
  12379. // } else {
  12380. // fmt.Println(err)
  12381. // }
  12382. // userJSONBytes, _ := json.Marshal(dat)
  12383. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12384. // utils.ErrorLog("解析失败:%v", err)
  12385. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12386. // return
  12387. // }
  12388. // }
  12389. //
  12390. // if res.Infcode != 0 {
  12391. // adminUser := c.GetAdminUserInfo()
  12392. // errlog := &models.HisOrderError{
  12393. // UserOrgId: adminUser.CurrentOrgId,
  12394. // Ctime: time.Now().Unix(),
  12395. // Mtime: time.Now().Unix(),
  12396. // ErrMsg: res.ErrMsg,
  12397. // Status: 1,
  12398. // PatientId: order.ID,
  12399. // Stage: 10265,
  12400. // }
  12401. // service.CreateErrMsgLog(errlog)
  12402. // continue
  12403. // } else {
  12404. // //order.FaPiaoNumber = zero
  12405. // //order.FaPiaoCode = last_order.FaPiaoCode
  12406. // //service.UpdateOrder(order)
  12407. // hisFundSettleListResult := &models.HisFundSettleListResult{
  12408. // Number: res.Output.SetlListId,
  12409. // Status: 1,
  12410. // Ctime: time.Now().Unix(),
  12411. // Mtime: time.Now().Unix(),
  12412. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  12413. // IsUpload: 1,
  12414. // OrderId: order.ID,
  12415. // }
  12416. // service.CreateUploadRecord(hisFundSettleListResult)
  12417. // c.ServeSuccessJSON(map[string]interface{}{
  12418. // "msg": "上传成功",
  12419. // "result": hisFundSettleListResult,
  12420. // })
  12421. // continue
  12422. // }
  12423. // }
  12424. //}
  12425. func (c *HisApiController) GetbatchSettleList() {
  12426. //order_id, _ := c.GetInt64("order_id")
  12427. admin_user_id, _ := c.GetInt64("admin_user_id")
  12428. orders, _ := service.GetAllHisOrderTwo10485()
  12429. for _, item := range orders {
  12430. order, _ := service.GetHisOrderByIDTwo(item.ID)
  12431. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  12432. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  12433. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  12434. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  12435. //depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  12436. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  12437. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  12438. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  12439. //last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  12440. //max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  12441. //count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  12442. //fmt.Println(count)
  12443. //var zero string
  12444. //number := count + 1
  12445. //if number >= 1000 {
  12446. // zero = "0000" + strconv.FormatInt(number, 10)
  12447. //} else if number >= 10000 {
  12448. // zero = "000" + strconv.FormatInt(number, 10)
  12449. //} else if number >= 100000 {
  12450. // zero = "00" + strconv.FormatInt(number, 10)
  12451. //} else if number >= 1000000 {
  12452. // zero = "0" + strconv.FormatInt(number, 10)
  12453. //} else {
  12454. // zero = strconv.FormatInt(number, 10)
  12455. //}
  12456. //fmt.Println(zero)
  12457. struct4101 := service.Struct4101{
  12458. PsnNo: order.PsnNo,
  12459. MdtrtId: order.MdtrtId,
  12460. SetlId: order.SetlId,
  12461. PsnName: order.PsnName,
  12462. Gend: order.Gend,
  12463. Brdy: his.Brdy,
  12464. Age: his.Age,
  12465. Naty: order.Naty,
  12466. PatnCertType: "01",
  12467. Certno: order.Certno,
  12468. Prfs: "90",
  12469. ConerName: roles[0].UserName,
  12470. PatnRlts: "99",
  12471. ConerAddr: miConfig.OrgName,
  12472. ConerTel: admin.Mobile,
  12473. HiType: order.Insutype,
  12474. Insuplc: miConfig.InsuplcAdmdvs,
  12475. MaindiagFlag: "1",
  12476. BillCode: order.SetlId,
  12477. BillNo: order.SetlId,
  12478. BizSn: order.Number,
  12479. PsnSelfPay: order.PsnPartAmt,
  12480. PsnOwnPay: order.PsnPartAmt,
  12481. AcctPay: order.AcctPay,
  12482. PsnCashpay: order.PsnCashPay,
  12483. HiPaymtd: "1",
  12484. Hsorg: miConfig.InsuplcAdmdvs,
  12485. HsorgOpter: miConfig.InsuplcAdmdvs,
  12486. MedinsFillPsn: curRoles.UserName,
  12487. MedinsFillDept: miConfig.OrgName,
  12488. IptMedType: "2",
  12489. }
  12490. struct4101.SetlBegnDate = order.SetlTime
  12491. struct4101.SetlEndDate = order.SetlTime
  12492. time_arr := strings.Split(order.SetlTime, " ")
  12493. struct4101.AdmTime = time_arr[0]
  12494. struct4101.AdmEndTime = time_arr[0]
  12495. //var rf []CustomFundPay
  12496. //json.Unmarshal([]byte(order.SetlDetail), &rf)
  12497. //
  12498. //var tempFunPays []service.CustomStruct
  12499. //for _, item := range rf {
  12500. // var tempFunPay service.CustomStruct
  12501. // tempFunPay.FundPayamt = item.FundPayamt
  12502. // tempFunPay.FundPayType = item.FundPayType
  12503. // tempFunPays = append(tempFunPays, tempFunPay)
  12504. //}
  12505. //struct4101.CustomStruct = tempFunPays
  12506. var tempDiaginfos []service.DiaginfoStructTwo
  12507. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  12508. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  12509. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  12510. var config []*models.HisXtDiagnoseConfig
  12511. for _, item := range diagnosis_ids {
  12512. id, _ := strconv.ParseInt(item, 10, 64)
  12513. diagnosisConfig, _ := service.FindDiagnoseById(id)
  12514. config = append(config, &diagnosisConfig)
  12515. }
  12516. for index, item := range config {
  12517. if index == 0 {
  12518. var tempDiaginfo service.DiaginfoStructTwo
  12519. tempDiaginfo.DiagCode = item.CountryCode
  12520. tempDiaginfo.DiagName = item.CountryContentName
  12521. tempDiaginfo.DiagType = "1"
  12522. tempDiaginfo.MaindiagFlag = "1"
  12523. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  12524. } else {
  12525. var tempDiaginfo service.DiaginfoStructTwo
  12526. tempDiaginfo.DiagCode = item.CountryCode
  12527. tempDiaginfo.DiagName = item.CountryContentName
  12528. tempDiaginfo.DiagType = "1"
  12529. tempDiaginfo.MaindiagFlag = "0"
  12530. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  12531. }
  12532. }
  12533. struct4101.Diseinfo = tempDiaginfos
  12534. sickConfigTwo, _ := service.FindSickById(his.SickType)
  12535. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  12536. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  12537. tempOpspdiseinfo2.OprnOprtCode = sickConfigTwo.ContentCode
  12538. tempOpspdiseinfo2.OprnOprtName = sickConfigTwo.CountryContentName
  12539. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  12540. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  12541. var iteminfo service.IteminfoStruct
  12542. var bedCostTotal float64 = 0 //床位总费
  12543. var bedCostSelfTotal float64 = 0 //床位自费
  12544. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  12545. var operationCostTotal float64 = 0 //手术费
  12546. var operationCostSelfTotal float64 = 0 //手术费
  12547. var operationCostPartSelfTotal float64 = 0 //手术费
  12548. var otherCostTotal float64 = 0 //其他费用
  12549. var otherCostSelfTotal float64 = 0 //其他费用
  12550. var otherCostPartSelfTotal float64 = 0 //其他费用
  12551. var materialCostTotal float64 = 0 //材料费
  12552. var materialCostSelfTotal float64 = 0 //材料费
  12553. var materialCostPartSelfTotal float64 = 0 //材料费
  12554. var westernMedicineCostTotal float64 = 0 //西药费
  12555. var westernMedicineCostSelfTotal float64 = 0 //西药费
  12556. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  12557. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  12558. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  12559. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  12560. var checkCostTotal float64 = 0 //检查费
  12561. var checkCostSelfTotal float64 = 0 //检查费
  12562. var checkCostPartSelfTotal float64 = 0 //检查费
  12563. var laboratoryCostTotal float64 = 0 //化验费
  12564. var laboratoryCostSelfTotal float64 = 0 //化验费
  12565. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  12566. var treatCostTotal float64 = 0 //治疗费用
  12567. var treatCostSelfTotal float64 = 0 //治疗费用
  12568. var treatCostPartSelfTotal float64 = 0 //治疗费用
  12569. decimal.DivisionPrecision = 2
  12570. var bed_fulamt_ownpay_amt float64 = 0
  12571. var operation_fulamt_ownpay_amt float64 = 0
  12572. var other_fulamt_ownpay_amt float64 = 0
  12573. var westernMedicine_fulamt_ownpay_amt float64 = 0
  12574. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  12575. var check_fulamt_ownpay_amt float64 = 0
  12576. var material_fulamt_ownpay_amt float64 = 0
  12577. var laboratory_fulamt_ownpay_amt float64 = 0
  12578. var treat_fulamt_ownpay_amt float64 = 0
  12579. var bed_claa_sunmfee float64 = 0
  12580. var bed_clab_amt float64 = 0
  12581. var bed_other_amt float64 = 0
  12582. var operation_claa_sunmfee float64 = 0
  12583. var operation_clab_amt float64 = 0
  12584. var operation_other_amt float64 = 0
  12585. var other_claa_sunmfee float64 = 0
  12586. var other_clab_amt float64 = 0
  12587. var other_other_amt float64 = 0
  12588. var westernMedicine_claa_sunmfee float64 = 0
  12589. var westernMedicine_clab_amt float64 = 0
  12590. var westernMedicine_other_amt float64 = 0
  12591. var chineseTraditional_claa_sunmfee float64 = 0
  12592. var chineseTraditional_clab_amt float64 = 0
  12593. var chineseTraditional_other_amt float64 = 0
  12594. var check_claa_sunmfee float64 = 0
  12595. var check_clab_amt float64 = 0
  12596. var check_other_amt float64 = 0
  12597. var material_claa_sunmfee float64 = 0
  12598. var material_clab_amt float64 = 0
  12599. var material_other_amt float64 = 0
  12600. var laboratory_claa_sunmfee float64 = 0
  12601. var laboratory_clab_amt float64 = 0
  12602. var laboratory_other_amt float64 = 0
  12603. var treat_claa_sunmfee float64 = 0
  12604. var treat_clab_amt float64 = 0
  12605. var treat_other_amt float64 = 0
  12606. for _, item := range order.HisOrderInfo {
  12607. if item.MedChrgitmType == "01" { //床位费
  12608. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12609. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12610. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12611. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  12612. if item.ChrgitmLv == "1" {
  12613. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12614. }
  12615. if item.ChrgitmLv == "2" {
  12616. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12617. }
  12618. if item.ChrgitmLv == "3" {
  12619. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12620. }
  12621. }
  12622. if item.MedChrgitmType == "03" { //检查费
  12623. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12624. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12625. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12626. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  12627. if item.ChrgitmLv == "1" {
  12628. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12629. }
  12630. if item.ChrgitmLv == "2" {
  12631. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12632. }
  12633. if item.ChrgitmLv == "3" {
  12634. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12635. }
  12636. }
  12637. if item.MedChrgitmType == "04" { //化验费
  12638. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12639. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12640. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12641. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  12642. if item.ChrgitmLv == "1" {
  12643. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12644. }
  12645. if item.ChrgitmLv == "2" {
  12646. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12647. }
  12648. if item.ChrgitmLv == "3" {
  12649. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12650. }
  12651. }
  12652. if item.MedChrgitmType == "05" { //治疗费
  12653. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12654. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12655. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12656. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  12657. if item.ChrgitmLv == "1" {
  12658. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12659. }
  12660. if item.ChrgitmLv == "2" {
  12661. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12662. }
  12663. if item.ChrgitmLv == "3" {
  12664. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12665. }
  12666. }
  12667. if item.MedChrgitmType == "06" { //手术费
  12668. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12669. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12670. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12671. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  12672. if item.ChrgitmLv == "1" {
  12673. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12674. }
  12675. if item.ChrgitmLv == "2" {
  12676. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12677. }
  12678. if item.ChrgitmLv == "3" {
  12679. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12680. }
  12681. }
  12682. if item.MedChrgitmType == "08" { //材料费
  12683. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12684. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12685. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12686. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  12687. if item.ChrgitmLv == "1" {
  12688. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12689. }
  12690. if item.ChrgitmLv == "2" {
  12691. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12692. }
  12693. if item.ChrgitmLv == "3" {
  12694. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12695. }
  12696. }
  12697. if item.MedChrgitmType == "09" { //西药费
  12698. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12699. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12700. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12701. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  12702. if item.ChrgitmLv == "1" {
  12703. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12704. }
  12705. if item.ChrgitmLv == "2" {
  12706. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12707. }
  12708. if item.ChrgitmLv == "3" {
  12709. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12710. }
  12711. }
  12712. if item.MedChrgitmType == "11" { //中成费
  12713. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12714. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12715. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12716. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  12717. if item.ChrgitmLv == "1" {
  12718. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12719. }
  12720. if item.ChrgitmLv == "2" {
  12721. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12722. }
  12723. if item.ChrgitmLv == "3" {
  12724. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12725. }
  12726. }
  12727. if item.MedChrgitmType == "14" { //其他费
  12728. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12729. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12730. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12731. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  12732. if item.ChrgitmLv == "1" {
  12733. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12734. }
  12735. if item.ChrgitmLv == "2" {
  12736. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12737. }
  12738. if item.ChrgitmLv == "3" {
  12739. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12740. }
  12741. }
  12742. }
  12743. var iteminfoStructs []service.IteminfoStruct
  12744. if bedCostTotal != 0 {
  12745. iteminfo.MedChrgitm = "01"
  12746. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  12747. iteminfo.Amt = bedCostTotal
  12748. iteminfo.ClaaSumfee = bed_claa_sunmfee
  12749. iteminfo.ClabAmt = bed_clab_amt
  12750. iteminfo.OthAmt = bed_other_amt
  12751. iteminfoStructs = append(iteminfoStructs, iteminfo)
  12752. }
  12753. if checkCostTotal != 0 {
  12754. iteminfo.MedChrgitm = "03"
  12755. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  12756. iteminfo.Amt = checkCostTotal
  12757. iteminfo.ClaaSumfee = check_claa_sunmfee
  12758. iteminfo.ClabAmt = check_clab_amt
  12759. iteminfo.OthAmt = check_other_amt
  12760. iteminfoStructs = append(iteminfoStructs, iteminfo)
  12761. }
  12762. if laboratoryCostTotal != 0 {
  12763. iteminfo.MedChrgitm = "04"
  12764. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  12765. iteminfo.Amt = laboratoryCostTotal
  12766. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  12767. iteminfo.ClabAmt = laboratory_clab_amt
  12768. iteminfo.OthAmt = laboratory_other_amt
  12769. iteminfoStructs = append(iteminfoStructs, iteminfo)
  12770. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  12771. }
  12772. if treatCostTotal != 0 {
  12773. iteminfo.MedChrgitm = "05"
  12774. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  12775. iteminfo.Amt = treatCostTotal
  12776. iteminfo.ClaaSumfee = treat_claa_sunmfee
  12777. iteminfo.ClabAmt = treat_clab_amt
  12778. iteminfo.OthAmt = treat_other_amt
  12779. iteminfoStructs = append(iteminfoStructs, iteminfo)
  12780. //(struct4101.IteminfoStruct, iteminfo)
  12781. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  12782. }
  12783. if operationCostTotal != 0 {
  12784. iteminfo.MedChrgitm = "06"
  12785. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  12786. iteminfo.Amt = operationCostTotal
  12787. iteminfo.ClaaSumfee = operation_claa_sunmfee
  12788. iteminfo.ClabAmt = operation_clab_amt
  12789. iteminfo.OthAmt = operation_other_amt
  12790. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  12791. iteminfoStructs = append(iteminfoStructs, iteminfo)
  12792. }
  12793. if materialCostTotal != 0 {
  12794. iteminfo.MedChrgitm = "08"
  12795. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  12796. iteminfo.Amt = materialCostTotal
  12797. iteminfo.ClaaSumfee = material_claa_sunmfee
  12798. iteminfo.ClabAmt = material_clab_amt
  12799. iteminfo.OthAmt = material_other_amt
  12800. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  12801. iteminfoStructs = append(iteminfoStructs, iteminfo)
  12802. }
  12803. if westernMedicineCostTotal != 0 {
  12804. iteminfo.MedChrgitm = "09"
  12805. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  12806. iteminfo.Amt = westernMedicineCostTotal
  12807. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  12808. iteminfo.ClabAmt = westernMedicine_clab_amt
  12809. iteminfo.OthAmt = westernMedicine_other_amt
  12810. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  12811. iteminfoStructs = append(iteminfoStructs, iteminfo)
  12812. }
  12813. if chineseTraditionalMedicineCostTotal != 0 {
  12814. iteminfo.MedChrgitm = "11"
  12815. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  12816. iteminfo.Amt = westernMedicineCostTotal
  12817. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  12818. iteminfo.ClabAmt = westernMedicine_clab_amt
  12819. iteminfo.OthAmt = westernMedicine_other_amt
  12820. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  12821. iteminfoStructs = append(iteminfoStructs, iteminfo)
  12822. }
  12823. if otherCostTotal != 0 {
  12824. iteminfo.MedChrgitm = "14"
  12825. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  12826. iteminfo.Amt = otherCostTotal
  12827. iteminfo.ClaaSumfee = other_claa_sunmfee
  12828. iteminfo.ClabAmt = other_clab_amt
  12829. iteminfo.OthAmt = other_other_amt
  12830. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  12831. iteminfoStructs = append(iteminfoStructs, iteminfo)
  12832. }
  12833. struct4101.IteminfoStruct = iteminfoStructs
  12834. struct4101.Ntly = "中国"
  12835. struct4101.AdmCaty = "A03.06"
  12836. struct4101.DoctorName = doctor.UserName
  12837. struct4101.DoctorCode = doctor.DoctorNumber
  12838. var res ResultSeventeen
  12839. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  12840. struct4101.BillCode = order.Number
  12841. struct4101.BillNo = order.SetlId
  12842. var resOther ResultSeventeenOther
  12843. var pp models.PublicParams
  12844. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  12845. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  12846. pp.FixmedinsName = miConfig.OrgName
  12847. pp.FixmedinsCode = miConfig.Code
  12848. pp.RequestUrl = miConfig.Url
  12849. pp.Cainfo = miConfig.Cainfo
  12850. pp.SecretKey = miConfig.SecretKey
  12851. pp.AccessKey = miConfig.AccessKey
  12852. pp.OpterName = curRoles.UserName
  12853. client := &http.Client{}
  12854. var req *http.Request
  12855. data := make(map[string]interface{})
  12856. data["struct4101"] = struct4101
  12857. data["pp"] = pp
  12858. bytesData, _ := json.Marshal(data)
  12859. if miConfig.MdtrtareaAdmvs == "320921" {
  12860. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  12861. } else {
  12862. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  12863. }
  12864. resp, _ := client.Do(req)
  12865. defer resp.Body.Close()
  12866. body, ioErr := ioutil.ReadAll(resp.Body)
  12867. if ioErr != nil {
  12868. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12869. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12870. return
  12871. }
  12872. var respJSON map[string]interface{}
  12873. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  12874. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12875. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12876. return
  12877. }
  12878. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  12879. userJSONBytes, _ := json.Marshal(respJSON)
  12880. fmt.Println("log")
  12881. fmt.Println(string(userJSONBytes))
  12882. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  12883. utils.ErrorLog("解析失败:%v", err)
  12884. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12885. return
  12886. }
  12887. res.InfRefmsgid = resOther.InfRefmsgid
  12888. res.Output = resOther.Output
  12889. res.ErrMsg = resOther.ErrMsg
  12890. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  12891. res.Infcode = infocode
  12892. } else if miConfig.MdtrtareaAdmvs == "360302" {
  12893. var pp models.PublicParams
  12894. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  12895. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  12896. pp.FixmedinsName = miConfig.OrgName
  12897. pp.FixmedinsCode = miConfig.Code
  12898. pp.RequestUrl = miConfig.Url
  12899. pp.Cainfo = miConfig.Cainfo
  12900. pp.SecretKey = miConfig.SecretKey
  12901. pp.AccessKey = miConfig.AccessKey
  12902. pp.OpterName = curRoles.UserName
  12903. result, _ := service.Jxyb4101(struct4101, pp)
  12904. var dat map[string]interface{}
  12905. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12906. fmt.Println(dat)
  12907. } else {
  12908. fmt.Println(err)
  12909. }
  12910. userJSONBytes, _ := json.Marshal(dat)
  12911. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12912. utils.ErrorLog("解析失败:%v", err)
  12913. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12914. return
  12915. }
  12916. } else if miConfig.MdtrtareaAdmvs == "430800" {
  12917. var pp models.PublicParams
  12918. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  12919. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  12920. pp.FixmedinsName = miConfig.OrgName
  12921. pp.FixmedinsCode = miConfig.Code
  12922. pp.RequestUrl = miConfig.Url
  12923. pp.Cainfo = miConfig.Cainfo
  12924. pp.SecretKey = miConfig.SecretKey
  12925. pp.AccessKey = miConfig.AccessKey
  12926. pp.OpterName = curRoles.UserName
  12927. result, _ := service.Hnyb4101(struct4101, pp)
  12928. var dat map[string]interface{}
  12929. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12930. fmt.Println(dat)
  12931. } else {
  12932. fmt.Println(err)
  12933. }
  12934. userJSONBytes, _ := json.Marshal(dat)
  12935. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12936. utils.ErrorLog("解析失败:%v", err)
  12937. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12938. return
  12939. }
  12940. } else if miConfig.MdtrtareaAdmvs == "150499" {
  12941. var resOther ResultSeventeenOther
  12942. var pp models.PublicParams
  12943. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  12944. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  12945. pp.FixmedinsName = miConfig.OrgName
  12946. pp.FixmedinsCode = miConfig.Code
  12947. pp.RequestUrl = miConfig.Url
  12948. pp.Cainfo = miConfig.Cainfo
  12949. pp.SecretKey = miConfig.SecretKey
  12950. pp.AccessKey = miConfig.AccessKey
  12951. pp.OpterName = curRoles.UserName
  12952. client := &http.Client{}
  12953. var req *http.Request
  12954. data := make(map[string]interface{})
  12955. data["struct4101"] = struct4101
  12956. data["pp"] = pp
  12957. bytesData, _ := json.Marshal(data)
  12958. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/4101", bytes.NewReader(bytesData))
  12959. resp, _ := client.Do(req)
  12960. defer resp.Body.Close()
  12961. body, ioErr := ioutil.ReadAll(resp.Body)
  12962. if ioErr != nil {
  12963. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12964. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12965. return
  12966. }
  12967. var respJSON map[string]interface{}
  12968. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  12969. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12970. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12971. return
  12972. }
  12973. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12974. userJSONBytes, _ := json.Marshal(respJSON)
  12975. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  12976. utils.ErrorLog("解析失败:%v", err)
  12977. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12978. return
  12979. }
  12980. res.InfRefmsgid = resOther.InfRefmsgid
  12981. res.Output = resOther.Output
  12982. res.ErrMsg = resOther.ErrMsg
  12983. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  12984. res.Infcode = infocode
  12985. } else if miConfig.MdtrtareaAdmvs == "350500" {
  12986. var pp models.PublicParams
  12987. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  12988. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  12989. pp.FixmedinsName = miConfig.OrgName
  12990. pp.FixmedinsCode = miConfig.Code
  12991. pp.RequestUrl = miConfig.Url
  12992. pp.Cainfo = miConfig.Cainfo
  12993. pp.SecretKey = miConfig.SecretKey
  12994. pp.AccessKey = miConfig.AccessKey
  12995. pp.OpterName = curRoles.UserName
  12996. result, requestLog, errMsgLog := service.Fjyb4101(struct4101, pp)
  12997. fmt.Println(requestLog)
  12998. fmt.Println(errMsgLog)
  12999. saveLog(result, requestLog, "4101a", "上传清单")
  13000. var dat map[string]interface{}
  13001. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13002. fmt.Println(dat)
  13003. } else {
  13004. fmt.Println(err)
  13005. }
  13006. userJSONBytes, _ := json.Marshal(dat)
  13007. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13008. utils.ErrorLog("解析失败:%v", err)
  13009. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13010. return
  13011. }
  13012. } else if miConfig.MdtrtareaAdmvs == "441799" {
  13013. var pp models.PublicParams
  13014. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  13015. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  13016. pp.FixmedinsName = miConfig.OrgName
  13017. pp.FixmedinsCode = miConfig.Code
  13018. pp.RequestUrl = miConfig.Url
  13019. pp.Cainfo = miConfig.Cainfo
  13020. pp.SecretKey = miConfig.SecretKey
  13021. pp.AccessKey = miConfig.AccessKey
  13022. pp.OpterName = curRoles.UserName
  13023. client := &http.Client{}
  13024. var req *http.Request
  13025. data := make(map[string]interface{})
  13026. data["struct4101"] = struct4101
  13027. data["pp"] = pp
  13028. bytesData, _ := json.Marshal(data)
  13029. req, _ = http.NewRequest("POST", miConfig.Url+"gdyb/4101", bytes.NewReader(bytesData))
  13030. resp, _ := client.Do(req)
  13031. defer resp.Body.Close()
  13032. body, ioErr := ioutil.ReadAll(resp.Body)
  13033. if ioErr != nil {
  13034. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13035. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13036. return
  13037. }
  13038. var respJSON map[string]interface{}
  13039. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  13040. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13041. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13042. return
  13043. }
  13044. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13045. userJSONBytes, _ := json.Marshal(respJSON)
  13046. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13047. utils.ErrorLog("解析失败:%v", err)
  13048. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13049. return
  13050. }
  13051. } else {
  13052. result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId, admin_user_id)
  13053. var dat map[string]interface{}
  13054. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13055. fmt.Println(dat)
  13056. } else {
  13057. fmt.Println(err)
  13058. }
  13059. userJSONBytes, _ := json.Marshal(dat)
  13060. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13061. utils.ErrorLog("解析失败:%v", err)
  13062. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13063. return
  13064. }
  13065. }
  13066. if res.Infcode != 0 {
  13067. errlog := &models.HisOrderError{
  13068. UserOrgId: order.UserOrgId,
  13069. Ctime: time.Now().Unix(),
  13070. Mtime: time.Now().Unix(),
  13071. ErrMsg: res.ErrMsg + "解析失败",
  13072. Status: 1,
  13073. PatientId: order.ID,
  13074. Stage: 10485,
  13075. }
  13076. service.CreateErrMsgLog(errlog)
  13077. continue
  13078. //c.ServeSuccessJSON(map[string]interface{}{
  13079. // "failed_code": -10,
  13080. // "msg": res.ErrMsg,
  13081. //})
  13082. } else {
  13083. //order.FaPiaoNumber = zero
  13084. //order.FaPiaoCode = last_order.FaPiaoCode
  13085. //service.UpdateOrder(order)
  13086. hisFundSettleListResult := &models.HisFundSettleListResult{
  13087. Number: res.Output.SetlListId,
  13088. Status: 1,
  13089. Ctime: time.Now().Unix(),
  13090. Mtime: time.Now().Unix(),
  13091. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13092. IsUpload: 1,
  13093. OrderId: order.ID,
  13094. }
  13095. service.CreateUploadRecord(hisFundSettleListResult)
  13096. continue
  13097. }
  13098. }
  13099. }
  13100. func (c *HisApiController) GetSettleList() {
  13101. order_id, _ := c.GetInt64("order_id")
  13102. admin_user_id, _ := c.GetInt64("admin_user_id")
  13103. order, _ := service.GetHisOrderByIDTwo(order_id)
  13104. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  13105. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  13106. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  13107. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  13108. //depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  13109. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  13110. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  13111. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  13112. if order.ID == 0 {
  13113. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  13114. return
  13115. }
  13116. //last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  13117. //max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  13118. //count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  13119. //fmt.Println(count)
  13120. //var zero string
  13121. //number := count + 1
  13122. //if number >= 1000 {
  13123. // zero = "0000" + strconv.FormatInt(number, 10)
  13124. //} else if number >= 10000 {
  13125. // zero = "000" + strconv.FormatInt(number, 10)
  13126. //} else if number >= 100000 {
  13127. // zero = "00" + strconv.FormatInt(number, 10)
  13128. //} else if number >= 1000000 {
  13129. // zero = "0" + strconv.FormatInt(number, 10)
  13130. //} else {
  13131. // zero = strconv.FormatInt(number, 10)
  13132. //}
  13133. //fmt.Println(zero)
  13134. struct4101 := service.Struct4101{
  13135. PsnNo: order.PsnNo,
  13136. MdtrtId: order.MdtrtId,
  13137. SetlId: order.SetlId,
  13138. PsnName: order.PsnName,
  13139. Gend: order.Gend,
  13140. Brdy: his.Brdy,
  13141. Age: his.Age,
  13142. Naty: order.Naty,
  13143. PatnCertType: "01",
  13144. Certno: order.Certno,
  13145. Prfs: "90",
  13146. ConerName: roles[0].UserName,
  13147. PatnRlts: "99",
  13148. ConerAddr: miConfig.OrgName,
  13149. ConerTel: admin.Mobile,
  13150. HiType: order.Insutype,
  13151. Insuplc: miConfig.InsuplcAdmdvs,
  13152. MaindiagFlag: "1",
  13153. BillCode: order.SetlId,
  13154. BillNo: order.SetlId,
  13155. BizSn: order.Number,
  13156. PsnSelfPay: order.PsnPartAmt,
  13157. PsnOwnPay: order.PsnPartAmt,
  13158. AcctPay: order.AcctPay,
  13159. PsnCashpay: order.PsnCashPay,
  13160. HiPaymtd: "1",
  13161. Hsorg: miConfig.InsuplcAdmdvs,
  13162. HsorgOpter: miConfig.InsuplcAdmdvs,
  13163. MedinsFillPsn: curRoles.UserName,
  13164. MedinsFillDept: miConfig.OrgName,
  13165. IptMedType: "2",
  13166. }
  13167. struct4101.SetlBegnDate = order.SetlTime
  13168. struct4101.SetlEndDate = order.SetlTime
  13169. time_arr := strings.Split(order.SetlTime, " ")
  13170. struct4101.AdmTime = time_arr[0]
  13171. struct4101.AdmEndTime = time_arr[0]
  13172. //
  13173. //var rf []CustomFundPay
  13174. //json.Unmarshal([]byte(order.SetlDetail), &rf)
  13175. //
  13176. //var tempFunPays []service.CustomStruct
  13177. //for _, item := range rf {
  13178. // var tempFunPay service.CustomStruct
  13179. // tempFunPay.FundPayamt = item.FundPayamt
  13180. // tempFunPay.FundPayType = item.FundPayType
  13181. // tempFunPays = append(tempFunPays, tempFunPay)
  13182. //}
  13183. //struct4101.CustomStruct = tempFunPays
  13184. var tempDiaginfos []service.DiaginfoStructTwo
  13185. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  13186. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  13187. diagnosis_ids := strings.Split(order.Diagnosis, ",")
  13188. var config []*models.HisXtDiagnoseConfig
  13189. for _, item := range diagnosis_ids {
  13190. id, _ := strconv.ParseInt(item, 10, 64)
  13191. diagnosisConfig, _ := service.FindDiagnoseById(id)
  13192. config = append(config, &diagnosisConfig)
  13193. }
  13194. if miConfig.Code == "H15049901371" {
  13195. //for _, item := range config {
  13196. // if item.ID == 138 {
  13197. diagnosisConfig, _ := service.FindDiagnoseById(138)
  13198. var tempDiaginfo service.DiaginfoStructTwo
  13199. tempDiaginfo.DiagCode = diagnosisConfig.CountryCode
  13200. tempDiaginfo.DiagName = diagnosisConfig.CountryContentName
  13201. tempDiaginfo.DiagType = "1"
  13202. tempDiaginfo.MaindiagFlag = "1"
  13203. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  13204. //}
  13205. //}
  13206. for _, item := range config {
  13207. if item.ID != 138 {
  13208. var tempDiaginfo service.DiaginfoStructTwo
  13209. tempDiaginfo.DiagCode = item.CountryCode
  13210. tempDiaginfo.DiagName = item.CountryContentName
  13211. tempDiaginfo.DiagType = "1"
  13212. tempDiaginfo.MaindiagFlag = "0"
  13213. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  13214. }
  13215. }
  13216. } else {
  13217. for index, item := range config {
  13218. if index == 0 {
  13219. var tempDiaginfo service.DiaginfoStructTwo
  13220. tempDiaginfo.DiagCode = item.CountryCode
  13221. tempDiaginfo.DiagName = item.CountryContentName
  13222. tempDiaginfo.DiagType = "1"
  13223. tempDiaginfo.MaindiagFlag = "1"
  13224. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  13225. } else {
  13226. var tempDiaginfo service.DiaginfoStructTwo
  13227. tempDiaginfo.DiagCode = item.CountryCode
  13228. tempDiaginfo.DiagName = item.CountryContentName
  13229. tempDiaginfo.DiagType = "1"
  13230. tempDiaginfo.MaindiagFlag = "0"
  13231. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  13232. }
  13233. }
  13234. }
  13235. struct4101.Diseinfo = tempDiaginfos
  13236. sickConfigTwo, _ := service.FindSickById(his.SickType)
  13237. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  13238. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  13239. tempOpspdiseinfo2.OprnOprtCode = sickConfigTwo.ContentCode
  13240. tempOpspdiseinfo2.OprnOprtName = sickConfigTwo.CountryContentName
  13241. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  13242. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  13243. var iteminfo service.IteminfoStruct
  13244. var bedCostTotal float64 = 0 //床位总费
  13245. var bedCostSelfTotal float64 = 0 //床位自费
  13246. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  13247. var operationCostTotal float64 = 0 //手术费
  13248. var operationCostSelfTotal float64 = 0 //手术费
  13249. var operationCostPartSelfTotal float64 = 0 //手术费
  13250. var otherCostTotal float64 = 0 //其他费用
  13251. var otherCostSelfTotal float64 = 0 //其他费用
  13252. var otherCostPartSelfTotal float64 = 0 //其他费用
  13253. var materialCostTotal float64 = 0 //材料费
  13254. var materialCostSelfTotal float64 = 0 //材料费
  13255. var materialCostPartSelfTotal float64 = 0 //材料费
  13256. var westernMedicineCostTotal float64 = 0 //西药费
  13257. var westernMedicineCostSelfTotal float64 = 0 //西药费
  13258. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  13259. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  13260. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  13261. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  13262. var checkCostTotal float64 = 0 //检查费
  13263. var checkCostSelfTotal float64 = 0 //检查费
  13264. var checkCostPartSelfTotal float64 = 0 //检查费
  13265. var laboratoryCostTotal float64 = 0 //化验费
  13266. var laboratoryCostSelfTotal float64 = 0 //化验费
  13267. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  13268. var treatCostTotal float64 = 0 //治疗费用
  13269. var treatCostSelfTotal float64 = 0 //治疗费用
  13270. var treatCostPartSelfTotal float64 = 0 //治疗费用
  13271. decimal.DivisionPrecision = 2
  13272. var bed_fulamt_ownpay_amt float64 = 0
  13273. var operation_fulamt_ownpay_amt float64 = 0
  13274. var other_fulamt_ownpay_amt float64 = 0
  13275. var westernMedicine_fulamt_ownpay_amt float64 = 0
  13276. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  13277. var check_fulamt_ownpay_amt float64 = 0
  13278. var material_fulamt_ownpay_amt float64 = 0
  13279. var laboratory_fulamt_ownpay_amt float64 = 0
  13280. var treat_fulamt_ownpay_amt float64 = 0
  13281. var bed_claa_sunmfee float64 = 0
  13282. var bed_clab_amt float64 = 0
  13283. var bed_other_amt float64 = 0
  13284. var operation_claa_sunmfee float64 = 0
  13285. var operation_clab_amt float64 = 0
  13286. var operation_other_amt float64 = 0
  13287. var other_claa_sunmfee float64 = 0
  13288. var other_clab_amt float64 = 0
  13289. var other_other_amt float64 = 0
  13290. var westernMedicine_claa_sunmfee float64 = 0
  13291. var westernMedicine_clab_amt float64 = 0
  13292. var westernMedicine_other_amt float64 = 0
  13293. var chineseTraditional_claa_sunmfee float64 = 0
  13294. var chineseTraditional_clab_amt float64 = 0
  13295. var chineseTraditional_other_amt float64 = 0
  13296. var check_claa_sunmfee float64 = 0
  13297. var check_clab_amt float64 = 0
  13298. var check_other_amt float64 = 0
  13299. var material_claa_sunmfee float64 = 0
  13300. var material_clab_amt float64 = 0
  13301. var material_other_amt float64 = 0
  13302. var laboratory_claa_sunmfee float64 = 0
  13303. var laboratory_clab_amt float64 = 0
  13304. var laboratory_other_amt float64 = 0
  13305. var treat_claa_sunmfee float64 = 0
  13306. var treat_clab_amt float64 = 0
  13307. var treat_other_amt float64 = 0
  13308. for _, item := range order.HisOrderInfo {
  13309. if item.MedChrgitmType == "01" { //床位费
  13310. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13311. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13312. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13313. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  13314. if item.ChrgitmLv == "1" {
  13315. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13316. }
  13317. if item.ChrgitmLv == "2" {
  13318. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13319. }
  13320. if item.ChrgitmLv == "3" {
  13321. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13322. }
  13323. }
  13324. if item.MedChrgitmType == "03" { //检查费
  13325. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13326. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13327. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13328. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  13329. if item.ChrgitmLv == "1" {
  13330. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13331. }
  13332. if item.ChrgitmLv == "2" {
  13333. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13334. }
  13335. if item.ChrgitmLv == "3" {
  13336. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13337. }
  13338. }
  13339. if item.MedChrgitmType == "04" { //化验费
  13340. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13341. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13342. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13343. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  13344. if item.ChrgitmLv == "1" {
  13345. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13346. }
  13347. if item.ChrgitmLv == "2" {
  13348. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13349. }
  13350. if item.ChrgitmLv == "3" {
  13351. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13352. }
  13353. }
  13354. if item.MedChrgitmType == "05" { //治疗费
  13355. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13356. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13357. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13358. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  13359. if item.ChrgitmLv == "1" {
  13360. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13361. }
  13362. if item.ChrgitmLv == "2" {
  13363. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13364. }
  13365. if item.ChrgitmLv == "3" {
  13366. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13367. }
  13368. }
  13369. if item.MedChrgitmType == "06" { //手术费
  13370. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13371. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13372. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13373. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  13374. if item.ChrgitmLv == "1" {
  13375. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13376. }
  13377. if item.ChrgitmLv == "2" {
  13378. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13379. }
  13380. if item.ChrgitmLv == "3" {
  13381. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13382. }
  13383. }
  13384. if item.MedChrgitmType == "08" { //材料费
  13385. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13386. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13387. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13388. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  13389. if item.ChrgitmLv == "1" {
  13390. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13391. }
  13392. if item.ChrgitmLv == "2" {
  13393. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13394. }
  13395. if item.ChrgitmLv == "3" {
  13396. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13397. }
  13398. }
  13399. if item.MedChrgitmType == "09" { //西药费
  13400. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13401. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13402. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13403. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  13404. if item.ChrgitmLv == "1" {
  13405. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13406. }
  13407. if item.ChrgitmLv == "2" {
  13408. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13409. }
  13410. if item.ChrgitmLv == "3" {
  13411. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13412. }
  13413. }
  13414. if item.MedChrgitmType == "11" { //中成费
  13415. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13416. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13417. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13418. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  13419. if item.ChrgitmLv == "1" {
  13420. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13421. }
  13422. if item.ChrgitmLv == "2" {
  13423. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13424. }
  13425. if item.ChrgitmLv == "3" {
  13426. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13427. }
  13428. }
  13429. if item.MedChrgitmType == "14" { //其他费
  13430. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13431. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13432. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13433. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  13434. if item.ChrgitmLv == "1" {
  13435. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13436. }
  13437. if item.ChrgitmLv == "2" {
  13438. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13439. }
  13440. if item.ChrgitmLv == "3" {
  13441. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13442. }
  13443. }
  13444. }
  13445. var iteminfoStructs []service.IteminfoStruct
  13446. if bedCostTotal != 0 {
  13447. iteminfo.MedChrgitm = "01"
  13448. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  13449. iteminfo.Amt = bedCostTotal
  13450. iteminfo.ClaaSumfee = bed_claa_sunmfee
  13451. iteminfo.ClabAmt = bed_clab_amt
  13452. iteminfo.OthAmt = bed_other_amt
  13453. iteminfoStructs = append(iteminfoStructs, iteminfo)
  13454. }
  13455. if checkCostTotal != 0 {
  13456. iteminfo.MedChrgitm = "03"
  13457. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  13458. iteminfo.Amt = checkCostTotal
  13459. iteminfo.ClaaSumfee = check_claa_sunmfee
  13460. iteminfo.ClabAmt = check_clab_amt
  13461. iteminfo.OthAmt = check_other_amt
  13462. iteminfoStructs = append(iteminfoStructs, iteminfo)
  13463. }
  13464. if laboratoryCostTotal != 0 {
  13465. iteminfo.MedChrgitm = "04"
  13466. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  13467. iteminfo.Amt = laboratoryCostTotal
  13468. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  13469. iteminfo.ClabAmt = laboratory_clab_amt
  13470. iteminfo.OthAmt = laboratory_other_amt
  13471. iteminfoStructs = append(iteminfoStructs, iteminfo)
  13472. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  13473. }
  13474. if treatCostTotal != 0 {
  13475. iteminfo.MedChrgitm = "05"
  13476. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  13477. iteminfo.Amt = treatCostTotal
  13478. iteminfo.ClaaSumfee = treat_claa_sunmfee
  13479. iteminfo.ClabAmt = treat_clab_amt
  13480. iteminfo.OthAmt = treat_other_amt
  13481. iteminfoStructs = append(iteminfoStructs, iteminfo)
  13482. //(struct4101.IteminfoStruct, iteminfo)
  13483. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  13484. }
  13485. if operationCostTotal != 0 {
  13486. iteminfo.MedChrgitm = "06"
  13487. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  13488. iteminfo.Amt = operationCostTotal
  13489. iteminfo.ClaaSumfee = operation_claa_sunmfee
  13490. iteminfo.ClabAmt = operation_clab_amt
  13491. iteminfo.OthAmt = operation_other_amt
  13492. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  13493. iteminfoStructs = append(iteminfoStructs, iteminfo)
  13494. }
  13495. if materialCostTotal != 0 {
  13496. iteminfo.MedChrgitm = "08"
  13497. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  13498. iteminfo.Amt = materialCostTotal
  13499. iteminfo.ClaaSumfee = material_claa_sunmfee
  13500. iteminfo.ClabAmt = material_clab_amt
  13501. iteminfo.OthAmt = material_other_amt
  13502. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  13503. iteminfoStructs = append(iteminfoStructs, iteminfo)
  13504. }
  13505. if westernMedicineCostTotal != 0 {
  13506. iteminfo.MedChrgitm = "09"
  13507. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  13508. iteminfo.Amt = westernMedicineCostTotal
  13509. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  13510. iteminfo.ClabAmt = westernMedicine_clab_amt
  13511. iteminfo.OthAmt = westernMedicine_other_amt
  13512. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  13513. iteminfoStructs = append(iteminfoStructs, iteminfo)
  13514. }
  13515. if chineseTraditionalMedicineCostTotal != 0 {
  13516. iteminfo.MedChrgitm = "11"
  13517. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  13518. iteminfo.Amt = westernMedicineCostTotal
  13519. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  13520. iteminfo.ClabAmt = westernMedicine_clab_amt
  13521. iteminfo.OthAmt = westernMedicine_other_amt
  13522. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  13523. iteminfoStructs = append(iteminfoStructs, iteminfo)
  13524. }
  13525. if otherCostTotal != 0 {
  13526. iteminfo.MedChrgitm = "14"
  13527. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  13528. iteminfo.Amt = otherCostTotal
  13529. iteminfo.ClaaSumfee = other_claa_sunmfee
  13530. iteminfo.ClabAmt = other_clab_amt
  13531. iteminfo.OthAmt = other_other_amt
  13532. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  13533. iteminfoStructs = append(iteminfoStructs, iteminfo)
  13534. }
  13535. struct4101.IteminfoStruct = iteminfoStructs
  13536. struct4101.Ntly = "中国"
  13537. struct4101.AdmCaty = "A03.06"
  13538. struct4101.DoctorName = doctor.UserName
  13539. struct4101.DoctorCode = doctor.DoctorNumber
  13540. var res ResultSeventeen
  13541. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  13542. struct4101.BillCode = order.Number
  13543. struct4101.BillNo = order.SetlId
  13544. var resOther ResultSeventeenOther
  13545. var pp models.PublicParams
  13546. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  13547. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  13548. pp.FixmedinsName = miConfig.OrgName
  13549. pp.FixmedinsCode = miConfig.Code
  13550. pp.RequestUrl = miConfig.Url
  13551. pp.Cainfo = miConfig.Cainfo
  13552. pp.SecretKey = miConfig.SecretKey
  13553. pp.AccessKey = miConfig.AccessKey
  13554. pp.OpterName = curRoles.UserName
  13555. client := &http.Client{}
  13556. var req *http.Request
  13557. data := make(map[string]interface{})
  13558. data["struct4101"] = struct4101
  13559. data["pp"] = pp
  13560. bytesData, _ := json.Marshal(data)
  13561. if miConfig.MdtrtareaAdmvs == "320921" {
  13562. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  13563. } else {
  13564. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  13565. }
  13566. resp, _ := client.Do(req)
  13567. defer resp.Body.Close()
  13568. body, ioErr := ioutil.ReadAll(resp.Body)
  13569. if ioErr != nil {
  13570. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13571. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13572. return
  13573. }
  13574. var respJSON map[string]interface{}
  13575. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  13576. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13577. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13578. return
  13579. }
  13580. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  13581. userJSONBytes, _ := json.Marshal(respJSON)
  13582. fmt.Println("log")
  13583. fmt.Println(string(userJSONBytes))
  13584. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  13585. utils.ErrorLog("解析失败:%v", err)
  13586. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13587. return
  13588. }
  13589. res.InfRefmsgid = resOther.InfRefmsgid
  13590. res.Output = resOther.Output
  13591. res.ErrMsg = resOther.ErrMsg
  13592. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  13593. res.Infcode = infocode
  13594. } else if miConfig.MdtrtareaAdmvs == "360302" {
  13595. var pp models.PublicParams
  13596. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  13597. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  13598. pp.FixmedinsName = miConfig.OrgName
  13599. pp.FixmedinsCode = miConfig.Code
  13600. pp.RequestUrl = miConfig.Url
  13601. pp.Cainfo = miConfig.Cainfo
  13602. pp.SecretKey = miConfig.SecretKey
  13603. pp.AccessKey = miConfig.AccessKey
  13604. pp.OpterName = curRoles.UserName
  13605. result, _ := service.Jxyb4101(struct4101, pp)
  13606. var dat map[string]interface{}
  13607. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13608. fmt.Println(dat)
  13609. } else {
  13610. fmt.Println(err)
  13611. }
  13612. userJSONBytes, _ := json.Marshal(dat)
  13613. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13614. utils.ErrorLog("解析失败:%v", err)
  13615. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13616. return
  13617. }
  13618. } else if miConfig.MdtrtareaAdmvs == "430800" {
  13619. var pp models.PublicParams
  13620. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  13621. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  13622. pp.FixmedinsName = miConfig.OrgName
  13623. pp.FixmedinsCode = miConfig.Code
  13624. pp.RequestUrl = miConfig.Url
  13625. pp.Cainfo = miConfig.Cainfo
  13626. pp.SecretKey = miConfig.SecretKey
  13627. pp.AccessKey = miConfig.AccessKey
  13628. pp.OpterName = curRoles.UserName
  13629. result, _ := service.Hnyb4101(struct4101, pp)
  13630. var dat map[string]interface{}
  13631. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13632. fmt.Println(dat)
  13633. } else {
  13634. fmt.Println(err)
  13635. }
  13636. userJSONBytes, _ := json.Marshal(dat)
  13637. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13638. utils.ErrorLog("解析失败:%v", err)
  13639. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13640. return
  13641. }
  13642. } else if miConfig.MdtrtareaAdmvs == "150499" {
  13643. var resOther ResultSeventeenOther
  13644. var pp models.PublicParams
  13645. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  13646. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  13647. pp.FixmedinsName = miConfig.OrgName
  13648. pp.FixmedinsCode = miConfig.Code
  13649. pp.RequestUrl = miConfig.Url
  13650. pp.Cainfo = miConfig.Cainfo
  13651. pp.SecretKey = miConfig.SecretKey
  13652. pp.AccessKey = miConfig.AccessKey
  13653. pp.OpterName = curRoles.UserName
  13654. client := &http.Client{}
  13655. var req *http.Request
  13656. data := make(map[string]interface{})
  13657. data["struct4101"] = struct4101
  13658. data["pp"] = pp
  13659. bytesData, _ := json.Marshal(data)
  13660. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/4101", bytes.NewReader(bytesData))
  13661. resp, _ := client.Do(req)
  13662. defer resp.Body.Close()
  13663. body, ioErr := ioutil.ReadAll(resp.Body)
  13664. if ioErr != nil {
  13665. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13666. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13667. return
  13668. }
  13669. var respJSON map[string]interface{}
  13670. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  13671. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13672. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13673. return
  13674. }
  13675. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13676. userJSONBytes, _ := json.Marshal(respJSON)
  13677. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  13678. utils.ErrorLog("解析失败:%v", err)
  13679. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13680. return
  13681. }
  13682. res.InfRefmsgid = resOther.InfRefmsgid
  13683. res.Output = resOther.Output
  13684. res.ErrMsg = resOther.ErrMsg
  13685. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  13686. res.Infcode = infocode
  13687. } else if miConfig.MdtrtareaAdmvs == "350500" {
  13688. var pp models.PublicParams
  13689. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  13690. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  13691. pp.FixmedinsName = miConfig.OrgName
  13692. pp.FixmedinsCode = miConfig.Code
  13693. pp.RequestUrl = miConfig.Url
  13694. pp.Cainfo = miConfig.Cainfo
  13695. pp.SecretKey = miConfig.SecretKey
  13696. pp.AccessKey = miConfig.AccessKey
  13697. pp.OpterName = curRoles.UserName
  13698. result, requestLog, errMsgLog := service.Fjyb4101(struct4101, pp)
  13699. fmt.Println(requestLog)
  13700. fmt.Println(errMsgLog)
  13701. saveLog(result, requestLog, "4101a", "上传清单")
  13702. var dat map[string]interface{}
  13703. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13704. fmt.Println(dat)
  13705. } else {
  13706. fmt.Println(err)
  13707. }
  13708. userJSONBytes, _ := json.Marshal(dat)
  13709. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13710. utils.ErrorLog("解析失败:%v", err)
  13711. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13712. return
  13713. }
  13714. } else if miConfig.MdtrtareaAdmvs == "441799" {
  13715. var pp models.PublicParams
  13716. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  13717. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  13718. pp.FixmedinsName = miConfig.OrgName
  13719. pp.FixmedinsCode = miConfig.Code
  13720. pp.RequestUrl = miConfig.Url
  13721. pp.Cainfo = miConfig.Cainfo
  13722. pp.SecretKey = miConfig.SecretKey
  13723. pp.AccessKey = miConfig.AccessKey
  13724. pp.OpterName = curRoles.UserName
  13725. client := &http.Client{}
  13726. var req *http.Request
  13727. data := make(map[string]interface{})
  13728. data["struct4101"] = struct4101
  13729. data["pp"] = pp
  13730. bytesData, _ := json.Marshal(data)
  13731. req, _ = http.NewRequest("POST", miConfig.Url+"gdyb/4101", bytes.NewReader(bytesData))
  13732. resp, _ := client.Do(req)
  13733. defer resp.Body.Close()
  13734. body, ioErr := ioutil.ReadAll(resp.Body)
  13735. if ioErr != nil {
  13736. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13737. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13738. return
  13739. }
  13740. var respJSON map[string]interface{}
  13741. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  13742. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13743. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13744. return
  13745. }
  13746. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13747. userJSONBytes, _ := json.Marshal(respJSON)
  13748. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13749. utils.ErrorLog("解析失败:%v", err)
  13750. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13751. return
  13752. }
  13753. } else {
  13754. result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId, admin_user_id)
  13755. var dat map[string]interface{}
  13756. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13757. fmt.Println(dat)
  13758. } else {
  13759. fmt.Println(err)
  13760. }
  13761. userJSONBytes, _ := json.Marshal(dat)
  13762. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13763. utils.ErrorLog("解析失败:%v", err)
  13764. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13765. return
  13766. }
  13767. }
  13768. if res.Infcode != 0 {
  13769. c.ServeSuccessJSON(map[string]interface{}{
  13770. "failed_code": -10,
  13771. "msg": res.ErrMsg,
  13772. })
  13773. return
  13774. } else {
  13775. //order.FaPiaoNumber = zero
  13776. //order.FaPiaoCode = last_order.FaPiaoCode
  13777. //service.UpdateOrder(order)
  13778. hisFundSettleListResult := &models.HisFundSettleListResult{
  13779. Number: res.Output.SetlListId,
  13780. Status: 1,
  13781. Ctime: time.Now().Unix(),
  13782. Mtime: time.Now().Unix(),
  13783. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13784. IsUpload: 1,
  13785. OrderId: order_id,
  13786. }
  13787. service.CreateUploadRecord(hisFundSettleListResult)
  13788. c.ServeSuccessJSON(map[string]interface{}{
  13789. "msg": "上传成功",
  13790. "result": hisFundSettleListResult,
  13791. })
  13792. return
  13793. }
  13794. }
  13795. func (c *HisApiController) GetSettleListHospital() {
  13796. order_id, _ := c.GetInt64("order_id")
  13797. admin_user_id, _ := c.GetInt64("admin_user_id")
  13798. order, _ := service.GetHisOrderByIDTwo(order_id)
  13799. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  13800. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  13801. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  13802. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  13803. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  13804. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  13805. if order.ID == 0 {
  13806. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  13807. return
  13808. }
  13809. last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  13810. max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  13811. count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  13812. fmt.Println(count)
  13813. var zero string
  13814. number := count + 1
  13815. if number >= 1000 {
  13816. zero = "0000" + strconv.FormatInt(number, 10)
  13817. } else if number >= 10000 {
  13818. zero = "000" + strconv.FormatInt(number, 10)
  13819. } else if number >= 100000 {
  13820. zero = "00" + strconv.FormatInt(number, 10)
  13821. } else if number >= 1000000 {
  13822. zero = "0" + strconv.FormatInt(number, 10)
  13823. } else {
  13824. zero = strconv.FormatInt(number, 10)
  13825. }
  13826. fmt.Println(zero)
  13827. struct4101 := service.Struct4101{
  13828. PsnNo: order.PsnNo,
  13829. MdtrtId: order.MdtrtId,
  13830. SetlId: order.SetlId,
  13831. PsnName: order.PsnName,
  13832. Gend: order.Gend,
  13833. Brdy: his.Brdy,
  13834. Age: int64(order.Age),
  13835. Naty: order.Naty,
  13836. PatnCertType: "01",
  13837. Certno: order.Certno,
  13838. Prfs: "90",
  13839. ConerName: roles[0].UserName,
  13840. PatnRlts: "99",
  13841. ConerAddr: miConfig.OrgName,
  13842. ConerTel: admin.Mobile,
  13843. HiType: order.Insutype,
  13844. Insuplc: miConfig.InsuplcAdmdvs,
  13845. MaindiagFlag: "1",
  13846. BillCode: order.SetlId,
  13847. BillNo: order.SetlId,
  13848. BizSn: order.Number,
  13849. PsnSelfPay: order.PsnPartAmt,
  13850. PsnOwnPay: order.PsnPartAmt,
  13851. AcctPay: order.AcctPay,
  13852. PsnCashpay: order.PsnCashPay,
  13853. HiPaymtd: "1",
  13854. Hsorg: miConfig.InsuplcAdmdvs,
  13855. HsorgOpter: miConfig.InsuplcAdmdvs,
  13856. MedinsFillPsn: curRoles.UserName,
  13857. MedinsFillDept: depart.Name,
  13858. IptMedType: "2",
  13859. AdmTime: his.InHosptialTime,
  13860. AdmEndTime: his.OutHosptialTime,
  13861. }
  13862. struct4101.SetlBegnDate = order.SetlTime
  13863. struct4101.SetlEndDate = order.SetlTime
  13864. //var rf []CustomFundPay
  13865. //json.Unmarshal([]byte(order.SetlDetail), &rf)
  13866. //
  13867. //var tempFunPays []service.CustomStruct
  13868. //for _, item := range rf {
  13869. // var tempFunPay service.CustomStruct
  13870. // tempFunPay.FundPayamt = item.FundPayamt
  13871. // tempFunPay.FundPayType = item.FundPayType
  13872. // tempFunPays = append(tempFunPays, tempFunPay)
  13873. //}
  13874. //struct4101.CustomStruct = tempFunPays
  13875. var tempDiaginfos []service.DiaginfoStructTwo
  13876. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  13877. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  13878. //infos, _ := service.FindLastPatientPrescriptionInfoTwo2(c.GetAdminUserInfo().CurrentOrgId, his.PatientId, strings.Split(his.InHosptialTime, " ")[0], strings.Split(his.OutHosptialTime, " ")[0])
  13879. //for _, item := range infos {
  13880. // his.Diagnosis = his.Diagnosis + "," + item.Diagnosis
  13881. //}
  13882. diagnosis_ids_arr := strings.Split(his.Diagnosis, ",")
  13883. diagnosis_ids_arr = RemoveRepeatedPurviewElement2(diagnosis_ids_arr)
  13884. //diagnosis_ids := strings.Split(his.Diagnosis, ",")
  13885. fmt.Println(diagnosis_ids_arr)
  13886. if order.UserOrgId == 10210 {
  13887. var diagnosis_ids_arr_two []int64
  13888. diagnosis_ids_arr_two = append(diagnosis_ids_arr_two, 704)
  13889. var config []*models.HisXtDiagnoseConfig
  13890. for _, id := range diagnosis_ids_arr_two {
  13891. //id, _ := strconv.ParseInt(item, 10, 64)
  13892. diagnosisConfig, _ := service.FindDiagnoseById(id)
  13893. if diagnosisConfig.ID > 0 {
  13894. config = append(config, &diagnosisConfig)
  13895. }
  13896. }
  13897. for index, item := range config {
  13898. if item.ID > 0 {
  13899. if index == 0 {
  13900. var tempDiaginfo service.DiaginfoStructTwo
  13901. tempDiaginfo.DiagCode = item.CountryCode
  13902. tempDiaginfo.DiagName = item.CountryContentName
  13903. tempDiaginfo.DiagType = "1"
  13904. tempDiaginfo.MaindiagFlag = "1"
  13905. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  13906. } else {
  13907. var tempDiaginfo service.DiaginfoStructTwo
  13908. tempDiaginfo.DiagCode = item.CountryCode
  13909. tempDiaginfo.DiagName = item.CountryContentName
  13910. tempDiaginfo.DiagType = "1"
  13911. tempDiaginfo.MaindiagFlag = "0"
  13912. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  13913. }
  13914. }
  13915. }
  13916. struct4101.Diseinfo = tempDiaginfos
  13917. } else {
  13918. var config []*models.HisXtDiagnoseConfig
  13919. for _, item := range diagnosis_ids_arr {
  13920. id, _ := strconv.ParseInt(item, 10, 64)
  13921. diagnosisConfig, _ := service.FindDiagnoseById(id)
  13922. if diagnosisConfig.ID > 0 {
  13923. config = append(config, &diagnosisConfig)
  13924. }
  13925. }
  13926. for index, item := range config {
  13927. if item.ID > 0 {
  13928. if index == 0 {
  13929. var tempDiaginfo service.DiaginfoStructTwo
  13930. tempDiaginfo.DiagCode = item.CountryCode
  13931. tempDiaginfo.DiagName = item.CountryContentName
  13932. tempDiaginfo.DiagType = "1"
  13933. tempDiaginfo.MaindiagFlag = "1"
  13934. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  13935. } else {
  13936. var tempDiaginfo service.DiaginfoStructTwo
  13937. tempDiaginfo.DiagCode = item.CountryCode
  13938. tempDiaginfo.DiagName = item.CountryContentName
  13939. tempDiaginfo.DiagType = "1"
  13940. tempDiaginfo.MaindiagFlag = "0"
  13941. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  13942. }
  13943. }
  13944. }
  13945. struct4101.Diseinfo = tempDiaginfos
  13946. }
  13947. sickConfigTwo, _ := service.FindSickById(his.SickType)
  13948. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  13949. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  13950. tempOpspdiseinfo2.OprnOprtCode = ""
  13951. tempOpspdiseinfo2.OprnOprtName = ""
  13952. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  13953. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  13954. var iteminfo service.IteminfoStruct
  13955. var bedCostTotal float64 = 0 //床位总费
  13956. var bedCostSelfTotal float64 = 0 //床位自费
  13957. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  13958. var operationCostTotal float64 = 0 //手术费
  13959. var operationCostSelfTotal float64 = 0 //手术费
  13960. var operationCostPartSelfTotal float64 = 0 //手术费
  13961. var otherCostTotal float64 = 0 //其他费用
  13962. var otherCostSelfTotal float64 = 0 //其他费用
  13963. var otherCostPartSelfTotal float64 = 0 //其他费用
  13964. var materialCostTotal float64 = 0 //材料费
  13965. var materialCostSelfTotal float64 = 0 //材料费
  13966. var materialCostPartSelfTotal float64 = 0 //材料费
  13967. var westernMedicineCostTotal float64 = 0 //西药费
  13968. var westernMedicineCostSelfTotal float64 = 0 //西药费
  13969. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  13970. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  13971. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  13972. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  13973. var checkCostTotal float64 = 0 //检查费
  13974. var checkCostSelfTotal float64 = 0 //检查费
  13975. var checkCostPartSelfTotal float64 = 0 //检查费
  13976. var laboratoryCostTotal float64 = 0 //化验费
  13977. var laboratoryCostSelfTotal float64 = 0 //化验费
  13978. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  13979. var treatCostTotal float64 = 0 //治疗费用
  13980. var treatCostSelfTotal float64 = 0 //治疗费用
  13981. var treatCostPartSelfTotal float64 = 0 //治疗费用
  13982. decimal.DivisionPrecision = 2
  13983. var bed_fulamt_ownpay_amt float64 = 0
  13984. var operation_fulamt_ownpay_amt float64 = 0
  13985. var other_fulamt_ownpay_amt float64 = 0
  13986. var westernMedicine_fulamt_ownpay_amt float64 = 0
  13987. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  13988. var check_fulamt_ownpay_amt float64 = 0
  13989. var material_fulamt_ownpay_amt float64 = 0
  13990. var laboratory_fulamt_ownpay_amt float64 = 0
  13991. var treat_fulamt_ownpay_amt float64 = 0
  13992. var bed_claa_sunmfee float64 = 0
  13993. var bed_clab_amt float64 = 0
  13994. var bed_other_amt float64 = 0
  13995. var operation_claa_sunmfee float64 = 0
  13996. var operation_clab_amt float64 = 0
  13997. var operation_other_amt float64 = 0
  13998. var other_claa_sunmfee float64 = 0
  13999. var other_clab_amt float64 = 0
  14000. var other_other_amt float64 = 0
  14001. var westernMedicine_claa_sunmfee float64 = 0
  14002. var westernMedicine_clab_amt float64 = 0
  14003. var westernMedicine_other_amt float64 = 0
  14004. var chineseTraditional_claa_sunmfee float64 = 0
  14005. var chineseTraditional_clab_amt float64 = 0
  14006. var chineseTraditional_other_amt float64 = 0
  14007. var check_claa_sunmfee float64 = 0
  14008. var check_clab_amt float64 = 0
  14009. var check_other_amt float64 = 0
  14010. var material_claa_sunmfee float64 = 0
  14011. var material_clab_amt float64 = 0
  14012. var material_other_amt float64 = 0
  14013. var laboratory_claa_sunmfee float64 = 0
  14014. var laboratory_clab_amt float64 = 0
  14015. var laboratory_other_amt float64 = 0
  14016. var treat_claa_sunmfee float64 = 0
  14017. var treat_clab_amt float64 = 0
  14018. var treat_other_amt float64 = 0
  14019. for _, item := range order.HisOrderInfo {
  14020. if item.MedChrgitmType == "01" { //床位费
  14021. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14022. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14023. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14024. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14025. if item.ChrgitmLv == "1" {
  14026. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14027. }
  14028. if item.ChrgitmLv == "2" {
  14029. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14030. }
  14031. if item.ChrgitmLv == "3" {
  14032. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14033. }
  14034. }
  14035. if item.MedChrgitmType == "03" { //检查费
  14036. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14037. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14038. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14039. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14040. if item.ChrgitmLv == "1" {
  14041. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14042. }
  14043. if item.ChrgitmLv == "2" {
  14044. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14045. }
  14046. if item.ChrgitmLv == "3" {
  14047. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14048. }
  14049. }
  14050. if item.MedChrgitmType == "04" { //化验费
  14051. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14052. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14053. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14054. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14055. if item.ChrgitmLv == "1" {
  14056. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14057. }
  14058. if item.ChrgitmLv == "2" {
  14059. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14060. }
  14061. if item.ChrgitmLv == "3" {
  14062. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14063. }
  14064. }
  14065. if item.MedChrgitmType == "05" { //治疗费
  14066. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14067. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14068. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14069. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14070. if item.ChrgitmLv == "1" {
  14071. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14072. }
  14073. if item.ChrgitmLv == "2" {
  14074. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14075. }
  14076. if item.ChrgitmLv == "3" {
  14077. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14078. }
  14079. }
  14080. if item.MedChrgitmType == "06" { //手术费
  14081. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14082. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14083. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14084. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14085. if item.ChrgitmLv == "1" {
  14086. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14087. }
  14088. if item.ChrgitmLv == "2" {
  14089. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14090. }
  14091. if item.ChrgitmLv == "3" {
  14092. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14093. }
  14094. }
  14095. if item.MedChrgitmType == "08" { //材料费
  14096. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14097. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14098. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14099. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14100. if item.ChrgitmLv == "1" {
  14101. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14102. }
  14103. if item.ChrgitmLv == "2" {
  14104. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14105. }
  14106. if item.ChrgitmLv == "3" {
  14107. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14108. }
  14109. }
  14110. if item.MedChrgitmType == "09" { //西药费
  14111. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14112. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14113. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14114. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14115. if item.ChrgitmLv == "1" {
  14116. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14117. }
  14118. if item.ChrgitmLv == "2" {
  14119. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14120. }
  14121. if item.ChrgitmLv == "3" {
  14122. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14123. }
  14124. }
  14125. if item.MedChrgitmType == "11" { //中成费
  14126. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14127. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14128. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14129. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14130. if item.ChrgitmLv == "1" {
  14131. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14132. }
  14133. if item.ChrgitmLv == "2" {
  14134. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14135. }
  14136. if item.ChrgitmLv == "3" {
  14137. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14138. }
  14139. }
  14140. if item.MedChrgitmType == "14" { //其他费
  14141. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14142. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14143. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14144. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14145. if item.ChrgitmLv == "1" {
  14146. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14147. }
  14148. if item.ChrgitmLv == "2" {
  14149. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14150. }
  14151. if item.ChrgitmLv == "3" {
  14152. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14153. }
  14154. }
  14155. }
  14156. var iteminfoStructs []service.IteminfoStruct
  14157. if bedCostTotal != 0 {
  14158. iteminfo.MedChrgitm = "01"
  14159. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  14160. iteminfo.Amt = bedCostTotal
  14161. iteminfo.ClaaSumfee = bed_claa_sunmfee
  14162. iteminfo.ClabAmt = bed_clab_amt
  14163. iteminfo.OthAmt = bed_other_amt
  14164. iteminfoStructs = append(iteminfoStructs, iteminfo)
  14165. }
  14166. if checkCostTotal != 0 {
  14167. iteminfo.MedChrgitm = "03"
  14168. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  14169. iteminfo.Amt = checkCostTotal
  14170. iteminfo.ClaaSumfee = check_claa_sunmfee
  14171. iteminfo.ClabAmt = check_clab_amt
  14172. iteminfo.OthAmt = check_other_amt
  14173. iteminfoStructs = append(iteminfoStructs, iteminfo)
  14174. }
  14175. if laboratoryCostTotal != 0 {
  14176. iteminfo.MedChrgitm = "04"
  14177. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  14178. iteminfo.Amt = laboratoryCostTotal
  14179. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  14180. iteminfo.ClabAmt = laboratory_clab_amt
  14181. iteminfo.OthAmt = laboratory_other_amt
  14182. iteminfoStructs = append(iteminfoStructs, iteminfo)
  14183. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  14184. }
  14185. if treatCostTotal != 0 {
  14186. iteminfo.MedChrgitm = "05"
  14187. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  14188. iteminfo.Amt = treatCostTotal
  14189. iteminfo.ClaaSumfee = treat_claa_sunmfee
  14190. iteminfo.ClabAmt = treat_clab_amt
  14191. iteminfo.OthAmt = treat_other_amt
  14192. iteminfoStructs = append(iteminfoStructs, iteminfo)
  14193. //(struct4101.IteminfoStruct, iteminfo)
  14194. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  14195. }
  14196. if operationCostTotal != 0 {
  14197. iteminfo.MedChrgitm = "06"
  14198. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  14199. iteminfo.Amt = operationCostTotal
  14200. iteminfo.ClaaSumfee = operation_claa_sunmfee
  14201. iteminfo.ClabAmt = operation_clab_amt
  14202. iteminfo.OthAmt = operation_other_amt
  14203. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  14204. iteminfoStructs = append(iteminfoStructs, iteminfo)
  14205. }
  14206. if materialCostTotal != 0 {
  14207. iteminfo.MedChrgitm = "08"
  14208. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  14209. iteminfo.Amt = materialCostTotal
  14210. iteminfo.ClaaSumfee = material_claa_sunmfee
  14211. iteminfo.ClabAmt = material_clab_amt
  14212. iteminfo.OthAmt = material_other_amt
  14213. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  14214. iteminfoStructs = append(iteminfoStructs, iteminfo)
  14215. }
  14216. if westernMedicineCostTotal != 0 {
  14217. iteminfo.MedChrgitm = "09"
  14218. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  14219. iteminfo.Amt = westernMedicineCostTotal
  14220. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  14221. iteminfo.ClabAmt = westernMedicine_clab_amt
  14222. iteminfo.OthAmt = westernMedicine_other_amt
  14223. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  14224. iteminfoStructs = append(iteminfoStructs, iteminfo)
  14225. }
  14226. if chineseTraditionalMedicineCostTotal != 0 {
  14227. iteminfo.MedChrgitm = "11"
  14228. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  14229. iteminfo.Amt = westernMedicineCostTotal
  14230. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  14231. iteminfo.ClabAmt = westernMedicine_clab_amt
  14232. iteminfo.OthAmt = westernMedicine_other_amt
  14233. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  14234. iteminfoStructs = append(iteminfoStructs, iteminfo)
  14235. }
  14236. if otherCostTotal != 0 {
  14237. iteminfo.MedChrgitm = "14"
  14238. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  14239. iteminfo.Amt = otherCostTotal
  14240. iteminfo.ClaaSumfee = other_claa_sunmfee
  14241. iteminfo.ClabAmt = other_clab_amt
  14242. iteminfo.OthAmt = other_other_amt
  14243. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  14244. iteminfoStructs = append(iteminfoStructs, iteminfo)
  14245. }
  14246. struct4101.IteminfoStruct = iteminfoStructs
  14247. struct4101.Ntly = "中国"
  14248. struct4101.AdmCaty = "A03.06"
  14249. var resOther ResultSeventeenOther
  14250. var res ResultSeventeen
  14251. if miConfig.MdtrtareaAdmvs == "150499" {
  14252. var pp models.PublicParams
  14253. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  14254. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  14255. pp.FixmedinsName = miConfig.OrgName
  14256. pp.FixmedinsCode = miConfig.Code
  14257. pp.RequestUrl = miConfig.Url
  14258. pp.Cainfo = miConfig.Cainfo
  14259. pp.SecretKey = miConfig.SecretKey
  14260. pp.AccessKey = miConfig.AccessKey
  14261. pp.OpterName = curRoles.UserName
  14262. client := &http.Client{}
  14263. var req *http.Request
  14264. data := make(map[string]interface{})
  14265. data["struct4101"] = struct4101
  14266. data["pp"] = pp
  14267. bytesData, _ := json.Marshal(data)
  14268. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/4101", bytes.NewReader(bytesData))
  14269. resp, _ := client.Do(req)
  14270. defer resp.Body.Close()
  14271. body, ioErr := ioutil.ReadAll(resp.Body)
  14272. if ioErr != nil {
  14273. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14274. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14275. return
  14276. }
  14277. var respJSON map[string]interface{}
  14278. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  14279. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14280. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14281. return
  14282. }
  14283. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  14284. userJSONBytes, _ := json.Marshal(respJSON)
  14285. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  14286. utils.ErrorLog("解析失败:%v", err)
  14287. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14288. return
  14289. }
  14290. res.InfRefmsgid = resOther.InfRefmsgid
  14291. res.Output = resOther.Output
  14292. res.ErrMsg = resOther.ErrMsg
  14293. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  14294. res.Infcode = infocode
  14295. } else if miConfig.MdtrtareaAdmvs == "360302" {
  14296. var pp models.PublicParams
  14297. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  14298. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  14299. pp.FixmedinsName = miConfig.OrgName
  14300. pp.FixmedinsCode = miConfig.Code
  14301. pp.RequestUrl = miConfig.Url
  14302. pp.Cainfo = miConfig.Cainfo
  14303. pp.SecretKey = miConfig.SecretKey
  14304. pp.AccessKey = miConfig.AccessKey
  14305. pp.OpterName = curRoles.UserName
  14306. result, _ := service.Jxyb4101(struct4101, pp)
  14307. var dat map[string]interface{}
  14308. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  14309. fmt.Println(dat)
  14310. } else {
  14311. fmt.Println(err)
  14312. }
  14313. userJSONBytes, _ := json.Marshal(dat)
  14314. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14315. utils.ErrorLog("解析失败:%v", err)
  14316. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14317. return
  14318. }
  14319. } else {
  14320. result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId, admin_user_id)
  14321. var dat map[string]interface{}
  14322. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  14323. fmt.Println(dat)
  14324. } else {
  14325. fmt.Println(err)
  14326. }
  14327. userJSONBytes, _ := json.Marshal(dat)
  14328. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14329. utils.ErrorLog("解析失败:%v", err)
  14330. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14331. return
  14332. }
  14333. }
  14334. if res.Infcode != 0 {
  14335. c.ServeSuccessJSON(map[string]interface{}{
  14336. "failed_code": -10,
  14337. "msg": res.ErrMsg,
  14338. })
  14339. return
  14340. } else {
  14341. if miConfig.MdtrtareaAdmvs != "150499" {
  14342. order.FaPiaoNumber = zero
  14343. order.FaPiaoCode = last_order.FaPiaoCode
  14344. service.UpdateOrder(order)
  14345. }
  14346. hisFundSettleListResult := &models.HisFundSettleListResult{
  14347. Number: res.Output.SetlListId,
  14348. Status: 1,
  14349. Ctime: time.Now().Unix(),
  14350. Mtime: time.Now().Unix(),
  14351. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14352. IsUpload: 1,
  14353. OrderId: order_id,
  14354. }
  14355. service.CreateUploadRecord(hisFundSettleListResult)
  14356. c.ServeSuccessJSON(map[string]interface{}{
  14357. "msg": "上传成功",
  14358. "result": hisFundSettleListResult,
  14359. })
  14360. return
  14361. }
  14362. }
  14363. //func (c *HisApiController) GetBatchSettleList() {
  14364. // orders, _ := service.GetAllHisOrder(10106)
  14365. // for _, item := range orders {
  14366. // order_id := item.ID
  14367. // order, _ := service.GetHisOrderByIDTwo(order_id)
  14368. // roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  14369. // his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  14370. // admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  14371. // curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, 2495)
  14372. // depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  14373. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  14374. //
  14375. // pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  14376. //
  14377. // doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  14378. //
  14379. // if order.ID == 0 {
  14380. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  14381. // return
  14382. // }
  14383. // if his.BalanceAccountsType == 2 {
  14384. // continue
  14385. // }
  14386. // struct4101 := service.Struct4101{
  14387. // PsnNo: order.PsnNo,
  14388. // MdtrtId: order.MdtrtId,
  14389. // SetlId: order.SetlId,
  14390. // PsnName: order.PsnName,
  14391. // Gend: order.Gend,
  14392. // Brdy: his.Brdy,
  14393. // Age: his.Age,
  14394. // Naty: order.Naty,
  14395. // PatnCertType: "01",
  14396. // Certno: order.Certno,
  14397. // Prfs: "90",
  14398. // ConerName: roles[0].UserName,
  14399. // PatnRlts: "99",
  14400. // ConerAddr: miConfig.OrgName,
  14401. // ConerTel: admin.Mobile,
  14402. // HiType: order.Insutype,
  14403. // Insuplc: his.InsuplcAdmdvs,
  14404. // MaindiagFlag: "1",
  14405. // BillCode: order.SetlId,
  14406. // BillNo: order.SetlId,
  14407. // BizSn: order.Number,
  14408. // PsnSelfPay: order.PsnPartAmt,
  14409. // PsnOwnPay: order.PsnPartAmt,
  14410. // AcctPay: order.AcctPay,
  14411. // PsnCashpay: order.PsnCashPay,
  14412. // HiPaymtd: "1",
  14413. // Hsorg: his.InsuplcAdmdvs,
  14414. // HsorgOpter: his.InsuplcAdmdvs,
  14415. // MedinsFillPsn: curRoles.UserName,
  14416. // MedinsFillDept: depart.Name,
  14417. // IptMedType: "2",
  14418. // }
  14419. // struct4101.SetlBegnDate = order.SetlTime
  14420. // struct4101.SetlEndDate = order.SetlTime
  14421. // //if order.SettleType == 1 {
  14422. // // t := time.Unix(int64(order.SettleAccountsDate), 0)
  14423. // // dateStr := t.Format("2006-01-02")
  14424. // // struct4101.SetlBegnDate = dateStr
  14425. // // struct4101.SetlEndDate = dateStr
  14426. // //} else {
  14427. // // t := time.Unix(int64(order.SettleStartTime), 0)
  14428. // // t2 := time.Unix(int64(order.SettleEndTime), 0)
  14429. // // dateStartStr := t.Format("2006-01-02")
  14430. // // dateEndStr := t2.Format("2006-01-02")
  14431. // // struct4101.SetlBegnDate = dateStartStr
  14432. // // struct4101.SetlEndDate = dateEndStr
  14433. // //}
  14434. //
  14435. // var rf []CustomFundPay
  14436. // json.Unmarshal([]byte(order.SetlDetail), &rf)
  14437. //
  14438. // var tempFunPays []service.CustomStruct
  14439. // var tempFunPay610100 service.CustomStruct
  14440. //
  14441. // for _, item := range rf {
  14442. // if item.FundPayType == "610100" {
  14443. // tempFunPay610100.FundPayamt, _ = decimal.NewFromFloat(tempFunPay610100.FundPayamt).Add(decimal.NewFromFloat(item.FundPayamt)).Float64()
  14444. // tempFunPay610100.FundPayType = item.FundPayType
  14445. // } else {
  14446. // var tempFunPay service.CustomStruct
  14447. // tempFunPay.FundPayamt = item.FundPayamt
  14448. // tempFunPay.FundPayType = item.FundPayType
  14449. // tempFunPays = append(tempFunPays, tempFunPay)
  14450. // }
  14451. // }
  14452. // tempFunPays = append(tempFunPays, tempFunPay610100)
  14453. // struct4101.CustomStruct = tempFunPays
  14454. //
  14455. // var tempDiaginfos []service.DiaginfoStructTwo
  14456. // var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  14457. // var tempOpspdiseinfos []service.OpspdiseinfoStruct
  14458. //
  14459. // diagnosis_ids := strings.Split(his.Diagnosis, ",")
  14460. // var config []*models.HisXtDiagnoseConfig
  14461. // for _, item := range diagnosis_ids {
  14462. // id, _ := strconv.ParseInt(item, 10, 64)
  14463. // diagnosisConfig, _ := service.FindDiagnoseById(id)
  14464. // config = append(config, &diagnosisConfig)
  14465. // }
  14466. //
  14467. // for index, item := range config {
  14468. // if index == 0 {
  14469. // var tempDiaginfo service.DiaginfoStructTwo
  14470. // tempDiaginfo.DiagCode = item.CountryCode
  14471. // tempDiaginfo.DiagName = item.CountryContentName
  14472. // tempDiaginfo.DiagType = "1"
  14473. // tempDiaginfo.MaindiagFlag = "1"
  14474. // tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  14475. // } else {
  14476. //
  14477. // var tempDiaginfo service.DiaginfoStructTwo
  14478. // tempDiaginfo.DiagCode = item.CountryCode
  14479. // tempDiaginfo.DiagName = item.CountryContentName
  14480. // tempDiaginfo.DiagType = "2"
  14481. // tempDiaginfo.MaindiagFlag = "0"
  14482. // tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  14483. // }
  14484. // }
  14485. // struct4101.Diseinfo = tempDiaginfos
  14486. //
  14487. // sickConfigTwo, _ := service.FindSickById(his.SickType)
  14488. // tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  14489. // tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  14490. // tempOpspdiseinfo2.OprnOprtCode = ""
  14491. // tempOpspdiseinfo2.OprnOprtName = ""
  14492. // tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  14493. // struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  14494. //
  14495. // var iteminfo service.IteminfoStruct
  14496. //
  14497. // var bedCostTotal float64 = 0 //床位总费
  14498. // var bedCostSelfTotal float64 = 0 //床位自费
  14499. // var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  14500. //
  14501. // var examineCostTotal float64 = 0 //诊查总费
  14502. // var examineCostSelfTotal float64 = 0 //诊查自费
  14503. // var examineCostPartSelfTotal float64 = 0 //诊查部分项目自费
  14504. //
  14505. // var nursingCostTotal float64 = 0 //护理总费
  14506. // var nursingCostSelfTotal float64 = 0 //护理自费
  14507. // var nursingCostPartSelfTotal float64 = 0 //护理部分项目自费
  14508. //
  14509. // var chineseMedicineCostTotal float64 = 0 //中成药
  14510. // var chineseMedicineCostSelfTotal float64 = 0 //中成药
  14511. // var chineseMedicineCostPartSelfTotal float64 = 0 //中成药
  14512. //
  14513. // var commonlyTreatmentCostTotal float64 = 0 //一般诊疗费
  14514. // var commonlyTreatmentCostSelfTotal float64 = 0 //一般诊疗费
  14515. // var commonlyTreatmentCostPartSelfTotal float64 = 0 //一般诊疗费
  14516. //
  14517. // var registerCostTotal float64 = 0 //一般诊疗费
  14518. // var registerCostSelfTotal float64 = 0 //一般诊疗费
  14519. // var registerPartSelfTotal float64 = 0 //一般诊疗费
  14520. //
  14521. // var operationCostTotal float64 = 0 //手术费
  14522. // var operationCostSelfTotal float64 = 0 //手术费
  14523. // var operationCostPartSelfTotal float64 = 0 //手术费
  14524. //
  14525. // var otherCostTotal float64 = 0 //其他费用
  14526. // var otherCostSelfTotal float64 = 0 //其他费用
  14527. // var otherCostPartSelfTotal float64 = 0 //其他费用
  14528. //
  14529. // var materialCostTotal float64 = 0 //材料费
  14530. // var materialCostSelfTotal float64 = 0 //材料费
  14531. // var materialCostPartSelfTotal float64 = 0 //材料费
  14532. //
  14533. // var westernMedicineCostTotal float64 = 0 //西药费
  14534. // var westernMedicineCostSelfTotal float64 = 0 //西药费
  14535. // var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  14536. //
  14537. // var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  14538. // var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  14539. // var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  14540. //
  14541. // var checkCostTotal float64 = 0 //检查费
  14542. // var checkCostSelfTotal float64 = 0 //检查费
  14543. // var checkCostPartSelfTotal float64 = 0 //检查费
  14544. //
  14545. // var laboratoryCostTotal float64 = 0 //化验费
  14546. // var laboratoryCostSelfTotal float64 = 0 //化验费
  14547. // var laboratoryCostPartSelfTotal float64 = 0 //化验费
  14548. //
  14549. // var treatCostTotal float64 = 0 //治疗费用
  14550. // var treatCostSelfTotal float64 = 0 //治疗费用
  14551. // var treatCostPartSelfTotal float64 = 0 //治疗费用
  14552. //
  14553. // decimal.DivisionPrecision = 2
  14554. //
  14555. // var bed_fulamt_ownpay_amt float64 = 0
  14556. //
  14557. // var examine_fulamt_ownpay_amt float64 = 0
  14558. //
  14559. // var nursing_fulamt_ownpay_amt float64 = 0
  14560. //
  14561. // var chinese_medicine_fulamt_ownpay_amt float64 = 0
  14562. //
  14563. // var commonly_treatment_fulamt_ownpay_amt float64 = 0
  14564. //
  14565. // var register_fulamt_ownpay_amt float64 = 0
  14566. //
  14567. // var operation_fulamt_ownpay_amt float64 = 0
  14568. // var other_fulamt_ownpay_amt float64 = 0
  14569. // var westernMedicine_fulamt_ownpay_amt float64 = 0
  14570. // var chineseTraditional_fulamt_ownpay_amt float64 = 0
  14571. // var check_fulamt_ownpay_amt float64 = 0
  14572. // var material_fulamt_ownpay_amt float64 = 0
  14573. // var laboratory_fulamt_ownpay_amt float64 = 0
  14574. // var treat_fulamt_ownpay_amt float64 = 0
  14575. //
  14576. // var bed_claa_sunmfee float64 = 0
  14577. // var bed_clab_amt float64 = 0
  14578. // var bed_other_amt float64 = 0
  14579. //
  14580. // var examine_claa_sunmfee float64 = 0
  14581. // var examine_clab_amt float64 = 0
  14582. // var examine_other_amt float64 = 0
  14583. //
  14584. // var nursing_claa_sunmfee float64 = 0
  14585. // var nursing_clab_amt float64 = 0
  14586. // var nursing_other_amt float64 = 0
  14587. //
  14588. // var chinese_medicine_claa_sunmfee float64 = 0
  14589. // var chinese_medicine_clab_amt float64 = 0
  14590. // var chinese_medicine_other_amt float64 = 0
  14591. //
  14592. // var commonly_treatment_claa_sunmfee float64 = 0
  14593. // var commonly_treatment_clab_amt float64 = 0
  14594. // var commonly_treatment_other_amt float64 = 0
  14595. //
  14596. // var operation_claa_sunmfee float64 = 0
  14597. // var operation_clab_amt float64 = 0
  14598. // var operation_other_amt float64 = 0
  14599. //
  14600. // var other_claa_sunmfee float64 = 0
  14601. // var other_clab_amt float64 = 0
  14602. // var other_other_amt float64 = 0
  14603. //
  14604. // var westernMedicine_claa_sunmfee float64 = 0
  14605. // var westernMedicine_clab_amt float64 = 0
  14606. // var westernMedicine_other_amt float64 = 0
  14607. //
  14608. // var chineseTraditional_claa_sunmfee float64 = 0
  14609. // var chineseTraditional_clab_amt float64 = 0
  14610. // var chineseTraditional_other_amt float64 = 0
  14611. //
  14612. // var check_claa_sunmfee float64 = 0
  14613. // var check_clab_amt float64 = 0
  14614. // var check_other_amt float64 = 0
  14615. //
  14616. // var material_claa_sunmfee float64 = 0
  14617. // var material_clab_amt float64 = 0
  14618. // var material_other_amt float64 = 0
  14619. //
  14620. // var laboratory_claa_sunmfee float64 = 0
  14621. // var laboratory_clab_amt float64 = 0
  14622. // var laboratory_other_amt float64 = 0
  14623. //
  14624. // var treat_claa_sunmfee float64 = 0
  14625. // var treat_clab_amt float64 = 0
  14626. // var treat_other_amt float64 = 0
  14627. //
  14628. // var register_claa_sunmfee float64 = 0
  14629. // var register_clab_amt float64 = 0
  14630. // var register_other_amt float64 = 0
  14631. //
  14632. // for _, item := range order.HisOrderInfo {
  14633. // if item.MedChrgitmType == "01" { //床位费
  14634. // bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14635. // bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14636. // bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14637. // bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14638. // if item.ChrgitmLv == "1" {
  14639. // bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14640. // }
  14641. // if item.ChrgitmLv == "2" {
  14642. // bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14643. //
  14644. // }
  14645. // if item.ChrgitmLv == "3" {
  14646. // bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14647. // }
  14648. //
  14649. // }
  14650. //
  14651. // if item.MedChrgitmType == "02" { //诊查
  14652. // examineCostTotal, _ = decimal.NewFromFloat(examineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14653. // examineCostSelfTotal, _ = decimal.NewFromFloat(examineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14654. // examineCostPartSelfTotal, _ = decimal.NewFromFloat(examineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14655. // examine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(examine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14656. // if item.ChrgitmLv == "1" {
  14657. // examine_claa_sunmfee, _ = decimal.NewFromFloat(examine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14658. // }
  14659. // if item.ChrgitmLv == "2" {
  14660. // examine_clab_amt, _ = decimal.NewFromFloat(examine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14661. //
  14662. // }
  14663. // if item.ChrgitmLv == "3" {
  14664. // examine_other_amt, _ = decimal.NewFromFloat(examine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14665. // }
  14666. //
  14667. // }
  14668. //
  14669. // if item.MedChrgitmType == "03" { //检查费
  14670. // checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14671. // checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14672. // checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14673. // check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14674. // if item.ChrgitmLv == "1" {
  14675. //
  14676. // check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14677. //
  14678. // }
  14679. // if item.ChrgitmLv == "2" {
  14680. // check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14681. //
  14682. // }
  14683. // if item.ChrgitmLv == "3" {
  14684. // check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14685. // }
  14686. // }
  14687. //
  14688. // if item.MedChrgitmType == "04" { //化验费
  14689. // laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14690. // laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14691. // laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14692. // laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14693. // if item.ChrgitmLv == "1" {
  14694. //
  14695. // laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14696. //
  14697. // }
  14698. // if item.ChrgitmLv == "2" {
  14699. // laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14700. //
  14701. // }
  14702. // if item.ChrgitmLv == "3" {
  14703. // laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14704. // }
  14705. // }
  14706. //
  14707. // if item.MedChrgitmType == "05" { //治疗费
  14708. // treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14709. // treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14710. // treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14711. // treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14712. // if item.ChrgitmLv == "1" {
  14713. //
  14714. // treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14715. //
  14716. // }
  14717. // if item.ChrgitmLv == "2" {
  14718. // treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14719. //
  14720. // }
  14721. // if item.ChrgitmLv == "3" {
  14722. // treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14723. // }
  14724. // }
  14725. //
  14726. // if item.MedChrgitmType == "06" { //手术费
  14727. // operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14728. // operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14729. // operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14730. // operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14731. //
  14732. // if item.ChrgitmLv == "1" {
  14733. //
  14734. // operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14735. //
  14736. // }
  14737. // if item.ChrgitmLv == "2" {
  14738. // operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14739. //
  14740. // }
  14741. // if item.ChrgitmLv == "3" {
  14742. // operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14743. // }
  14744. // }
  14745. //
  14746. // if item.MedChrgitmType == "07" { //手术费
  14747. // nursingCostTotal, _ = decimal.NewFromFloat(nursingCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14748. // nursingCostSelfTotal, _ = decimal.NewFromFloat(nursingCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14749. // nursingCostPartSelfTotal, _ = decimal.NewFromFloat(nursingCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14750. // nursing_fulamt_ownpay_amt, _ = decimal.NewFromFloat(nursing_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14751. //
  14752. // if item.ChrgitmLv == "1" {
  14753. //
  14754. // nursing_claa_sunmfee, _ = decimal.NewFromFloat(nursing_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14755. //
  14756. // }
  14757. // if item.ChrgitmLv == "2" {
  14758. // nursing_clab_amt, _ = decimal.NewFromFloat(nursing_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14759. //
  14760. // }
  14761. // if item.ChrgitmLv == "3" {
  14762. // nursing_other_amt, _ = decimal.NewFromFloat(nursing_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14763. // }
  14764. // }
  14765. //
  14766. // if item.MedChrgitmType == "08" { //材料费
  14767. // materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14768. // materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14769. // materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14770. // material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14771. // if item.ChrgitmLv == "1" {
  14772. //
  14773. // material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14774. //
  14775. // }
  14776. // if item.ChrgitmLv == "2" {
  14777. // material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14778. //
  14779. // }
  14780. // if item.ChrgitmLv == "3" {
  14781. // material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14782. // }
  14783. // }
  14784. // if item.MedChrgitmType == "09" { //西药费
  14785. // westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14786. // westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14787. // westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14788. // westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14789. // if item.ChrgitmLv == "1" {
  14790. // westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14791. // }
  14792. // if item.ChrgitmLv == "2" {
  14793. // westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14794. // }
  14795. // if item.ChrgitmLv == "3" {
  14796. // westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14797. // }
  14798. // }
  14799. // if item.MedChrgitmType == "10" { //中药饮片
  14800. // chineseMedicineCostTotal, _ = decimal.NewFromFloat(chineseMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14801. // chineseMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14802. // chineseMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14803. // chinese_medicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chinese_medicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14804. // if item.ChrgitmLv == "1" {
  14805. // chinese_medicine_claa_sunmfee, _ = decimal.NewFromFloat(chinese_medicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14806. // }
  14807. // if item.ChrgitmLv == "2" {
  14808. // chinese_medicine_clab_amt, _ = decimal.NewFromFloat(chinese_medicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14809. // }
  14810. // if item.ChrgitmLv == "3" {
  14811. // chinese_medicine_other_amt, _ = decimal.NewFromFloat(chinese_medicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14812. // }
  14813. // }
  14814. //
  14815. // if item.MedChrgitmType == "11" { //中成费
  14816. // chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14817. // chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14818. // chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14819. // chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14820. // if item.ChrgitmLv == "1" {
  14821. //
  14822. // chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14823. //
  14824. // }
  14825. // if item.ChrgitmLv == "2" {
  14826. // chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14827. //
  14828. // }
  14829. // if item.ChrgitmLv == "3" {
  14830. // chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14831. // }
  14832. // }
  14833. //
  14834. // if item.MedChrgitmType == "12" { //中成费
  14835. // commonlyTreatmentCostTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14836. // commonlyTreatmentCostSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14837. // commonlyTreatmentCostPartSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14838. // commonly_treatment_fulamt_ownpay_amt, _ = decimal.NewFromFloat(commonly_treatment_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14839. // if item.ChrgitmLv == "1" {
  14840. //
  14841. // commonly_treatment_claa_sunmfee, _ = decimal.NewFromFloat(commonly_treatment_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14842. //
  14843. // }
  14844. // if item.ChrgitmLv == "2" {
  14845. // commonly_treatment_clab_amt, _ = decimal.NewFromFloat(commonly_treatment_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14846. //
  14847. // }
  14848. // if item.ChrgitmLv == "3" {
  14849. // commonly_treatment_other_amt, _ = decimal.NewFromFloat(commonly_treatment_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14850. // }
  14851. // }
  14852. //
  14853. // if item.MedChrgitmType == "13" { //中成费
  14854. // registerCostTotal, _ = decimal.NewFromFloat(registerCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14855. // registerCostSelfTotal, _ = decimal.NewFromFloat(registerCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14856. // registerPartSelfTotal, _ = decimal.NewFromFloat(registerPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14857. // register_fulamt_ownpay_amt, _ = decimal.NewFromFloat(register_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14858. // if item.ChrgitmLv == "1" {
  14859. //
  14860. // register_claa_sunmfee, _ = decimal.NewFromFloat(register_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14861. //
  14862. // }
  14863. // if item.ChrgitmLv == "2" {
  14864. // register_clab_amt, _ = decimal.NewFromFloat(register_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14865. //
  14866. // }
  14867. // if item.ChrgitmLv == "3" {
  14868. // register_other_amt, _ = decimal.NewFromFloat(register_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14869. // }
  14870. // }
  14871. //
  14872. // if item.MedChrgitmType == "14" { //其他费
  14873. // otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14874. // otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14875. // otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14876. // other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14877. // if item.ChrgitmLv == "1" {
  14878. // other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14879. //
  14880. // }
  14881. // if item.ChrgitmLv == "2" {
  14882. // other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14883. //
  14884. // }
  14885. // if item.ChrgitmLv == "3" {
  14886. // other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14887. // }
  14888. // }
  14889. //
  14890. // }
  14891. //
  14892. // var iteminfoStructs []service.IteminfoStruct
  14893. //
  14894. // if bedCostTotal != 0 {
  14895. // iteminfo.MedChrgitm = "01"
  14896. // iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  14897. // iteminfo.Amt = bedCostTotal
  14898. // iteminfo.ClaaSumfee = bed_claa_sunmfee
  14899. // iteminfo.ClabAmt = bed_clab_amt
  14900. // iteminfo.OthAmt = bed_other_amt
  14901. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  14902. // }
  14903. //
  14904. // if examineCostTotal != 0 {
  14905. // iteminfo.MedChrgitm = "02"
  14906. // iteminfo.FulamtOwnpayAmt = examine_fulamt_ownpay_amt
  14907. // iteminfo.Amt = examineCostTotal
  14908. // iteminfo.ClaaSumfee = examine_claa_sunmfee
  14909. // iteminfo.ClabAmt = examine_clab_amt
  14910. // iteminfo.OthAmt = examine_other_amt
  14911. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  14912. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  14913. // }
  14914. //
  14915. // if checkCostTotal != 0 {
  14916. // iteminfo.MedChrgitm = "03"
  14917. // iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  14918. // iteminfo.Amt = checkCostTotal
  14919. // iteminfo.ClaaSumfee = check_claa_sunmfee
  14920. // iteminfo.ClabAmt = check_clab_amt
  14921. // iteminfo.OthAmt = check_other_amt
  14922. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  14923. //
  14924. // }
  14925. //
  14926. // if laboratoryCostTotal != 0 {
  14927. // iteminfo.MedChrgitm = "04"
  14928. // iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  14929. // iteminfo.Amt = laboratoryCostTotal
  14930. // iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  14931. // iteminfo.ClabAmt = laboratory_clab_amt
  14932. // iteminfo.OthAmt = laboratory_other_amt
  14933. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  14934. //
  14935. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  14936. //
  14937. // }
  14938. //
  14939. // if treatCostTotal != 0 {
  14940. // iteminfo.MedChrgitm = "05"
  14941. // iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  14942. // iteminfo.Amt = treatCostTotal
  14943. // iteminfo.ClaaSumfee = treat_claa_sunmfee
  14944. // iteminfo.ClabAmt = treat_clab_amt
  14945. // iteminfo.OthAmt = treat_other_amt
  14946. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  14947. // //(struct4101.IteminfoStruct, iteminfo)
  14948. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  14949. // }
  14950. //
  14951. // if operationCostTotal != 0 {
  14952. // iteminfo.MedChrgitm = "06"
  14953. // iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  14954. // iteminfo.Amt = operationCostTotal
  14955. // iteminfo.ClaaSumfee = operation_claa_sunmfee
  14956. // iteminfo.ClabAmt = operation_clab_amt
  14957. // iteminfo.OthAmt = operation_other_amt
  14958. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  14959. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  14960. // }
  14961. //
  14962. // if nursingCostTotal != 0 {
  14963. // iteminfo.MedChrgitm = "07"
  14964. // iteminfo.FulamtOwnpayAmt = nursing_fulamt_ownpay_amt
  14965. // iteminfo.Amt = nursingCostTotal
  14966. // iteminfo.ClaaSumfee = nursing_claa_sunmfee
  14967. // iteminfo.ClabAmt = nursing_clab_amt
  14968. // iteminfo.OthAmt = nursing_other_amt
  14969. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  14970. // }
  14971. //
  14972. // if materialCostTotal != 0 {
  14973. // iteminfo.MedChrgitm = "08"
  14974. // iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  14975. // iteminfo.Amt = materialCostTotal
  14976. // iteminfo.ClaaSumfee = material_claa_sunmfee
  14977. // iteminfo.ClabAmt = material_clab_amt
  14978. // iteminfo.OthAmt = material_other_amt
  14979. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  14980. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  14981. // }
  14982. //
  14983. // if westernMedicineCostTotal != 0 {
  14984. // iteminfo.MedChrgitm = "09"
  14985. // iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  14986. // iteminfo.Amt = westernMedicineCostTotal
  14987. // iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  14988. // iteminfo.ClabAmt = westernMedicine_clab_amt
  14989. // iteminfo.OthAmt = westernMedicine_other_amt
  14990. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  14991. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  14992. //
  14993. // }
  14994. //
  14995. // if chineseMedicineCostTotal != 0 {
  14996. // iteminfo.MedChrgitm = "10"
  14997. // iteminfo.FulamtOwnpayAmt = chinese_medicine_fulamt_ownpay_amt
  14998. // iteminfo.Amt = chineseMedicineCostTotal
  14999. // iteminfo.ClaaSumfee = chinese_medicine_claa_sunmfee
  15000. // iteminfo.ClabAmt = chinese_medicine_clab_amt
  15001. // iteminfo.OthAmt = chinese_medicine_other_amt
  15002. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  15003. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  15004. //
  15005. // }
  15006. //
  15007. // if chineseTraditionalMedicineCostTotal != 0 {
  15008. // iteminfo.MedChrgitm = "11"
  15009. // iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  15010. // iteminfo.Amt = westernMedicineCostTotal
  15011. // iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  15012. // iteminfo.ClabAmt = westernMedicine_clab_amt
  15013. // iteminfo.OthAmt = westernMedicine_other_amt
  15014. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  15015. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  15016. //
  15017. // }
  15018. //
  15019. // if commonlyTreatmentCostTotal != 0 {
  15020. // iteminfo.MedChrgitm = "12"
  15021. // iteminfo.FulamtOwnpayAmt = commonly_treatment_fulamt_ownpay_amt
  15022. // iteminfo.Amt = commonlyTreatmentCostTotal
  15023. // iteminfo.ClaaSumfee = commonly_treatment_claa_sunmfee
  15024. // iteminfo.ClabAmt = commonly_treatment_clab_amt
  15025. // iteminfo.OthAmt = commonly_treatment_other_amt
  15026. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  15027. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  15028. //
  15029. // }
  15030. //
  15031. // if registerCostTotal != 0 {
  15032. // iteminfo.MedChrgitm = "13"
  15033. // iteminfo.FulamtOwnpayAmt = register_fulamt_ownpay_amt
  15034. // iteminfo.Amt = registerCostTotal
  15035. // iteminfo.ClaaSumfee = register_claa_sunmfee
  15036. // iteminfo.ClabAmt = register_clab_amt
  15037. // iteminfo.OthAmt = register_other_amt
  15038. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  15039. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  15040. //
  15041. // }
  15042. //
  15043. // if otherCostTotal != 0 {
  15044. // iteminfo.MedChrgitm = "14"
  15045. // iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  15046. // iteminfo.Amt = otherCostTotal
  15047. // iteminfo.ClaaSumfee = other_claa_sunmfee
  15048. // iteminfo.ClabAmt = other_clab_amt
  15049. // iteminfo.OthAmt = other_other_amt
  15050. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  15051. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  15052. //
  15053. // }
  15054. // struct4101.IteminfoStruct = iteminfoStructs
  15055. // time_arr := strings.Split(order.SetlTime, " ")
  15056. // struct4101.AdmTime = time_arr[0]
  15057. // struct4101.AdmEndTime = time_arr[0]
  15058. //
  15059. // struct4101.DoctorName = doctor.UserName
  15060. // struct4101.DoctorCode = doctor.DoctorNumber
  15061. //
  15062. // struct4101.Ntly = "中国"
  15063. // struct4101.AdmCaty = "A03.06"
  15064. // var res ResultSeventeen
  15065. // if miConfig.MdtrtareaAdmvs == "421300" {
  15066. // data := make(map[string]interface{})
  15067. // data["struct4101"] = struct4101
  15068. // data["secret_key"] = miConfig.SecretKey
  15069. // data["org_name"] = miConfig.OrgName
  15070. // data["opera"] = curRoles.UserName
  15071. // data["code"] = miConfig.Code
  15072. // data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  15073. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  15074. //
  15075. // client := &http.Client{}
  15076. // bytesData, _ := json.Marshal(data)
  15077. // req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/4101", bytes.NewReader(bytesData))
  15078. // resp, _ := client.Do(req)
  15079. // defer resp.Body.Close()
  15080. // body, ioErr := ioutil.ReadAll(resp.Body)
  15081. // if ioErr != nil {
  15082. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  15083. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15084. // return
  15085. // }
  15086. // var respJSON map[string]interface{}
  15087. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  15088. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15089. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15090. // return
  15091. // }
  15092. //
  15093. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  15094. // userJSONBytes, _ := json.Marshal(respJSON)
  15095. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  15096. // utils.ErrorLog("解析失败:%v", err)
  15097. // //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15098. // adminUser := c.GetAdminUserInfo()
  15099. // errlog := &models.HisOrderError{
  15100. // UserOrgId: adminUser.CurrentOrgId,
  15101. // Ctime: time.Now().Unix(),
  15102. // Mtime: time.Now().Unix(),
  15103. // ErrMsg: res.ErrMsg + "解析失败",
  15104. // Status: 1,
  15105. // PatientId: order_id,
  15106. // Stage: 10088,
  15107. // }
  15108. // service.CreateErrMsgLog(errlog)
  15109. // continue
  15110. // }
  15111. //
  15112. // } else if miConfig.MdtrtareaAdmvs == "420200" {
  15113. // data := make(map[string]interface{})
  15114. // data["struct4101"] = struct4101
  15115. // data["secret_key"] = miConfig.SecretKey
  15116. // data["org_name"] = miConfig.OrgName
  15117. // data["opera"] = curRoles.UserName
  15118. // data["code"] = miConfig.Code
  15119. // data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  15120. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  15121. //
  15122. // client := &http.Client{}
  15123. // bytesData, _ := json.Marshal(data)
  15124. // req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/4101", bytes.NewReader(bytesData))
  15125. // resp, _ := client.Do(req)
  15126. // defer resp.Body.Close()
  15127. // body, ioErr := ioutil.ReadAll(resp.Body)
  15128. // if ioErr != nil {
  15129. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  15130. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15131. // return
  15132. // }
  15133. // var respJSON map[string]interface{}
  15134. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  15135. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15136. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15137. // return
  15138. // }
  15139. //
  15140. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  15141. // userJSONBytes, _ := json.Marshal(respJSON)
  15142. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  15143. // utils.ErrorLog("解析失败:%v", err)
  15144. // //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15145. // adminUser := c.GetAdminUserInfo()
  15146. // errlog := &models.HisOrderError{
  15147. // UserOrgId: adminUser.CurrentOrgId,
  15148. // Ctime: time.Now().Unix(),
  15149. // Mtime: time.Now().Unix(),
  15150. // ErrMsg: res.ErrMsg + "解析失败",
  15151. // Status: 1,
  15152. // PatientId: order_id,
  15153. // Stage: 10088,
  15154. // }
  15155. // service.CreateErrMsgLog(errlog)
  15156. // continue
  15157. // }
  15158. //
  15159. // } else {
  15160. // result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, c.GetAdminUserInfo().CurrentOrgId)
  15161. // fmt.Println(result)
  15162. //
  15163. // var dat map[string]interface{}
  15164. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  15165. // fmt.Println(dat)
  15166. // } else {
  15167. // fmt.Println(err)
  15168. // }
  15169. // userJSONBytes, _ := json.Marshal(dat)
  15170. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  15171. // utils.ErrorLog("解析失败:%v", err)
  15172. // //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15173. // adminUser := c.GetAdminUserInfo()
  15174. // errlog := &models.HisOrderError{
  15175. // UserOrgId: adminUser.CurrentOrgId,
  15176. // Ctime: time.Now().Unix(),
  15177. // Mtime: time.Now().Unix(),
  15178. // ErrMsg: res.ErrMsg + "解析失败",
  15179. // Status: 1,
  15180. // PatientId: order_id,
  15181. // Stage: 10106,
  15182. // }
  15183. // service.CreateErrMsgLog(errlog)
  15184. // continue
  15185. // }
  15186. // }
  15187. //
  15188. // if res.Infcode != 0 {
  15189. // adminUser := c.GetAdminUserInfo()
  15190. // errlog := &models.HisOrderError{
  15191. // UserOrgId: adminUser.CurrentOrgId,
  15192. // Ctime: time.Now().Unix(),
  15193. // Mtime: time.Now().Unix(),
  15194. // ErrMsg: res.ErrMsg,
  15195. // Status: 1,
  15196. // PatientId: order_id,
  15197. // Stage: 10106,
  15198. // }
  15199. // service.CreateErrMsgLog(errlog)
  15200. // continue
  15201. // } else {
  15202. // hisFundSettleListResult := &models.HisFundSettleListResult{
  15203. // Number: res.Output.SetlListId,
  15204. // Status: 1,
  15205. // Ctime: time.Now().Unix(),
  15206. // Mtime: time.Now().Unix(),
  15207. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15208. // IsUpload: 1,
  15209. // OrderId: order_id,
  15210. // }
  15211. // service.CreateUploadRecord(hisFundSettleListResult)
  15212. // continue
  15213. // }
  15214. // }
  15215. //}
  15216. func (c *HisApiController) GetOrgInfo() {
  15217. miConfig, _ := service.FindMedicalInsuranceInfo(4)
  15218. service.Gdyb1201("", miConfig.OrgName, "1122", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1, "")
  15219. }
  15220. func (c *HisApiController) GetHisPatientInfo() {
  15221. medical_insurance_card := c.GetString("medical_insurance_card")
  15222. id_card_type, _ := c.GetInt64("id_card_type")
  15223. id_card := c.GetString("id_card")
  15224. adminInfo := c.GetAdminUserInfo()
  15225. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  15226. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  15227. appRole, _ := service.GetAppRole(adminInfo.CurrentOrgId)
  15228. IdCardNo := ""
  15229. if id_card_type == 1 {
  15230. IdCardNo = medical_insurance_card
  15231. } else if id_card_type == 2 {
  15232. IdCardNo = id_card
  15233. }
  15234. if config.IsOpen == 1 {
  15235. 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
  15236. resp, requestErr := http.Get(api)
  15237. if requestErr != nil {
  15238. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15239. return
  15240. }
  15241. defer resp.Body.Close()
  15242. body, ioErr := ioutil.ReadAll(resp.Body)
  15243. if ioErr != nil {
  15244. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  15245. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15246. return
  15247. }
  15248. var respJSON map[string]interface{}
  15249. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  15250. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15251. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15252. return
  15253. }
  15254. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  15255. userJSONBytes, _ := json.Marshal(userJSON)
  15256. var res ResultTwo
  15257. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  15258. utils.ErrorLog("解析失败:%v", err)
  15259. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15260. return
  15261. }
  15262. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15263. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15264. infoStr := string(Iinfos)
  15265. idetinfoStr := string(Idetinfos)
  15266. if res.Infcode == 0 {
  15267. his := models.VMHisPatient{
  15268. Status: 1,
  15269. Ctime: time.Now().Unix(),
  15270. Mtime: time.Now().Unix(),
  15271. PsnNo: res.Output.Baseinfo.PsnNo,
  15272. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15273. Certno: res.Output.Baseinfo.Certno,
  15274. PsnName: res.Output.Baseinfo.PsnName,
  15275. Gend: res.Output.Baseinfo.Gend,
  15276. Naty: res.Output.Baseinfo.Naty,
  15277. Iinfo: infoStr,
  15278. Idetinfo: idetinfoStr,
  15279. UserOrgId: adminInfo.CurrentOrgId,
  15280. IsReturn: 1,
  15281. IdCardType: id_card_type,
  15282. }
  15283. c.ServeSuccessJSON(map[string]interface{}{
  15284. "info": his,
  15285. })
  15286. } else {
  15287. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15288. return
  15289. }
  15290. }
  15291. }
  15292. //func GetBasBaseInfo() (jsonStr string, err error) {
  15293. //
  15294. // handle := syscall.NewLazyDLL("SSCard.dll")
  15295. // add := handle.NewProc("ReadCardBas")
  15296. // str := make([]byte, 1024)
  15297. // str1 := make([]byte, 1024)
  15298. // ret, _, _ := add.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  15299. // fmt.Println(ConvertToString(string(str), "gbk", "utf-8"))
  15300. //
  15301. // fmt.Println(ConvertToString(string(str1), "gbk", "utf-8"))
  15302. //
  15303. // fmt.Println("> Add(4,5)的结果为:", ret)
  15304. // handle.Release()
  15305. //
  15306. // return "", nil
  15307. //
  15308. //}
  15309. //func GetQRBaseInfo() (jsonStr string, err error) {
  15310. // handle := syscall.LoadDLL("SSCard.dll")
  15311. // ReadCardBas := handle.FindProc("GetQRBase")
  15312. //
  15313. // str := make([]byte, 256)
  15314. // str1 := make([]byte, 256)
  15315. // r, _, _ := ReadCardBas.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  15316. //
  15317. // fmt.Println(string(str))
  15318. // fmt.Println(r)
  15319. // return string(str), nil
  15320. //}
  15321. //func CardInit() int {
  15322. // DllTestDef := syscall.MustLoadDLL("SSCard.dll")
  15323. // add := DllTestDef.MustFindProc("Init")
  15324. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  15325. // if err != nil {
  15326. // fmt.Println("SSCard的运算结果为:", ret)
  15327. // }
  15328. // result := int(ret)
  15329. // return result
  15330. //}
  15331. //func CardInit() int {
  15332. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  15333. // if err != nil {
  15334. // fmt.Println("SSCard的运算结果为:", ret)
  15335. // }
  15336. // fmt.Println(err)
  15337. // result := int(ret)
  15338. // return result
  15339. //}
  15340. func IntPtr(n int) uintptr {
  15341. return uintptr(n)
  15342. }
  15343. func StrPtr(s string) uintptr {
  15344. return uintptr(unsafe.Pointer(syscall.StringBytePtr(s)))
  15345. }
  15346. type Result2001 struct {
  15347. Cainfo interface{} `json:"cainfo"`
  15348. ErrMsg string `json:"err_msg"`
  15349. InfRefmsgid string `json:"inf_refmsgid"`
  15350. Infcode int64 `json:"infcode"`
  15351. Output struct {
  15352. Trtinfo struct {
  15353. PsnNo string `json:"psn_no"`
  15354. TrtChkType string `json:"trt_chk_type"`
  15355. FundPayType string `json:"fund_pay_type"`
  15356. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  15357. Begndate string `json:"begndate"`
  15358. Enddate string `json:"enddate"`
  15359. TrtChkRslt string `json:"trt_chk_rslt"`
  15360. } `json:"trtinfo"`
  15361. } `json:"output"`
  15362. RefmsgTime string `json:"refmsg_time"`
  15363. RespondTime string `json:"respond_time"`
  15364. Signtype interface{} `json:"signtype"`
  15365. WarnMsg interface{} `json:"warn_msg"`
  15366. }
  15367. type Result2001Org10265 struct {
  15368. Cainfo interface{} `json:"cainfo"`
  15369. ErrMsg string `json:"err_msg"`
  15370. InfRefmsgid string `json:"inf_refmsgid"`
  15371. Infcode string `json:"infcode"`
  15372. Output struct {
  15373. Trtinfo struct {
  15374. PsnNo string `json:"psn_no"`
  15375. TrtChkType string `json:"trt_chk_type"`
  15376. FundPayType string `json:"fund_pay_type"`
  15377. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  15378. Begndate string `json:"begndate"`
  15379. Enddate string `json:"enddate"`
  15380. TrtChkRslt string `json:"trt_chk_rslt"`
  15381. } `json:"trtinfo"`
  15382. } `json:"output"`
  15383. RefmsgTime string `json:"refmsg_time"`
  15384. RespondTime string `json:"respond_time"`
  15385. Signtype interface{} `json:"signtype"`
  15386. WarnMsg interface{} `json:"warn_msg"`
  15387. }
  15388. type ResultTwo struct {
  15389. ErrMsg string `json:"err_msg"`
  15390. InfRefmsgid string `json:"inf_refmsgid"`
  15391. Infcode int64 `json:"infcode"`
  15392. Output struct {
  15393. Baseinfo struct {
  15394. //Brdy string `json:"brdy"`
  15395. Certno string `json:"certno"`
  15396. Gend string `json:"gend"`
  15397. Naty string `json:"naty"`
  15398. PsnCertType string `json:"psn_cert_type"`
  15399. PsnName string `json:"psn_name"`
  15400. PsnNo string `json:"psn_no"`
  15401. } `json:"baseinfo"`
  15402. Idetinfo []interface{} `json:"idetinfo"`
  15403. Iinfo []struct {
  15404. Balc float64 `json:"balc"`
  15405. CvlservFlag string `json:"cvlserv_flag"`
  15406. EmpName string `json:"emp_name"`
  15407. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  15408. Insutype string `json:"insutype"`
  15409. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  15410. //PausInsuDate string `json:"paus_insu_date"`
  15411. //PsnInsuDate string `json:"psn_insu_date"`
  15412. PsnInsuStas string `json:"psn_insu_stas"`
  15413. PsnType string `json:"psn_type"`
  15414. } `json:"insuinfo"`
  15415. } `json:"output"`
  15416. RefmsgTime string `json:"refmsg_time"`
  15417. RespondTime string `json:"respond_time"`
  15418. Signtype interface{} `json:"signtype"`
  15419. WarnInfo interface{} `json:"warn_info"`
  15420. }
  15421. type ResultTwo10265 struct {
  15422. ErrMsg string `json:"err_msg"`
  15423. InfRefmsgid string `json:"inf_refmsgid"`
  15424. Infcode string `json:"infcode"`
  15425. Output struct {
  15426. Baseinfo struct {
  15427. //Brdy string `json:"brdy"`
  15428. Certno string `json:"certno"`
  15429. Gend string `json:"gend"`
  15430. Naty string `json:"naty"`
  15431. PsnCertType string `json:"psn_cert_type"`
  15432. PsnName string `json:"psn_name"`
  15433. PsnNo string `json:"psn_no"`
  15434. } `json:"baseinfo"`
  15435. Idetinfo []interface{} `json:"idetinfo"`
  15436. Iinfo []struct {
  15437. Balc float64 `json:"balc"`
  15438. CvlservFlag string `json:"cvlserv_flag"`
  15439. EmpName string `json:"emp_name"`
  15440. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  15441. Insutype string `json:"insutype"`
  15442. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  15443. PsnInsuStas string `json:"psn_insu_stas"`
  15444. PsnType string `json:"psn_type"`
  15445. } `json:"insuinfo"`
  15446. } `json:"output"`
  15447. RefmsgTime string `json:"refmsg_time"`
  15448. RespondTime string `json:"respond_time"`
  15449. Signtype interface{} `json:"signtype"`
  15450. WarnInfo interface{} `json:"warn_info"`
  15451. }
  15452. type ResultThree struct {
  15453. Cainfo interface{} `json:"cainfo"`
  15454. ErrMsg string `json:"err_msg"`
  15455. InfRefmsgid string `json:"inf_refmsgid"`
  15456. Infcode int64 `json:"infcode"`
  15457. Output struct {
  15458. Data struct {
  15459. IptOtpNo string `json:"ipt_otp_no"`
  15460. MdtrtID string `json:"mdtrt_id"`
  15461. PsnNo string `json:"psn_no"`
  15462. } `json:"data"`
  15463. } `json:"output"`
  15464. RefmsgTime string `json:"refmsg_time"`
  15465. RespondTime string `json:"respond_time"`
  15466. Signtype interface{} `json:"signtype"`
  15467. WarnMsg interface{} `json:"warn_msg"`
  15468. }
  15469. type ResultThree10265 struct {
  15470. Cainfo interface{} `json:"cainfo"`
  15471. ErrMsg string `json:"err_msg"`
  15472. InfRefmsgid string `json:"inf_refmsgid"`
  15473. Infcode string `json:"infcode"`
  15474. Output struct {
  15475. Data struct {
  15476. IptOtpNo string `json:"ipt_otp_no"`
  15477. MdtrtID string `json:"mdtrt_id"`
  15478. PsnNo string `json:"psn_no"`
  15479. } `json:"data"`
  15480. } `json:"output"`
  15481. RefmsgTime string `json:"refmsg_time"`
  15482. RespondTime string `json:"respond_time"`
  15483. Signtype interface{} `json:"signtype"`
  15484. WarnMsg interface{} `json:"warn_msg"`
  15485. }
  15486. type ResultFour struct {
  15487. Cainfo string `json:"cainfo"`
  15488. ErrMsg string `json:"err_msg"`
  15489. InfRefmsgid string `json:"inf_refmsgid"`
  15490. Infcode int64 `json:"infcode"`
  15491. Output struct {
  15492. Result []struct {
  15493. BasMednFlag string `json:"bas_medn_flag"`
  15494. ChldMedcFlag string `json:"chld_medc_flag"`
  15495. ChrgitmLv string `json:"chrgitm_lv"`
  15496. Cnt float64 `json:"cnt"`
  15497. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  15498. DrtReimFlag string `json:"drt_reim_flag"`
  15499. FeedetlSn string `json:"feedetl_sn"`
  15500. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  15501. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  15502. InscpScpAmt float64 `json:"inscp_scp_amt"`
  15503. ListSpItemFlag string `json:"list_sp_item_flag"`
  15504. LmtUsedFlag string `json:"lmt_used_flag"`
  15505. MedChrgitmType string `json:"med_chrgitm_type"`
  15506. Memo string `json:"memo"`
  15507. OverlmtAmt float64 `json:"overlmt_amt"`
  15508. PreselfpayAmt float64 `json:"preselfpay_amt"`
  15509. Pric float64 `json:"pric"`
  15510. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  15511. SelfpayProp float64 `json:"selfpay_prop"`
  15512. } `json:"result"`
  15513. } `json:"output"`
  15514. RefmsgTime string `json:"refmsg_time"`
  15515. RespondTime string `json:"respond_time"`
  15516. Signtype string `json:"signtype"`
  15517. WarnMsg string `json:"warn_msg"`
  15518. }
  15519. type ResultFour10265 struct {
  15520. Cainfo string `json:"cainfo"`
  15521. ErrMsg string `json:"err_msg"`
  15522. InfRefmsgid string `json:"inf_refmsgid"`
  15523. Infcode string `json:"infcode"`
  15524. Output struct {
  15525. Result []struct {
  15526. BasMednFlag string `json:"bas_medn_flag"`
  15527. ChldMedcFlag string `json:"chld_medc_flag"`
  15528. ChrgitmLv string `json:"chrgitm_lv"`
  15529. Cnt float64 `json:"cnt"`
  15530. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  15531. DrtReimFlag string `json:"drt_reim_flag"`
  15532. FeedetlSn string `json:"feedetl_sn"`
  15533. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  15534. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  15535. InscpScpAmt float64 `json:"inscp_scp_amt"`
  15536. ListSpItemFlag string `json:"list_sp_item_flag"`
  15537. LmtUsedFlag string `json:"lmt_used_flag"`
  15538. MedChrgitmType string `json:"med_chrgitm_type"`
  15539. Memo string `json:"memo"`
  15540. OverlmtAmt float64 `json:"overlmt_amt"`
  15541. PreselfpayAmt float64 `json:"preselfpay_amt"`
  15542. Pric float64 `json:"pric"`
  15543. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  15544. SelfpayProp float64 `json:"selfpay_prop"`
  15545. } `json:"result"`
  15546. } `json:"output"`
  15547. RefmsgTime string `json:"refmsg_time"`
  15548. RespondTime string `json:"respond_time"`
  15549. Signtype string `json:"signtype"`
  15550. WarnMsg string `json:"warn_msg"`
  15551. }
  15552. type ResultMemo struct {
  15553. InsuAdmdvs string `json:"insuAdmdvs"`
  15554. }
  15555. // [{"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}]
  15556. type ResultIDInfo struct {
  15557. Begntime string `json:"begntime"`
  15558. Endtime string `json:"endtime"`
  15559. Memo string `json:"memo"`
  15560. }
  15561. type ResultFive struct {
  15562. Balc float64 `json:"balc"`
  15563. CvlservFlag string `json:"cvlserv_flag"`
  15564. EmpName string `json:"emp_name"`
  15565. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  15566. Insutype string `json:"insutype"`
  15567. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  15568. PausInsuDate string `json:"paus_insu_date"`
  15569. PsnInsuDate string `json:"psn_insu_date"`
  15570. PsnInsuStas string `json:"psn_insu_stas"`
  15571. PsnType string `json:"psn_type"`
  15572. }
  15573. type ResultSix struct {
  15574. Cainfo interface{} `json:"cainfo"`
  15575. ErrMsg string `json:"err_msg"`
  15576. InfRefmsgid string `json:"inf_refmsgid"`
  15577. Infcode int64 `json:"infcode"`
  15578. Output struct {
  15579. } `json:"output"`
  15580. RefmsgTime string `json:"refmsg_time"`
  15581. RespondTime string `json:"respond_time"`
  15582. Signtype interface{} `json:"signtype"`
  15583. WarnMsg interface{} `json:"warn_msg"`
  15584. }
  15585. type FJ3507Result struct {
  15586. Cainfo interface{} `json:"cainfo"`
  15587. ErrMsg string `json:"err_msg"`
  15588. InfRefmsgid string `json:"inf_refmsgid"`
  15589. Infcode int64 `json:"infcode"`
  15590. Output struct {
  15591. retRslt string `json:"retRslt"`
  15592. msgRslt string `json:"msgRslt"`
  15593. } `json:"output"`
  15594. RefmsgTime string `json:"refmsg_time"`
  15595. RespondTime string `json:"respond_time"`
  15596. Signtype interface{} `json:"signtype"`
  15597. WarnMsg interface{} `json:"warn_msg"`
  15598. }
  15599. type Result2406 struct {
  15600. Cainfo interface{} `json:"cainfo"`
  15601. ErrMsg string `json:"err_msg"`
  15602. InfRefmsgid string `json:"inf_refmsgid"`
  15603. Infcode int64 `json:"infcode"`
  15604. Output struct {
  15605. Result struct {
  15606. IptPsnSpFlagDetlId string `json:"ipt_psn_sp_flag_detl_id"`
  15607. } `json:"result"`
  15608. } `json:"output"`
  15609. RefmsgTime string `json:"refmsg_time"`
  15610. RespondTime string `json:"respond_time"`
  15611. Signtype interface{} `json:"signtype"`
  15612. WarnMsg interface{} `json:"warn_msg"`
  15613. }
  15614. type GZResultSix struct {
  15615. Cainfo interface{} `json:"cainfo"`
  15616. ErrMsg string `json:"err_msg"`
  15617. InfRefmsgid string `json:"inf_refmsgid"`
  15618. Infcode int64 `json:"infcode"`
  15619. Output string `json:"output"`
  15620. RefmsgTime string `json:"refmsg_time"`
  15621. RespondTime string `json:"respond_time"`
  15622. Signtype interface{} `json:"signtype"`
  15623. WarnMsg interface{} `json:"warn_msg"`
  15624. }
  15625. type ResultSix10265 struct {
  15626. Cainfo interface{} `json:"cainfo"`
  15627. ErrMsg string `json:"err_msg"`
  15628. InfRefmsgid string `json:"inf_refmsgid"`
  15629. Infcode string `json:"infcode"`
  15630. Output struct {
  15631. } `json:"output"`
  15632. RefmsgTime string `json:"refmsg_time"`
  15633. RespondTime string `json:"respond_time"`
  15634. Signtype interface{} `json:"signtype"`
  15635. WarnMsg interface{} `json:"warn_msg"`
  15636. }
  15637. type ResultSeven struct {
  15638. Cainfo string `json:"cainfo"`
  15639. ErrMsg string `json:"err_msg"`
  15640. InfRefmsgid string `json:"inf_refmsgid"`
  15641. Infcode int64 `json:"infcode"`
  15642. Output struct {
  15643. Setlinfo struct {
  15644. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  15645. AcctPay float64 `json:"acct_pay"`
  15646. ActPayDedc float64 `json:"act_pay_dedc"`
  15647. Age float64 `json:"age"`
  15648. Balc float64 `json:"balc"`
  15649. Certno string `json:"certno"`
  15650. ClrOptins string `json:"clr_optins"`
  15651. ClrType string `json:"clr_type"`
  15652. ClrWay string `json:"clr_way"`
  15653. CvlservFlag string `json:"cvlserv_flag"`
  15654. CvlservPay float64 `json:"cvlserv_pay"`
  15655. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  15656. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  15657. Gend string `json:"gend"`
  15658. HifesPay float64 `json:"hifes_pay"`
  15659. HifmiPay float64 `json:"hifmi_pay"`
  15660. HifpPay float64 `json:"hifp_pay"`
  15661. HospPartAmt float64 `json:"hosp_part_amt"`
  15662. InscpScpAmt float64 `json:"inscp_scp_amt"`
  15663. Insutype string `json:"insutype"`
  15664. MafPay float64 `json:"maf_pay"`
  15665. MdtrtCertType string `json:"mdtrt_cert_type"`
  15666. HifobPay float64 `json:"hifob_pay"`
  15667. MdtrtID string `json:"mdtrt_id"`
  15668. MedType string `json:"med_type"`
  15669. MedfeeSumamt float64 `json:"medfee_sumamt"`
  15670. MedinsSetlID string `json:"medins_setl_id"`
  15671. Naty string `json:"naty"`
  15672. OthPay float64 `json:"oth_pay"`
  15673. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  15674. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  15675. PreselfpayAmt float64 `json:"preselfpay_amt"`
  15676. PsnCashPay float64 `json:"psn_cash_pay"`
  15677. PsnCertType string `json:"psn_cert_type"`
  15678. PsnName string `json:"psn_name"`
  15679. PsnNo string `json:"psn_no"`
  15680. PsnPartAmt float64 `json:"psn_part_amt"`
  15681. PsnType string `json:"psn_type"`
  15682. SetlID string `json:"setl_id"`
  15683. SetlTime string `json:"setl_time"`
  15684. } `json:"setlinfo"`
  15685. Setldetail interface{} `json:"setldetail"`
  15686. } `json:"output"`
  15687. RefmsgTime string `json:"refmsg_time"`
  15688. RespondTime string `json:"respond_time"`
  15689. Signtype interface{} `json:"signtype"`
  15690. WarnMsg interface{} `json:"warn_msg"`
  15691. }
  15692. type ResultSevenAH struct {
  15693. Cainfo string `json:"cainfo"`
  15694. ErrMsg string `json:"err_msg"`
  15695. InfRefmsgid string `json:"inf_refmsgid"`
  15696. Infcode int64 `json:"infcode"`
  15697. Output struct {
  15698. Setlinfo struct {
  15699. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  15700. AcctPay float64 `json:"acct_pay"`
  15701. ActPayDedc float64 `json:"act_pay_dedc"`
  15702. Age float64 `json:"age"`
  15703. Balc float64 `json:"balc"`
  15704. Certno string `json:"certno"`
  15705. ClrOptins string `json:"clr_optins"`
  15706. ClrType string `json:"clr_type"`
  15707. ClrWay string `json:"clr_way"`
  15708. CvlservFlag string `json:"cvlserv_flag"`
  15709. CvlservPay float64 `json:"cvlserv_pay"`
  15710. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  15711. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  15712. Gend string `json:"gend"`
  15713. HifesPay float64 `json:"hifes_pay"`
  15714. HifmiPay float64 `json:"hifmi_pay"`
  15715. HifpPay float64 `json:"hifp_pay"`
  15716. HospPartAmt float64 `json:"hosp_part_amt"`
  15717. InscpScpAmt float64 `json:"inscp_scp_amt"`
  15718. Insutype string `json:"insutype"`
  15719. MafPay float64 `json:"maf_pay"`
  15720. MdtrtCertType string `json:"mdtrt_cert_type"`
  15721. HifobPay float64 `json:"hifob_pay"`
  15722. MdtrtID string `json:"mdtrt_id"`
  15723. MedType string `json:"med_type"`
  15724. MedfeeSumamt float64 `json:"medfee_sumamt"`
  15725. MedinsSetlID string `json:"medins_setl_id"`
  15726. Naty string `json:"naty"`
  15727. OthPay float64 `json:"oth_pay"`
  15728. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  15729. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  15730. PreselfpayAmt float64 `json:"preselfpay_amt"`
  15731. PsnCashPay float64 `json:"psn_cash_pay"`
  15732. PsnCertType string `json:"psn_cert_type"`
  15733. PsnName string `json:"psn_name"`
  15734. PsnNo string `json:"psn_no"`
  15735. PsnPartAmt float64 `json:"psn_part_amt"`
  15736. PsnType string `json:"psn_type"`
  15737. SetlID string `json:"setl_id"`
  15738. SetlTime int64 `json:"setl_time"`
  15739. } `json:"setlinfo"`
  15740. Setldetail interface{} `json:"setldetail"`
  15741. } `json:"output"`
  15742. RefmsgTime string `json:"refmsg_time"`
  15743. RespondTime string `json:"respond_time"`
  15744. Signtype interface{} `json:"signtype"`
  15745. WarnMsg interface{} `json:"warn_msg"`
  15746. }
  15747. type ResultSeven10265 struct {
  15748. Cainfo string `json:"cainfo"`
  15749. ErrMsg string `json:"err_msg"`
  15750. InfRefmsgid string `json:"inf_refmsgid"`
  15751. Infcode string `json:"infcode"`
  15752. Output struct {
  15753. Setlinfo struct {
  15754. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  15755. AcctPay float64 `json:"acct_pay"`
  15756. ActPayDedc float64 `json:"act_pay_dedc"`
  15757. Age float64 `json:"age"`
  15758. Balc float64 `json:"balc"`
  15759. Certno string `json:"certno"`
  15760. ClrOptins string `json:"clr_optins"`
  15761. ClrType string `json:"clr_type"`
  15762. ClrWay string `json:"clr_way"`
  15763. CvlservFlag string `json:"cvlserv_flag"`
  15764. CvlservPay float64 `json:"cvlserv_pay"`
  15765. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  15766. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  15767. Gend string `json:"gend"`
  15768. HifesPay float64 `json:"hifes_pay"`
  15769. HifmiPay float64 `json:"hifmi_pay"`
  15770. HifpPay float64 `json:"hifp_pay"`
  15771. HospPartAmt float64 `json:"hosp_part_amt"`
  15772. InscpScpAmt float64 `json:"inscp_scp_amt"`
  15773. Insutype string `json:"insutype"`
  15774. MafPay float64 `json:"maf_pay"`
  15775. MdtrtCertType string `json:"mdtrt_cert_type"`
  15776. HifobPay float64 `json:"hifob_pay"`
  15777. MdtrtID string `json:"mdtrt_id"`
  15778. MedType string `json:"med_type"`
  15779. MedfeeSumamt float64 `json:"medfee_sumamt"`
  15780. MedinsSetlID string `json:"medins_setl_id"`
  15781. Naty string `json:"naty"`
  15782. OthPay float64 `json:"oth_pay"`
  15783. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  15784. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  15785. PreselfpayAmt float64 `json:"preselfpay_amt"`
  15786. PsnCashPay float64 `json:"psn_cash_pay"`
  15787. PsnCertType string `json:"psn_cert_type"`
  15788. PsnName string `json:"psn_name"`
  15789. PsnNo string `json:"psn_no"`
  15790. PsnPartAmt float64 `json:"psn_part_amt"`
  15791. PsnType string `json:"psn_type"`
  15792. SetlID string `json:"setl_id"`
  15793. SetlTime string `json:"setl_time"`
  15794. } `json:"setlinfo"`
  15795. Setldetail interface{} `json:"setldetail"`
  15796. } `json:"output"`
  15797. RefmsgTime string `json:"refmsg_time"`
  15798. RespondTime string `json:"respond_time"`
  15799. Signtype interface{} `json:"signtype"`
  15800. WarnMsg interface{} `json:"warn_msg"`
  15801. }
  15802. type ResultSeven10265Two struct {
  15803. Cainfo string `json:"cainfo"`
  15804. ErrMsg string `json:"err_msg"`
  15805. InfRefmsgid string `json:"inf_refmsgid"`
  15806. Infcode string `json:"infcode"`
  15807. Output struct {
  15808. Setlinfo struct {
  15809. AcctMulaidPay string `json:"acct_mulaid_pay"`
  15810. AcctPay float64 `json:"acct_pay"`
  15811. ActPayDedc float64 `json:"act_pay_dedc"`
  15812. Age float64 `json:"age"`
  15813. Balc float64 `json:"balc"`
  15814. Certno string `json:"certno"`
  15815. ClrOptins string `json:"clr_optins"`
  15816. ClrType string `json:"clr_type"`
  15817. ClrWay string `json:"clr_way"`
  15818. CvlservFlag string `json:"cvlserv_flag"`
  15819. CvlservPay float64 `json:"cvlserv_pay"`
  15820. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  15821. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  15822. Gend string `json:"gend"`
  15823. HifesPay float64 `json:"hifes_pay"`
  15824. HifmiPay float64 `json:"hifmi_pay"`
  15825. HifpPay float64 `json:"hifp_pay"`
  15826. HospPartAmt string `json:"hosp_part_amt"`
  15827. InscpScpAmt float64 `json:"inscp_scp_amt"`
  15828. Insutype string `json:"insutype"`
  15829. MafPay float64 `json:"maf_pay"`
  15830. MdtrtCertType string `json:"mdtrt_cert_type"`
  15831. HifobPay float64 `json:"hifob_pay"`
  15832. MdtrtID string `json:"mdtrt_id"`
  15833. MedType string `json:"med_type"`
  15834. MedfeeSumamt float64 `json:"medfee_sumamt"`
  15835. MedinsSetlID string `json:"medins_setl_id"`
  15836. Naty string `json:"naty"`
  15837. OthPay float64 `json:"oth_pay"`
  15838. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  15839. PoolPropSelfpay string `json:"pool_prop_selfpay"`
  15840. PreselfpayAmt float64 `json:"preselfpay_amt"`
  15841. PsnCashPay float64 `json:"psn_cash_pay"`
  15842. PsnCertType string `json:"psn_cert_type"`
  15843. PsnName string `json:"psn_name"`
  15844. PsnNo string `json:"psn_no"`
  15845. PsnPartAmt float64 `json:"psn_part_amt"`
  15846. PsnType string `json:"psn_type"`
  15847. SetlID string `json:"setl_id"`
  15848. SetlTime string `json:"setl_time"`
  15849. } `json:"setlinfo"`
  15850. Setldetail interface{} `json:"setldetail"`
  15851. } `json:"output"`
  15852. RefmsgTime string `json:"refmsg_time"`
  15853. RespondTime string `json:"respond_time"`
  15854. Signtype interface{} `json:"signtype"`
  15855. WarnMsg interface{} `json:"warn_msg"`
  15856. }
  15857. type GZResultSeven10265Two struct {
  15858. Cainfo string `json:"cainfo"`
  15859. ErrMsg string `json:"err_msg"`
  15860. InfRefmsgid string `json:"inf_refmsgid"`
  15861. Infcode int64 `json:"infcode"`
  15862. Output struct {
  15863. Setlinfo struct {
  15864. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  15865. AcctPay float64 `json:"acct_pay"`
  15866. ActPayDedc float64 `json:"act_pay_dedc"`
  15867. Age float64 `json:"age"`
  15868. Balc float64 `json:"balc"`
  15869. Certno string `json:"certno"`
  15870. ClrOptins string `json:"clr_optins"`
  15871. ClrType string `json:"clr_type"`
  15872. ClrWay string `json:"clr_way"`
  15873. CvlservFlag string `json:"cvlserv_flag"`
  15874. CvlservPay float64 `json:"cvlserv_pay"`
  15875. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  15876. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  15877. Gend string `json:"gend"`
  15878. HifesPay float64 `json:"hifes_pay"`
  15879. HifmiPay float64 `json:"hifmi_pay"`
  15880. HifpPay float64 `json:"hifp_pay"`
  15881. HospPartAmt float64 `json:"hosp_part_amt"`
  15882. InscpScpAmt float64 `json:"inscp_scp_amt"`
  15883. Insutype string `json:"insutype"`
  15884. MafPay float64 `json:"maf_pay"`
  15885. MdtrtCertType string `json:"mdtrt_cert_type"`
  15886. HifobPay float64 `json:"hifob_pay"`
  15887. MdtrtID string `json:"mdtrt_id"`
  15888. MedType string `json:"med_type"`
  15889. MedfeeSumamt float64 `json:"medfee_sumamt"`
  15890. MedinsSetlID string `json:"medins_setl_id"`
  15891. Naty string `json:"naty"`
  15892. OthPay float64 `json:"oth_pay"`
  15893. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  15894. PoolPropSelfpay string `json:"pool_prop_selfpay"`
  15895. PreselfpayAmt float64 `json:"preselfpay_amt"`
  15896. PsnCashPay float64 `json:"psn_cash_pay"`
  15897. PsnCertType string `json:"psn_cert_type"`
  15898. PsnName string `json:"psn_name"`
  15899. PsnNo string `json:"psn_no"`
  15900. PsnPartAmt float64 `json:"psn_part_amt"`
  15901. PsnType string `json:"psn_type"`
  15902. SetlID string `json:"setl_id"`
  15903. SetlTime string `json:"setl_time"`
  15904. } `json:"setlinfo"`
  15905. Setldetail interface{} `json:"setldetail"`
  15906. } `json:"output"`
  15907. RefmsgTime string `json:"refmsg_time"`
  15908. RespondTime string `json:"respond_time"`
  15909. Signtype interface{} `json:"signtype"`
  15910. WarnMsg interface{} `json:"warn_msg"`
  15911. }
  15912. type ResultEight struct {
  15913. Cainfo string `json:"cainfo"`
  15914. ErrMsg string `json:"err_msg"`
  15915. InfRefmsgid string `json:"inf_refmsgid"`
  15916. Infcode int64 `json:"infcode"`
  15917. Output struct {
  15918. Stmtinfo struct {
  15919. SetlOptins string `json:"setl_optins"`
  15920. StmtRslt string `json:"stmt_rslt"`
  15921. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  15922. } `json:"stmtinfo"`
  15923. } `json:"output"`
  15924. RefmsgTime string `json:"refmsg_time"`
  15925. RespondTime string `json:"respond_time"`
  15926. Signtype interface{} `json:"signtype"`
  15927. WarnMsg interface{} `json:"warn_msg"`
  15928. }
  15929. type ResultEightFor10188 struct {
  15930. Cainfo string `json:"cainfo"`
  15931. ErrMsg string `json:"err_msg"`
  15932. InfRefmsgid string `json:"inf_refmsgid"`
  15933. Infcode string `json:"infcode"`
  15934. Output struct {
  15935. Stmtinfo struct {
  15936. SetlOptins string `json:"setl_optins"`
  15937. StmtRslt string `json:"stmt_rslt"`
  15938. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  15939. } `json:"stmtinfo"`
  15940. } `json:"output"`
  15941. RefmsgTime string `json:"refmsg_time"`
  15942. RespondTime string `json:"respond_time"`
  15943. Signtype interface{} `json:"signtype"`
  15944. WarnMsg interface{} `json:"warn_msg"`
  15945. }
  15946. type ResultNine struct {
  15947. Cainfo string `json:"cainfo"`
  15948. ErrMsg string `json:"err_msg"`
  15949. InfRefmsgid string `json:"inf_refmsgid"`
  15950. Infcode int64 `json:"infcode"`
  15951. Output struct {
  15952. FileQuryNo string `json:"file_qury_no"`
  15953. } `json:"output"`
  15954. RefmsgTime string `json:"refmsg_time"`
  15955. RespondTime string `json:"respond_time"`
  15956. Signtype interface{} `json:"signtype"`
  15957. WarnMsg interface{} `json:"warn_msg"`
  15958. }
  15959. type ResultTen struct {
  15960. Cainfo string `json:"cainfo"`
  15961. ErrMsg string `json:"err_msg"`
  15962. InfRefmsgid string `json:"inf_refmsgid"`
  15963. Infcode int64 `json:"infcode"`
  15964. Output struct {
  15965. Fileinfo struct {
  15966. DldEndtime string `json:"dld_endtime"`
  15967. FileQuryNo string `json:"file_qury_no"`
  15968. Filename string `json:"filename"`
  15969. } `json:"fileinfo"`
  15970. } `json:"output"`
  15971. RefmsgTime string `json:"refmsg_time"`
  15972. RespondTime string `json:"respond_time"`
  15973. Signtype interface{} `json:"signtype"`
  15974. WarnMsg interface{} `json:"warn_msg"`
  15975. }
  15976. type Result5262 struct {
  15977. ErrMsg string `json:"err_msg"`
  15978. InfRefmsgid string `json:"inf_refmsgid"`
  15979. Infcode int64 `json:"infcode"`
  15980. Output struct {
  15981. PageInfo struct {
  15982. Size int `json:"size"`
  15983. RecordCounts int `json:"record_counts"`
  15984. } `json:"page_info"`
  15985. Idetinfo []interface{} `json:"idetinfo"`
  15986. Result []struct {
  15987. SetlID string `json:"setl_id"`
  15988. MedinsSetlID string `json:"medins_setl_id,omitempty"`
  15989. MdtrtID string `json:"mdtrt_id"`
  15990. InitSetlID string `json:"init_setl_id,omitempty"`
  15991. PsnNo string `json:"psn_no"`
  15992. PsnInsuRltsID string `json:"psn_insu_rlts_id,omitempty"`
  15993. PsnName string `json:"psn_name"`
  15994. PsnCertType string `json:"psn_cert_type"`
  15995. Certno string `json:"certno"`
  15996. Gend string `json:"gend,omitempty"`
  15997. Naty string `json:"naty,omitempty"`
  15998. Brdy string `json:"brdy,omitempty"`
  15999. Age float64 `json:"age,omitempty"`
  16000. Insutype string `json:"insutype,omitempty"`
  16001. PsnType string `json:"psn_type"`
  16002. CvlservFlag string `json:"cvlserv_flag"`
  16003. CvlservLv string `json:"cvlserv_lv,omitempty"`
  16004. SpPsnType string `json:"sp_psn_type,omitempty"`
  16005. SpPsnTypeLv string `json:"sp_psn_type_lv,omitempty"`
  16006. ClctGrde string `json:"clct_grde,omitempty"`
  16007. FlxempeFlag string `json:"flxempe_flag,omitempty"`
  16008. NwbFlag string `json:"nwb_flag,omitempty"`
  16009. InsuAdmdvs string `json:"insu_admdvs"`
  16010. EmpNo string `json:"emp_no,omitempty"`
  16011. EmpName string `json:"emp_name,omitempty"`
  16012. EmpType string `json:"emp_type,omitempty"`
  16013. EconType string `json:"econ_type,omitempty"`
  16014. AfilIndu string `json:"afil_indu,omitempty"`
  16015. AfilRlts string `json:"afil_rlts,omitempty"`
  16016. EmpMgtType string `json:"emp_mgt_type,omitempty"`
  16017. PayLoc string `json:"pay_loc,omitempty"`
  16018. FixmedinsCode string `json:"fixmedins_code"`
  16019. FixmedinsName string `json:"fixmedins_name"`
  16020. HospLv string `json:"hosp_lv,omitempty"`
  16021. FixBlngAdmdvs string `json:"fix_blng_admdvs,omitempty"`
  16022. LmtpricHospLv string `json:"lmtpric_hosp_lv,omitempty"`
  16023. DedcHospLv string `json:"dedc_hosp_lv,omitempty"`
  16024. Begndate string `json:"begndate"`
  16025. Enddate string `json:"enddate"`
  16026. SetlTime string `json:"setl_time"`
  16027. MdtrtCertType string `json:"mdtrt_cert_type,omitempty"`
  16028. MdtrtCertNo string `json:"mdtrt_cert_no,omitempty"`
  16029. MedType string `json:"med_type"`
  16030. SetlType string `json:"setl_type,omitempty"`
  16031. ClrType string `json:"clr_type,omitempty"`
  16032. ClrWay string `json:"clr_way,omitempty"`
  16033. PsnSetlway string `json:"psn_setlway,omitempty"`
  16034. ClrOptins string `json:"clr_optins,omitempty"`
  16035. MedfeeSumamt float64 `json:"medfee_sumamt,omitempty"`
  16036. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt,omitempty"`
  16037. OverlmtSelfpay float64 `json:"overlmt_selfpay,omitempty"`
  16038. PreselfpayAmt float64 `json:"preselfpay_amt,omitempty"`
  16039. InscpAmt float64 `json:"inscp_amt,omitempty"`
  16040. DedcStd float64 `json:"dedc_std,omitempty"`
  16041. CrtDedc float64 `json:"crt_dedc,omitempty"`
  16042. ActPayDedc float64 `json:"act_pay_dedc,omitempty"`
  16043. HifpPay float64 `json:"hifp_pay,omitempty"`
  16044. PoolPropSelfpay float64 `json:"pool_prop_selfpay,omitempty"`
  16045. HiAgreSumfee float64 `json:"hi_agre_sumfee,omitempty"`
  16046. CvlservPay float64 `json:"cvlserv_pay,omitempty"`
  16047. HifesPay float64 `json:"hifes_pay,omitempty"`
  16048. HifmiPay float64 `json:"hifmi_pay,omitempty"`
  16049. HifobPay float64 `json:"hifob_pay,omitempty"`
  16050. HifdmPay float64 `json:"hifdm_pay,omitempty"`
  16051. MafPay float64 `json:"maf_pay,omitempty"`
  16052. OthfundPay float64 `json:"othfund_pay,omitempty"`
  16053. FundPaySumamt float64 `json:"fund_pay_sumamt,omitempty"`
  16054. PsnPay float64 `json:"psn_pay,omitempty"`
  16055. AcctPay float64 `json:"acct_pay,omitempty"`
  16056. CashPayamt float64 `json:"cash_payamt,omitempty"`
  16057. OwnpayHospPart float64 `json:"ownpay_hosp_part,omitempty"`
  16058. Balc float64 `json:"balc,omitempty"`
  16059. AcctMulaidPay float64 `json:"acct_mulaid_pay,omitempty"`
  16060. RefdSetlFlag string `json:"refd_setl_flag,omitempty"`
  16061. CalIptCnt string `json:"cal_ipt_cnt,omitempty"`
  16062. SetlCashpayWay string `json:"setl_cashpay_way,omitempty"`
  16063. Year string `json:"year,omitempty"`
  16064. DiseNo string `json:"dise_no,omitempty"`
  16065. DiseName string `json:"dise_name,omitempty"`
  16066. Invono string `json:"invono,omitempty"`
  16067. ManlReimRea string `json:"manl_reim_rea,omitempty"`
  16068. ValiFlag string `json:"vali_flag,omitempty"`
  16069. Memo string `json:"memo,omitempty"`
  16070. Rid string `json:"rid"`
  16071. UpdtTime string `json:"updt_time,omitempty"`
  16072. CrterID string `json:"crter_id,omitempty"`
  16073. CrterName string `json:"crter_name,omitempty"`
  16074. CrteTime string `json:"crte_time,omitempty"`
  16075. CrteOptinsNo string `json:"crte_optins_no,omitempty"`
  16076. OpterID string `json:"opter_id,omitempty"`
  16077. OpterName string `json:"opter_name,omitempty"`
  16078. OptTime string `json:"opt_time,omitempty"`
  16079. OptinsNo string `json:"optins_no,omitempty"`
  16080. PoolareaNo string `json:"poolarea_no,omitempty"`
  16081. } `json:"result"`
  16082. } `json:"output"`
  16083. RefmsgTime string `json:"refmsg_time"`
  16084. RespondTime string `json:"respond_time"`
  16085. Signtype interface{} `json:"signtype"`
  16086. WarnInfo interface{} `json:"warn_info"`
  16087. }
  16088. type Result5267 struct {
  16089. ErrMsg string `json:"err_msg"`
  16090. InfRefmsgid string `json:"inf_refmsgid"`
  16091. Infcode int64 `json:"infcode"`
  16092. Output struct {
  16093. PageInfo struct {
  16094. Size int `json:"size"`
  16095. RecordCounts int `json:"record_counts"`
  16096. } `json:"pageinfo"`
  16097. Result []struct {
  16098. SetlID string `json:"setl_id"`
  16099. ClrOptins string `json:"clr_optins"`
  16100. MedinsSetlID string `json:"medins_setl_id,omitempty"`
  16101. MdtrtID string `json:"mdtrt_id"`
  16102. InitSetlID string `json:"init_setl_id,omitempty"`
  16103. PsnNo string `json:"psn_no"`
  16104. PsnInsuRltsID string `json:"psn_insu_rlts_id,omitempty"`
  16105. PsnName string `json:"psn_name"`
  16106. PsnCertType string `json:"psn_cert_type"`
  16107. Certno string `json:"certno"`
  16108. Gend string `json:"gend,omitempty"`
  16109. Naty string `json:"naty,omitempty"`
  16110. Brdy string `json:"brdy,omitempty"`
  16111. Age float64 `json:"age,omitempty"`
  16112. Insutype string `json:"insutype,omitempty"`
  16113. PsnType string `json:"psn_type"`
  16114. CvlservFlag string `json:"cvlserv_flag"`
  16115. CvlservLv string `json:"cvlserv_lv,omitempty"`
  16116. SpPsnType string `json:"sp_psn_type,omitempty"`
  16117. SpPsnTypeLv string `json:"sp_psn_type_lv,omitempty"`
  16118. ClctGrde string `json:"clct_grde,omitempty"`
  16119. FlxempeFlag string `json:"flxempe_flag,omitempty"`
  16120. NwbFlag string `json:"nwb_flag,omitempty"`
  16121. InsuAdmdvs string `json:"insu_admdvs"`
  16122. EmpNo string `json:"emp_no,omitempty"`
  16123. EmpName string `json:"emp_name,omitempty"`
  16124. EmpType string `json:"emp_type,omitempty"`
  16125. EconType string `json:"econ_type,omitempty"`
  16126. AfilIndu string `json:"afil_indu,omitempty"`
  16127. AfilRlts string `json:"afil_rlts,omitempty"`
  16128. EmpMgtType string `json:"emp_mgt_type,omitempty"`
  16129. PayLoc string `json:"pay_loc,omitempty"`
  16130. FixmedinsCode string `json:"fixmedins_code"`
  16131. FixmedinsName string `json:"fixmedins_name"`
  16132. HospLv string `json:"hosp_lv,omitempty"`
  16133. FixBlngAdmdvs string `json:"fix_blng_admdvs,omitempty"`
  16134. LmtpricHospLv string `json:"lmtpric_hosp_lv,omitempty"`
  16135. DedcHospLv string `json:"dedc_hosp_lv,omitempty"`
  16136. Begndate string `json:"begndate,omitempty"`
  16137. Enddate string `json:"enddate,omitempty"`
  16138. SetlTime string `json:"setl_time,omitempty"`
  16139. MdtrtCertType string `json:"mdtrt_cert_type,omitempty"`
  16140. MdtrtCertNo string `json:"mdtrt_cert_no,omitempty"`
  16141. MedType string `json:"med_type"`
  16142. SetlType string `json:"setl_type,omitempty"`
  16143. ClrType string `json:"clr_type,omitempty"`
  16144. ClrWay string `json:"clr_way,omitempty"`
  16145. PsnSetlway string `json:"psn_setlway,omitempty"`
  16146. MedfeeSumamt float64 `json:"medfee_sumamt,omitempty"`
  16147. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt,omitempty"`
  16148. OverlmtSelfpay float64 `json:"overlmt_selfpay,omitempty"`
  16149. PreselfpayAmt float64 `json:"preselfpay_amt,omitempty"`
  16150. InscpAmt float64 `json:"inscp_amt,omitempty"`
  16151. DedcStd float64 `json:"dedc_std,omitempty"`
  16152. CrtDedc float64 `json:"crt_dedc,omitempty"`
  16153. ActPayDedc float64 `json:"act_pay_dedc,omitempty"`
  16154. HifpPay float64 `json:"hifp_pay,omitempty"`
  16155. PoolPropSelfpay float64 `json:"pool_prop_selfpay,omitempty"`
  16156. HiAgreSumfee float64 `json:"hi_agre_sumfee,omitempty"`
  16157. CvlservPay float64 `json:"cvlserv_pay,omitempty"`
  16158. HifesPay float64 `json:"hifes_pay,omitempty"`
  16159. HifmiPay float64 `json:"hifmi_pay,omitempty"`
  16160. HifobPay float64 `json:"hifob_pay,omitempty"`
  16161. HifdmPay float64 `json:"hifdm_pay,omitempty"`
  16162. MafPay float64 `json:"maf_pay,omitempty"`
  16163. OthfundPay float64 `json:"othfund_pay,omitempty"`
  16164. FundPaySumamt float64 `json:"fund_pay_sumamt,omitempty"`
  16165. PsnPay float64 `json:"psn_pay,omitempty"`
  16166. AcctPay float64 `json:"acct_pay,omitempty"`
  16167. CashPayamt float64 `json:"cash_payamt,omitempty"`
  16168. OwnpayHospPart float64 `json:"ownpay_hosp_part,omitempty"`
  16169. Balc float64 `json:"balc,omitempty"`
  16170. AcctMulaidPay float64 `json:"acct_mulaid_pay,omitempty"`
  16171. RefdSetlFlag string `json:"refd_setl_flag,omitempty"`
  16172. CalIptCnt string `json:"cal_ipt_cnt,omitempty"`
  16173. SetlCashpayWay string `json:"setl_cashpay_way,omitempty"`
  16174. Year string `json:"year,omitempty"`
  16175. DiseNo string `json:"dise_no,omitempty"`
  16176. DiseName string `json:"dise_name,omitempty"`
  16177. Invono string `json:"invono,omitempty"`
  16178. ManlReimRea string `json:"manl_reim_rea,omitempty"`
  16179. Memo string `json:"memo,omitempty"`
  16180. UpdtTime string `json:"updt_time,omitempty"`
  16181. OpterID string `json:"opter_id,omitempty"`
  16182. OpterName string `json:"opter_name,omitempty"`
  16183. OptTime string `json:"opt_time,omitempty"`
  16184. OptinsNo string `json:"optins_no,omitempty"`
  16185. PoolareaNo string `json:"poolarea_no,omitempty"`
  16186. } `json:"result"`
  16187. } `json:"output"`
  16188. RefmsgTime string `json:"refmsg_time"`
  16189. RespondTime string `json:"respond_time"`
  16190. Signtype interface{} `json:"signtype"`
  16191. WarnInfo interface{} `json:"warn_info"`
  16192. }
  16193. // type Autogenerated struct {
  16194. // Output struct {
  16195. // Setlinfo struct {
  16196. // SetlTime string `json:"setl_time"`
  16197. // CvlservPay float64 `json:"cvlserv_pay"`
  16198. // Year string `json:"year"`
  16199. // MedType string `json:"med_type"`
  16200. // PsnPay float64 `json:"psn_pay"`
  16201. // OpterID string `json:"opter_id"`
  16202. // Begndate string `json:"begndate"`
  16203. // FlxempeFlag string `json:"flxempe_flag"`
  16204. // HifmiPay float64 `json:"hifmi_pay"`
  16205. // PsnNo string `json:"psn_no"`
  16206. // ActPayDedc float64 `json:"act_pay_dedc"`
  16207. // MedinsSetlID interface{} `json:"medins_setl_id"`
  16208. // AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  16209. // ClrWay string `json:"clr_way"`
  16210. // OthPay float64 `json:"oth_pay"`
  16211. // Gend string `json:"gend"`
  16212. // MdtrtID string `json:"mdtrt_id"`
  16213. // AcctPay float64 `json:"acct_pay"`
  16214. // InscpScpAmt float64 `json:"inscp_scp_amt"`
  16215. // Insutype string `json:"insutype"`
  16216. // Invono interface{} `json:"invono"`
  16217. // Enddate string `json:"enddate"`
  16218. // CashPayamt float64 `json:"cash_payamt"`
  16219. // PsnType string `json:"psn_type"`
  16220. // FixmedinsName string `json:"fixmedins_name"`
  16221. // HifpPay float64 `json:"hifp_pay"`
  16222. // NewFlag interface{} `json:"new_flag"`
  16223. // OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  16224. // PreselfpayAmt float64 `json:"preselfpay_amt"`
  16225. // PayLoc string `json:"pay_loc"`
  16226. // ClrType string `json:"clr_type"`
  16227. // RefdSetlFlag string `json:"refd_setl_flag"`
  16228. // CvlservFlag string `json:"cvlserv_flag"`
  16229. // EmpName string `json:"emp_name"`
  16230. // Brdy string `json:"brdy"`
  16231. // Naty string `json:"naty"`
  16232. // Certno string `json:"certno"`
  16233. // DiseCode string `json:"dise_code"`
  16234. // FixmedinsCode string `json:"fixmedins_code"`
  16235. // DedcHospLv string `json:"dedc_hosp_lv"`
  16236. // OpterName string `json:"opter_name"`
  16237. // Balc float64 `json:"balc"`
  16238. // FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  16239. // PsnCertType string `json:"psn_cert_type"`
  16240. // HifobPay float64 `json:"hifob_pay"`
  16241. // MedfeeSumamt float64 `json:"medfee_sumamt"`
  16242. // HifesPay float64 `json:"hifes_pay"`
  16243. // FundPaySumamt float64 `json:"fund_pay_sumamt"`
  16244. // OptTime string `json:"opt_time"`
  16245. // FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  16246. // SetlID string `json:"setl_id"`
  16247. // MafPay float64 `json:"maf_pay"`
  16248. // PsnName string `json:"psn_name"`
  16249. // InsuOptins interface{} `json:"insu_optins"`
  16250. // PrefFundPay interface{} `json:"pref_fund_pay"`
  16251. // ClrOptins string `json:"clr_optins"`
  16252. // PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  16253. // DiseName string `json:"dise_name"`
  16254. // LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  16255. // Age float64 `json:"age"`
  16256. // DtrtCertType string `json:"dtrt_cert_type"`
  16257. // HospLv string `json:"hosp_lv"`
  16258. // } `json:"setlinfo"`
  16259. // Setldetail []struct {
  16260. // FundPayType string `json:"fund_pay_type"`
  16261. // FundPayamt float64 `json:"fund_payamt"`
  16262. // SetlProcInfo interface{} `json:"setl_proc_info"`
  16263. // CrtPaybLmtAmt interface{} `json:"crt_payb_lmt_amt"`
  16264. // InscpScpAmt interface{} `json:"inscp_scp_amt"`
  16265. // FundPayTypeName interface{} `json:"fund_pay_type_name"`
  16266. // PrefFundPay interface{} `json:"pref_fund_pay"`
  16267. // } `json:"setldetail"`
  16268. // } `json:"output"`
  16269. // Infcode int `json:"infcode"`
  16270. // WarnMsg interface{} `json:"warn_msg"`
  16271. // Cainfo interface{} `json:"cainfo"`
  16272. // ErrMsg interface{} `json:"err_msg"`
  16273. // RefmsgTime string `json:"refmsg_time"`
  16274. // Signtype interface{} `json:"signtype"`
  16275. // RespondTime string `json:"respond_time"`
  16276. // InfRefmsgid string `json:"inf_refmsgid"`
  16277. // }
  16278. type Result002 struct {
  16279. Cainfo interface{} `json:"cainfo"`
  16280. ErrMsg string `json:"err_msg"`
  16281. InfRefmsgid string `json:"inf_refmsgid"`
  16282. Infcode int64 `json:"infcode"`
  16283. Output struct {
  16284. RxFile string `json:"rx_file"`
  16285. SignDigest string `json:"sign_digest"`
  16286. SignCertSn string `json:"sign_cert_sn"`
  16287. SignCertDn string `json:"sign_cert_dn"`
  16288. } `json:"output"`
  16289. RefmsgTime string `json:"refmsg_time"`
  16290. RespondTime string `json:"respond_time"`
  16291. Signtype interface{} `json:"signtype"`
  16292. WarnMsg interface{} `json:"warn_msg"`
  16293. }
  16294. type Result003 struct {
  16295. Cainfo interface{} `json:"cainfo"`
  16296. ErrMsg string `json:"err_msg"`
  16297. InfRefmsgid string `json:"inf_refmsgid"`
  16298. Infcode int64 `json:"infcode"`
  16299. Output struct {
  16300. HiRxno string `json:"hi_rxno"`
  16301. RxStasCodg string `json:"rx_stas_codg"`
  16302. RxStasName string `json:"rx_stas_name"`
  16303. } `json:"output"`
  16304. RefmsgTime string `json:"refmsg_time"`
  16305. RespondTime string `json:"respond_time"`
  16306. Signtype interface{} `json:"signtype"`
  16307. WarnMsg interface{} `json:"warn_msg"`
  16308. }
  16309. type ResultEleven struct {
  16310. Cainfo string `json:"cainfo"`
  16311. ErrMsg string `json:"err_msg"`
  16312. InfRefmsgid string `json:"inf_refmsgid"`
  16313. Infcode int64 `json:"infcode"`
  16314. Output struct {
  16315. Setlinfo struct {
  16316. SetlTime string `json:"setl_time"`
  16317. CvlservPay float64 `json:"cvlserv_pay"`
  16318. Year string `json:"year"`
  16319. MedType string `json:"med_type"`
  16320. PsnPay float64 `json:"psn_pay"`
  16321. OpterID string `json:"opter_id"`
  16322. Begndate string `json:"begndate"`
  16323. FlxempeFlag string `json:"flxempe_flag"`
  16324. HifmiPay float64 `json:"hifmi_pay"`
  16325. PsnNo string `json:"psn_no"`
  16326. ActPayDedc float64 `json:"act_pay_dedc"`
  16327. MedinsSetlID interface{} `json:"medins_setl_id"`
  16328. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  16329. ClrWay string `json:"clr_way"`
  16330. OthPay float64 `json:"oth_pay"`
  16331. Gend string `json:"gend"`
  16332. MdtrtID string `json:"mdtrt_id"`
  16333. AcctPay float64 `json:"acct_pay"`
  16334. InscpScpAmt float64 `json:"inscp_scp_amt"`
  16335. Insutype string `json:"insutype"`
  16336. Invono interface{} `json:"invono"`
  16337. Enddate string `json:"enddate"`
  16338. CashPayamt float64 `json:"cash_payamt"`
  16339. PsnType string `json:"psn_type"`
  16340. FixmedinsName string `json:"fixmedins_name"`
  16341. HifpPay float64 `json:"hifp_pay"`
  16342. NewFlag interface{} `json:"new_flag"`
  16343. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  16344. PreselfpayAmt float64 `json:"preselfpay_amt"`
  16345. PayLoc string `json:"pay_loc"`
  16346. ClrType string `json:"clr_type"`
  16347. RefdSetlFlag string `json:"refd_setl_flag"`
  16348. CvlservFlag string `json:"cvlserv_flag"`
  16349. EmpName string `json:"emp_name"`
  16350. Brdy string `json:"brdy"`
  16351. Naty string `json:"naty"`
  16352. Certno string `json:"certno"`
  16353. DiseCode string `json:"dise_code"`
  16354. FixmedinsCode string `json:"fixmedins_code"`
  16355. DedcHospLv string `json:"dedc_hosp_lv"`
  16356. OpterName string `json:"opter_name"`
  16357. Balc float64 `json:"balc"`
  16358. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  16359. PsnCertType string `json:"psn_cert_type"`
  16360. HifobPay float64 `json:"hifob_pay"`
  16361. MedfeeSumamt float64 `json:"medfee_sumamt"`
  16362. HifesPay float64 `json:"hifes_pay"`
  16363. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  16364. OptTime string `json:"opt_time"`
  16365. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  16366. SetlID string `json:"setl_id"`
  16367. MafPay float64 `json:"maf_pay"`
  16368. PsnName string `json:"psn_name"`
  16369. InsuOptins interface{} `json:"insu_optins"`
  16370. PrefFundPay interface{} `json:"pref_fund_pay"`
  16371. ClrOptins string `json:"clr_optins"`
  16372. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  16373. DiseName string `json:"dise_name"`
  16374. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  16375. Age float64 `json:"age"`
  16376. DtrtCertType string `json:"dtrt_cert_type"`
  16377. HospLv string `json:"hosp_lv"`
  16378. PsnCashPay float64 `json:"psn_cash_pay"`
  16379. } `json:"setlinfo"`
  16380. } `json:"output"`
  16381. RefmsgTime string `json:"refmsg_time"`
  16382. RespondTime string `json:"respond_time"`
  16383. Signtype interface{} `json:"signtype"`
  16384. WarnMsg interface{} `json:"warn_msg"`
  16385. }
  16386. type ResultElevenah struct {
  16387. Cainfo string `json:"cainfo"`
  16388. ErrMsg string `json:"err_msg"`
  16389. InfRefmsgid string `json:"inf_refmsgid"`
  16390. Infcode int64 `json:"infcode"`
  16391. Output struct {
  16392. Setlinfo struct {
  16393. SetlTime int64 `json:"setl_time"`
  16394. CvlservPay float64 `json:"cvlserv_pay"`
  16395. Year string `json:"year"`
  16396. MedType string `json:"med_type"`
  16397. PsnPay float64 `json:"psn_pay"`
  16398. OpterID string `json:"opter_id"`
  16399. Begndate int64 `json:"begndate"`
  16400. FlxempeFlag string `json:"flxempe_flag"`
  16401. HifmiPay float64 `json:"hifmi_pay"`
  16402. PsnNo string `json:"psn_no"`
  16403. ActPayDedc float64 `json:"act_pay_dedc"`
  16404. MedinsSetlID interface{} `json:"medins_setl_id"`
  16405. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  16406. ClrWay string `json:"clr_way"`
  16407. OthPay float64 `json:"oth_pay"`
  16408. Gend string `json:"gend"`
  16409. MdtrtID string `json:"mdtrt_id"`
  16410. AcctPay float64 `json:"acct_pay"`
  16411. InscpScpAmt float64 `json:"inscp_scp_amt"`
  16412. Insutype string `json:"insutype"`
  16413. Invono interface{} `json:"invono"`
  16414. Enddate int64 `json:"enddate"`
  16415. CashPayamt float64 `json:"cash_payamt"`
  16416. PsnType string `json:"psn_type"`
  16417. FixmedinsName string `json:"fixmedins_name"`
  16418. HifpPay float64 `json:"hifp_pay"`
  16419. NewFlag interface{} `json:"new_flag"`
  16420. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  16421. PreselfpayAmt float64 `json:"preselfpay_amt"`
  16422. PayLoc string `json:"pay_loc"`
  16423. ClrType string `json:"clr_type"`
  16424. RefdSetlFlag string `json:"refd_setl_flag"`
  16425. CvlservFlag string `json:"cvlserv_flag"`
  16426. EmpName string `json:"emp_name"`
  16427. Brdy int64 `json:"brdy"`
  16428. Naty string `json:"naty"`
  16429. Certno string `json:"certno"`
  16430. DiseCode string `json:"dise_code"`
  16431. FixmedinsCode string `json:"fixmedins_code"`
  16432. DedcHospLv string `json:"dedc_hosp_lv"`
  16433. OpterName string `json:"opter_name"`
  16434. Balc float64 `json:"balc"`
  16435. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  16436. PsnCertType string `json:"psn_cert_type"`
  16437. HifobPay float64 `json:"hifob_pay"`
  16438. MedfeeSumamt float64 `json:"medfee_sumamt"`
  16439. HifesPay float64 `json:"hifes_pay"`
  16440. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  16441. OptTime int64 `json:"opt_time"`
  16442. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  16443. SetlID string `json:"setl_id"`
  16444. MafPay float64 `json:"maf_pay"`
  16445. PsnName string `json:"psn_name"`
  16446. InsuOptins interface{} `json:"insu_optins"`
  16447. PrefFundPay interface{} `json:"pref_fund_pay"`
  16448. ClrOptins string `json:"clr_optins"`
  16449. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  16450. DiseName string `json:"dise_name"`
  16451. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  16452. Age float64 `json:"age"`
  16453. DtrtCertType string `json:"dtrt_cert_type"`
  16454. HospLv string `json:"hosp_lv"`
  16455. PsnCashPay float64 `json:"psn_cash_pay"`
  16456. } `json:"setlinfo"`
  16457. } `json:"output"`
  16458. RefmsgTime string `json:"refmsg_time"`
  16459. RespondTime string `json:"respond_time"`
  16460. Signtype interface{} `json:"signtype"`
  16461. WarnMsg interface{} `json:"warn_msg"`
  16462. }
  16463. type ResultEleven10265 struct {
  16464. Cainfo string `json:"cainfo"`
  16465. ErrMsg string `json:"err_msg"`
  16466. InfRefmsgid string `json:"inf_refmsgid"`
  16467. Infcode string `json:"infcode"`
  16468. Output struct {
  16469. Setlinfo struct {
  16470. SetlTime string `json:"setl_time"`
  16471. CvlservPay float64 `json:"cvlserv_pay"`
  16472. Year string `json:"year"`
  16473. MedType string `json:"med_type"`
  16474. PsnPay float64 `json:"psn_pay"`
  16475. OpterID string `json:"opter_id"`
  16476. Begndate string `json:"begndate"`
  16477. FlxempeFlag string `json:"flxempe_flag"`
  16478. HifmiPay float64 `json:"hifmi_pay"`
  16479. PsnNo string `json:"psn_no"`
  16480. ActPayDedc float64 `json:"act_pay_dedc"`
  16481. MedinsSetlID interface{} `json:"medins_setl_id"`
  16482. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  16483. ClrWay string `json:"clr_way"`
  16484. OthPay float64 `json:"oth_pay"`
  16485. Gend string `json:"gend"`
  16486. MdtrtID string `json:"mdtrt_id"`
  16487. AcctPay float64 `json:"acct_pay"`
  16488. InscpScpAmt float64 `json:"inscp_scp_amt"`
  16489. Insutype string `json:"insutype"`
  16490. Invono interface{} `json:"invono"`
  16491. Enddate string `json:"enddate"`
  16492. CashPayamt float64 `json:"cash_payamt"`
  16493. PsnType string `json:"psn_type"`
  16494. FixmedinsName string `json:"fixmedins_name"`
  16495. HifpPay float64 `json:"hifp_pay"`
  16496. NewFlag interface{} `json:"new_flag"`
  16497. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  16498. PreselfpayAmt float64 `json:"preselfpay_amt"`
  16499. PayLoc string `json:"pay_loc"`
  16500. ClrType string `json:"clr_type"`
  16501. RefdSetlFlag string `json:"refd_setl_flag"`
  16502. CvlservFlag string `json:"cvlserv_flag"`
  16503. EmpName string `json:"emp_name"`
  16504. Brdy string `json:"brdy"`
  16505. Naty string `json:"naty"`
  16506. Certno string `json:"certno"`
  16507. DiseCode string `json:"dise_code"`
  16508. FixmedinsCode string `json:"fixmedins_code"`
  16509. DedcHospLv string `json:"dedc_hosp_lv"`
  16510. OpterName string `json:"opter_name"`
  16511. Balc float64 `json:"balc"`
  16512. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  16513. PsnCertType string `json:"psn_cert_type"`
  16514. HifobPay float64 `json:"hifob_pay"`
  16515. MedfeeSumamt float64 `json:"medfee_sumamt"`
  16516. HifesPay float64 `json:"hifes_pay"`
  16517. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  16518. OptTime string `json:"opt_time"`
  16519. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  16520. SetlID string `json:"setl_id"`
  16521. MafPay float64 `json:"maf_pay"`
  16522. PsnName string `json:"psn_name"`
  16523. InsuOptins interface{} `json:"insu_optins"`
  16524. PrefFundPay interface{} `json:"pref_fund_pay"`
  16525. ClrOptins string `json:"clr_optins"`
  16526. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  16527. DiseName string `json:"dise_name"`
  16528. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  16529. Age float64 `json:"age"`
  16530. DtrtCertType string `json:"dtrt_cert_type"`
  16531. HospLv string `json:"hosp_lv"`
  16532. PsnCashPay float64 `json:"psn_cash_pay"`
  16533. } `json:"setlinfo"`
  16534. } `json:"output"`
  16535. RefmsgTime string `json:"refmsg_time"`
  16536. RespondTime string `json:"respond_time"`
  16537. Signtype interface{} `json:"signtype"`
  16538. WarnMsg interface{} `json:"warn_msg"`
  16539. }
  16540. type ResultTwelve struct {
  16541. Cainfo string `json:"cainfo"`
  16542. ErrMsg string `json:"err_msg"`
  16543. InfRefmsgid string `json:"inf_refmsgid"`
  16544. Infcode int64 `json:"infcode"`
  16545. Output struct {
  16546. MdtrtId string `json:"mdtrt_id"`
  16547. ChrgBchno string `json:"chrg_bchno"`
  16548. PsnNo string `json:"psn_no"`
  16549. } `json:"output"`
  16550. RefmsgTime string `json:"refmsg_time"`
  16551. RespondTime string `json:"respond_time"`
  16552. Signtype interface{} `json:"signtype"`
  16553. WarnMsg interface{} `json:"warn_msg"`
  16554. }
  16555. type ResultThirteen struct {
  16556. ErrMsg string `json:"err_msg"`
  16557. InfRefmsgid string `json:"inf_refmsgid"`
  16558. Infcode int64 `json:"infcode"`
  16559. Output struct {
  16560. Result struct {
  16561. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  16562. } `json:"result"`
  16563. } `json:"output"`
  16564. RefmsgTime string `json:"refmsg_time"`
  16565. RespondTime string `json:"respond_time"`
  16566. Signtype interface{} `json:"signtype"`
  16567. WarnInfo interface{} `json:"warn_info"`
  16568. }
  16569. type ResultThirteen10265 struct {
  16570. ErrMsg string `json:"err_msg"`
  16571. InfRefmsgid string `json:"inf_refmsgid"`
  16572. Infcode string `json:"infcode"`
  16573. Output struct {
  16574. Result struct {
  16575. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  16576. } `json:"result"`
  16577. } `json:"output"`
  16578. RefmsgTime string `json:"refmsg_time"`
  16579. RespondTime string `json:"respond_time"`
  16580. Signtype interface{} `json:"signtype"`
  16581. WarnInfo interface{} `json:"warn_info"`
  16582. }
  16583. type ResultFourteen struct {
  16584. ErrMsg string `json:"err_msg"`
  16585. InfRefmsgid string `json:"inf_refmsgid"`
  16586. Infcode int64 `json:"infcode"`
  16587. Output struct {
  16588. } `json:"output"`
  16589. RefmsgTime string `json:"refmsg_time"`
  16590. RespondTime string `json:"respond_time"`
  16591. Signtype interface{} `json:"signtype"`
  16592. WarnInfo interface{} `json:"warn_info"`
  16593. }
  16594. type ResultCFYLJG001 struct {
  16595. ErrMsg string `json:"err_msg"`
  16596. InfRefmsgid string `json:"inf_refmsgid"`
  16597. Infcode int64 `json:"infcode"`
  16598. Output struct {
  16599. RxTraceCode string `json:"rx_trace_code"`
  16600. HiRxno string `json:"hi_rxno"`
  16601. } `json:"output"`
  16602. RefmsgTime string `json:"refmsg_time"`
  16603. RespondTime string `json:"respond_time"`
  16604. Signtype interface{} `json:"signtype"`
  16605. WarnInfo interface{} `json:"warn_info"`
  16606. }
  16607. type ResultCFYLJG007 struct {
  16608. ErrMsg string `json:"err_msg"`
  16609. InfRefmsgid string `json:"inf_refmsgid"`
  16610. Infcode int64 `json:"infcode"`
  16611. Output struct {
  16612. HiRxno string `json:"hi_rxno"`
  16613. RxStasName string `json:"rx_stas_name"`
  16614. RxUsedStasCodg string `json:"rx_used_stas_codg"`
  16615. Seltdelts []interface{} `json:"seltdelts"`
  16616. RxUsedStasName string `json:"rx_used_stas_name"`
  16617. RxStasCodg string `json:"rx_stas_codg"`
  16618. } `json:"output"`
  16619. RefmsgTime string `json:"refmsg_time"`
  16620. RespondTime string `json:"respond_time"`
  16621. Signtype interface{} `json:"signtype"`
  16622. WarnInfo interface{} `json:"warn_info"`
  16623. }
  16624. type ResultCFYLJG002 struct {
  16625. ErrMsg string `json:"err_msg"`
  16626. InfRefmsgid string `json:"inf_refmsgid"`
  16627. Infcode int64 `json:"infcode"`
  16628. Output struct {
  16629. RxFile string `json:"rx_file"`
  16630. SignDigest string `json:"sign_digest"`
  16631. SignCertSn string `json:"sign_cert_sn"`
  16632. SignCertDn string `json:"sign_cert_dn"`
  16633. } `json:"output"`
  16634. RefmsgTime string `json:"refmsg_time"`
  16635. RespondTime string `json:"respond_time"`
  16636. Signtype interface{} `json:"signtype"`
  16637. WarnInfo interface{} `json:"warn_info"`
  16638. }
  16639. type ResultCFYLJG003 struct {
  16640. ErrMsg string `json:"err_msg"`
  16641. InfRefmsgid string `json:"inf_refmsgid"`
  16642. Infcode int64 `json:"infcode"`
  16643. Output struct {
  16644. HiRxno string `json:"hi_rxno"`
  16645. RxStasCodg string `json:"rx_stas_codg"`
  16646. RxStasName string `json:"rx_stas_name"`
  16647. } `json:"output"`
  16648. RefmsgTime string `json:"refmsg_time"`
  16649. RespondTime string `json:"respond_time"`
  16650. Signtype interface{} `json:"signtype"`
  16651. WarnInfo interface{} `json:"warn_info"`
  16652. }
  16653. type ResultCFYLJG004 struct {
  16654. ErrMsg string `json:"err_msg"`
  16655. InfRefmsgid string `json:"inf_refmsgid"`
  16656. Infcode int64 `json:"infcode"`
  16657. Output struct {
  16658. HiRxno string `json:"hi_rxno"`
  16659. RxStasCodg string `json:"rx_stas_codg"`
  16660. RxStasName string `json:"rx_stas_name"`
  16661. } `json:"output"`
  16662. RefmsgTime string `json:"refmsg_time"`
  16663. RespondTime string `json:"respond_time"`
  16664. Signtype interface{} `json:"signtype"`
  16665. WarnInfo interface{} `json:"warn_info"`
  16666. }
  16667. type ResultCFYLJG008 struct {
  16668. ErrMsg string `json:"err_msg"`
  16669. InfRefmsgid string `json:"inf_refmsgid"`
  16670. Infcode int64 `json:"infcode"`
  16671. Output struct {
  16672. PoolareaNo string `json:"poolareaNo"`
  16673. AdmdvsName string `json:"admdvsName"`
  16674. Count string `json:"count"`
  16675. } `json:"output"`
  16676. RefmsgTime string `json:"refmsg_time"`
  16677. RespondTime string `json:"respond_time"`
  16678. Signtype interface{} `json:"signtype"`
  16679. WarnInfo interface{} `json:"warn_info"`
  16680. }
  16681. type ResultCFYLJG005 struct {
  16682. ErrMsg string `json:"err_msg"`
  16683. InfRefmsgid string `json:"inf_refmsgid"`
  16684. Infcode int64 `json:"infcode"`
  16685. Output struct {
  16686. HiRxNo string `json:"hi_rxno"`
  16687. FixMedinsCode string `json:"fixmedins_code"`
  16688. FixMedinsName string `json:"fixmedins_name"`
  16689. RxStasCodg string `json:"rx_stas_codg"`
  16690. RxStasName string `json:"rx_stas_name"`
  16691. RxUserdStasCog string `json:"rx_userd_stas_cog"`
  16692. RxUserdStasName string `json:"rx_userd_stas_name"`
  16693. PrscTime string `json:"prsc_time"`
  16694. RxDrugCnt float64 `json:"rx_drug_cnt"`
  16695. RxUsedWayCodg string `json:"rx_used_way_codg"`
  16696. RxUsedWayName string `json:"rx_used_way_name"`
  16697. RxFrquCodg string `json:"rx_frqu_codg"`
  16698. RxFrquName string `json:"rx_frqu_name"`
  16699. RxDosunt string `json:"rx_dosunt"`
  16700. RxDoscnt float64 `json:"rx_doscnt"`
  16701. RxDrordDscr string `json:"rx_drord_dscr"`
  16702. ValiDays int64 `json:"vali_days"`
  16703. ValiEndTime string `json:"vali_end_time"`
  16704. ReptFlag string `json:"rept_flag"`
  16705. MaxReptCnt int64 `json:"max_rept_cnt"`
  16706. ReptdCnt int64 `json:"reptd_cnt"`
  16707. MinInrvDays int64 `json:"min_inrv_days"`
  16708. RxTypeCode string `json:"rx_type_code"`
  16709. RxTypeName string `json:"rx_type_name"`
  16710. LongRxFlag string `json:"long_rx_flag"`
  16711. RxDetlList []struct {
  16712. MedListCodg string `json:"med_list_codg"`
  16713. MedinsListCodg string `json:"medins_list_codg"`
  16714. HospPrepFlag string `json:"hosp_prep_flag"`
  16715. RxItemTypeCode string `json:"rx_item_type_code"`
  16716. RxItemTypeName string `json:"rx_item_type_name"`
  16717. TcmDrugTypeName string `json:"tcmdrug_type_name"`
  16718. TcmDrugTypeCode string `json:"tcmdrug_type_code"`
  16719. TcmHerbFoote string `json:"tcmherb_foote"`
  16720. MednTypeCode string `json:"medn_type_code"`
  16721. MednTypeName string `json:"medn_type_name"`
  16722. MainMedcFlag string `json:"main_medc_flag"`
  16723. UrgtFlag string `json:"urgt_flag"`
  16724. BasMednFlag string `json:"bas_medn_flag"`
  16725. ImpDrugFlag string `json:"imp_drug_flag"`
  16726. ProdBarc string `json:"prod_barc"`
  16727. DrugProdname string `json:"drug_prodname"`
  16728. GennameCodg string `json:"genname_codg"`
  16729. DrugGenname string `json:"drug_genname"`
  16730. DrugDosform string `json:"drug_dosform"`
  16731. DrugSpec string `json:"drug_spec"`
  16732. PrdrName string `json:"prdr_name"`
  16733. MedcWayCodg string `json:"medc_way_codg"`
  16734. MedcWayDscr string `json:"medc_way_dscr"`
  16735. MedcBegntime string `json:"medc_begntime"`
  16736. MedcEndtime string `json:"medc_endtime"`
  16737. MedcDays float64 `json:"medc_days"`
  16738. DrugPric float64 `json:"drug_pric"`
  16739. DrugSumamt float64 `json:"drug_sumamt"`
  16740. DrugCnt float64 `json:"drug_cnt"`
  16741. DrugDosunt string `json:"drug_dosunt"`
  16742. SinDoscnt float64 `json:"sin_doscnt"`
  16743. SinDosunt string `json:"sin_dosunt"`
  16744. UsedFrquCodg string `json:"used_frqu_codg"`
  16745. UsedFrquName string `json:"used_frqu_name"`
  16746. DrugTotlcnt string `json:"drug_totlcnt"`
  16747. DrugTotlcntEmp string `json:"drug_totlcnt_emp"`
  16748. DiseCodg string `json:"dise_codg"`
  16749. HospApprFlag string `json:"hosp_appr_flag"`
  16750. } `json:"rx_detl_list"`
  16751. RxOtpinfo struct {
  16752. MedType string `json:"med_type"`
  16753. IptOtpNo string `json:"ipt_otp_no"`
  16754. OtpIptFlag string `json:"otp_ipt_flag"`
  16755. PatnName string `json:"patn_name"`
  16756. PatnAge float64 `json:"patn_age"`
  16757. PatnHgt float64 `json:"patn_hgt"`
  16758. PatnWt float64 `json:"patn_wt"`
  16759. Gend string `json:"gend"`
  16760. GesoVal float64 `json:"geso_val"`
  16761. NwbFlag string `json:"nwb_flag"`
  16762. NwbAge string `json:"nwb_age"`
  16763. SuckPrdFlag string `json:"suck_prd_flag"`
  16764. AlgsHis string `json:"algs_his"`
  16765. Insutype string `json:"insutype"`
  16766. PrscDeptName string `json:"prsc_dept_name"`
  16767. PrscDrName string `json:"prsc_dr_name"`
  16768. PharName string `json:"phar_name"`
  16769. PharChkTime string `json:"phar_chk_time"`
  16770. MdtrtTime string `json:"mdtrt_time"`
  16771. DiseCodg string `json:"dise_codg"`
  16772. DiseName string `json:"dise_name"`
  16773. SpDiseFlag string `json:"sp_dise_flag"`
  16774. MaindiagCode string `json:"maindiag_code"`
  16775. MaindiagName string `json:"maindiag_name"`
  16776. DiseCondDscr string `json:"dise_cond_dscr"`
  16777. FstdiagFlag string `json:"fstdiag_flag"`
  16778. } `json:"rx_otpinfo"`
  16779. RxDiseList []struct {
  16780. DiagType string `json:"diag_type"`
  16781. MaindiagFlag string `json:"maindiag_flag"`
  16782. DiagSrtNo string `json:"diag_srt_no"`
  16783. DiagCode string `json:"diag_code"`
  16784. DiagName string `json:"diag_name"`
  16785. DiagDept string `json:"diag_dept"`
  16786. DiagDrNo string `json:"diag_dr_no"`
  16787. DiagDrName string `json:"diag_dr_name"`
  16788. DiagTime string `json:"diag_time"`
  16789. TcmDiseCode string `json:"tcm_dise_code"`
  16790. TcmDiseName string `json:"tcm_dise_name"`
  16791. TcmSympCode string `json:"tcmsymp_code"`
  16792. TcmSymp string `json:"tcmsymp"`
  16793. } `json:"rx_dise_list"`
  16794. } `json:"output"`
  16795. RefmsgTime string `json:"refmsg_time"`
  16796. RespondTime string `json:"respond_time"`
  16797. Signtype interface{} `json:"signtype"`
  16798. WarnInfo interface{} `json:"warn_info"`
  16799. }
  16800. type ResultCFYLJG006 struct {
  16801. ErrMsg string `json:"err_msg"`
  16802. InfRefmsgid string `json:"inf_refmsgid"`
  16803. Infcode int64 `json:"infcode"`
  16804. Output struct {
  16805. HiRxNo string `json:"hi_rxno"`
  16806. PharCode string `json:"phar_code"`
  16807. PharName string `json:"phar_name"`
  16808. RxChkOpnn string `json:"rx_chk_opnn"`
  16809. RxChkTime string `json:"rx_chk_time"`
  16810. RxChkStasCodg string `json:"rx_chk_stas_codg"`
  16811. RxChkStasName string `json:"rx_chk_stas_name"`
  16812. RxStasCodg string `json:"rx_stas_codg"`
  16813. RxStasName string `json:"rx_stas_name"`
  16814. } `json:"output"`
  16815. RefmsgTime string `json:"refmsg_time"`
  16816. RespondTime string `json:"respond_time"`
  16817. Signtype interface{} `json:"signtype"`
  16818. WarnInfo interface{} `json:"warn_info"`
  16819. }
  16820. type ResultFourteen10265 struct {
  16821. ErrMsg string `json:"err_msg"`
  16822. InfRefmsgid string `json:"inf_refmsgid"`
  16823. Infcode string `json:"infcode"`
  16824. Output struct {
  16825. } `json:"output"`
  16826. RefmsgTime string `json:"refmsg_time"`
  16827. RespondTime string `json:"respond_time"`
  16828. Signtype interface{} `json:"signtype"`
  16829. WarnInfo interface{} `json:"warn_info"`
  16830. }
  16831. type ResultSixteen struct {
  16832. Cainfo string `json:"cainfo"`
  16833. ErrMsg string `json:"err_msg"`
  16834. InfRefmsgid string `json:"inf_refmsgid"`
  16835. Infcode int64 `json:"infcode"`
  16836. Output struct {
  16837. Setlinfo struct {
  16838. MdtrtID string `json:"mdtrt_id"`
  16839. SetlID string `json:"setl_id"`
  16840. ClrOptins string `json:"clr_optins"`
  16841. SetlTime string `json:"setl_time"`
  16842. MedfeeSumamt float64 `json:"medfee_sumamt"`
  16843. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  16844. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  16845. PreselfpayAmt float64 `json:"preselfpay_amt"`
  16846. InscpScpAmt float64 `json:"inscp_scp_amt"`
  16847. ActPayDedc float64 `json:"act_pay_dedc"`
  16848. HifpPay float64 `json:"hifp_pay"`
  16849. PoolPropSe float64 `json:"pool_prop_selfpay"`
  16850. Lfpay float64 `json:"selfpay"`
  16851. CvlservPay float64 `json:"cvlserv_pay"`
  16852. HifesPay float64 `json:"hifes_pay"`
  16853. HifmiPay float64 `json:"hifmi_pay"`
  16854. HifobPay float64 `json:"hifob_pay"`
  16855. MafPay float64 `json:"maf_pay"`
  16856. OthPay float64 `json:"oth_pay"`
  16857. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  16858. PsnPartAmt float64 `json:"psn_part_amt"`
  16859. AcctPay float64 `json:"acct_pay"`
  16860. Balc float64 `json:"balc"`
  16861. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  16862. HospPartAmt float64 `json:"hosp_part_amt"`
  16863. MedinsSetlID string `json:"medins_setl_id"`
  16864. PdnCashPay string `json:"pdn_cash_pay"`
  16865. } `json:"setlinfo"`
  16866. } `json:"output"`
  16867. RefmsgTime string `json:"refmsg_time"`
  16868. RespondTime string `json:"respond_time"`
  16869. Signtype interface{} `json:"signtype"`
  16870. WarnMsg interface{} `json:"warn_msg"`
  16871. }
  16872. type ResultSixteen10265 struct {
  16873. Cainfo string `json:"cainfo"`
  16874. ErrMsg string `json:"err_msg"`
  16875. InfRefmsgid string `json:"inf_refmsgid"`
  16876. Infcode string `json:"infcode"`
  16877. Output struct {
  16878. Setlinfo struct {
  16879. MdtrtID string `json:"mdtrt_id"`
  16880. SetlID string `json:"setl_id"`
  16881. ClrOptins string `json:"clr_optins"`
  16882. SetlTime string `json:"setl_time"`
  16883. MedfeeSumamt float64 `json:"medfee_sumamt"`
  16884. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  16885. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  16886. PreselfpayAmt float64 `json:"preselfpay_amt"`
  16887. InscpScpAmt float64 `json:"inscp_scp_amt"`
  16888. ActPayDedc float64 `json:"act_pay_dedc"`
  16889. HifpPay float64 `json:"hifp_pay"`
  16890. PoolPropSe float64 `json:"pool_prop_selfpay"`
  16891. Lfpay float64 `json:"selfpay"`
  16892. CvlservPay float64 `json:"cvlserv_pay"`
  16893. HifesPay float64 `json:"hifes_pay"`
  16894. HifmiPay float64 `json:"hifmi_pay"`
  16895. HifobPay float64 `json:"hifob_pay"`
  16896. MafPay float64 `json:"maf_pay"`
  16897. OthPay float64 `json:"oth_pay"`
  16898. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  16899. PsnPartAmt float64 `json:"psn_part_amt"`
  16900. AcctPay float64 `json:"acct_pay"`
  16901. Balc float64 `json:"balc"`
  16902. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  16903. HospPartAmt float64 `json:"hosp_part_amt"`
  16904. MedinsSetlID string `json:"medins_setl_id"`
  16905. PdnCashPay string `json:"pdn_cash_pay"`
  16906. } `json:"setlinfo"`
  16907. } `json:"output"`
  16908. RefmsgTime string `json:"refmsg_time"`
  16909. RespondTime string `json:"respond_time"`
  16910. Signtype interface{} `json:"signtype"`
  16911. WarnMsg interface{} `json:"warn_msg"`
  16912. }
  16913. type ResultSixteen10265Two struct {
  16914. Cainfo string `json:"cainfo"`
  16915. ErrMsg string `json:"err_msg"`
  16916. InfRefmsgid string `json:"inf_refmsgid"`
  16917. Infcode string `json:"infcode"`
  16918. Output struct {
  16919. Setlinfo interface{} `json:"setlinfo"`
  16920. } `json:"output"`
  16921. RefmsgTime string `json:"refmsg_time"`
  16922. RespondTime string `json:"respond_time"`
  16923. Signtype interface{} `json:"signtype"`
  16924. WarnMsg interface{} `json:"warn_msg"`
  16925. }
  16926. type ResultgzSixteen10265Two struct {
  16927. Cainfo string `json:"cainfo"`
  16928. ErrMsg string `json:"err_msg"`
  16929. InfRefmsgid string `json:"inf_refmsgid"`
  16930. Infcode int64 `json:"infcode"`
  16931. Output struct {
  16932. Setlinfo interface{} `json:"setlinfo"`
  16933. } `json:"output"`
  16934. RefmsgTime string `json:"refmsg_time"`
  16935. RespondTime string `json:"respond_time"`
  16936. Signtype interface{} `json:"signtype"`
  16937. WarnMsg interface{} `json:"warn_msg"`
  16938. }
  16939. type ResultSeventeen struct {
  16940. ErrMsg string `json:"err_msg"`
  16941. InfRefmsgid string `json:"inf_refmsgid"`
  16942. Infcode int64 `json:"infcode"`
  16943. Output struct {
  16944. SetlListId string `json:"setl_list_id"`
  16945. } `json:"output"`
  16946. RefmsgTime string `json:"refmsg_time"`
  16947. RespondTime string `json:"respond_time"`
  16948. Signtype string `json:"signtype"`
  16949. WarnInfo string `json:"warn_info"`
  16950. }
  16951. type ResultSeventeenOther struct {
  16952. ErrMsg string `json:"err_msg"`
  16953. InfRefmsgid string `json:"inf_refmsgid"`
  16954. Infcode string `json:"infcode"`
  16955. Output struct {
  16956. SetlListId string `json:"setl_list_id"`
  16957. } `json:"output"`
  16958. RefmsgTime string `json:"refmsg_time"`
  16959. RespondTime string `json:"respond_time"`
  16960. Signtype string `json:"signtype"`
  16961. WarnInfo string `json:"warn_info"`
  16962. }
  16963. type Result90991 struct {
  16964. ErrMsg string `json:"err_msg"`
  16965. InfRefmsgid string `json:"inf_refmsgid"`
  16966. Infcode int64 `json:"infcode"`
  16967. Output struct {
  16968. Result struct {
  16969. PsnNo string `json:"psn_no"`
  16970. CardStat string `json:"card_stat"`
  16971. Certno string `json:"certno"`
  16972. PsnName string `json:"psn_name"`
  16973. CheckStat string `json:"check_stat"`
  16974. SscnoCheckStat string `json:"sscno_check_stat"`
  16975. } `json:"result"`
  16976. } `json:"output"`
  16977. RefmsgTime string `json:"refmsg_time"`
  16978. RespondTime string `json:"respond_time"`
  16979. Signtype interface{} `json:"signtype"`
  16980. WarnInfo interface{} `json:"warn_info"`
  16981. }
  16982. type Result90100 struct {
  16983. ErrMsg string `json:"err_msg"`
  16984. InfRefmsgid string `json:"inf_refmsgid"`
  16985. Infcode int64 `json:"infcode"`
  16986. Output struct {
  16987. PoolareaNo string `json:"poolarea_no"`
  16988. PoolareaNoName string `json:"poolarea_no_name"`
  16989. Insutype string `json:"insutype"`
  16990. InsutypeName string `json:"insutype_name"`
  16991. ClctType string `json:"clct_type"`
  16992. ClctTypeName string `json:"clct_type_name"`
  16993. ClctFlag string `json:"clct_flag"`
  16994. ClctFlagName string `json:"clct_flag_name"`
  16995. AccrymBegn string `json:"accrym_begn"`
  16996. AccrymEnd string `json:"accrym_end"`
  16997. ClctTime string `json:"clct_time"`
  16998. ClctstdCrtfRuleCodg string `json:"clctstd_crtf_rule_codg"`
  16999. } `json:"output"`
  17000. RefmsgTime string `json:"refmsg_time"`
  17001. RespondTime string `json:"respond_time"`
  17002. Signtype interface{} `json:"signtype"`
  17003. WarnInfo interface{} `json:"warn_info"`
  17004. }
  17005. type Custom struct {
  17006. DetItemFeeSumamt string
  17007. Cut string
  17008. FeedetlSn string
  17009. Price string
  17010. MedListCodg string
  17011. Type int64
  17012. AdviceId int64
  17013. ProjectId int64
  17014. ItemId int64
  17015. }
  17016. type Result5301 struct {
  17017. ErrMsg string `json:"err_msg"`
  17018. InfRefmsgid string `json:"inf_refmsgid"`
  17019. Infcode int64 `json:"infcode"`
  17020. Output struct {
  17021. Result []struct {
  17022. OpspDiseCode string `json:"opsp_dise_code"`
  17023. OpspDiseName string `json:"opsp_dise_name"`
  17024. Begndate string `json:"begndate"`
  17025. Enddate string `json:"enddate"`
  17026. } `json:"feedetail"`
  17027. } `json:"output"`
  17028. RefmsgTime string `json:"refmsg_time"`
  17029. RespondTime string `json:"respond_time"`
  17030. Signtype interface{} `json:"signtype"`
  17031. WarnInfo interface{} `json:"warn_info"`
  17032. }
  17033. type Result5301For10265 struct {
  17034. ErrMsg string `json:"err_msg"`
  17035. InfRefmsgid string `json:"inf_refmsgid"`
  17036. Infcode string `json:"infcode"`
  17037. Output struct {
  17038. Result []struct {
  17039. OpspDiseCode string `json:"opsp_dise_code"`
  17040. OpspDiseName string `json:"opsp_dise_name"`
  17041. Begndate string `json:"begndate"`
  17042. Enddate string `json:"enddate"`
  17043. } `json:"feedetail"`
  17044. } `json:"output"`
  17045. RefmsgTime string `json:"refmsg_time"`
  17046. RespondTime string `json:"respond_time"`
  17047. Signtype interface{} `json:"signtype"`
  17048. WarnInfo interface{} `json:"warn_info"`
  17049. }
  17050. //获取个人信息----挂号-----上传就诊信息
  17051. func (c *HisApiController) GetRegisterInfo() {
  17052. id, _ := c.GetInt64("id")
  17053. record_time := c.GetString("record_time")
  17054. settlementValue, _ := c.GetInt64("settlement_value")
  17055. medical_insurance_card := c.GetString("medical_insurance_card")
  17056. name := c.GetString("name")
  17057. id_card_type, _ := c.GetInt64("id_card_type")
  17058. certificates, _ := c.GetInt64("certificates")
  17059. medical_care, _ := c.GetInt64("medical_care")
  17060. birthday := c.GetString("birthday")
  17061. id_card := c.GetString("id_card")
  17062. register_type, _ := c.GetInt64("register")
  17063. doctor, _ := c.GetInt64("doctor")
  17064. department, _ := c.GetInt64("department")
  17065. gender, _ := c.GetInt64("sex")
  17066. registration_fee, _ := c.GetFloat("registration_fee")
  17067. medical_expenses, _ := c.GetFloat("medical_expenses")
  17068. social_type, _ := c.GetInt64("social_type")
  17069. admin_user_id, _ := c.GetInt64("admin_user_id")
  17070. insuplc_admdvs := c.GetString("insuplc_admdvs")
  17071. mdtrt_type := c.GetString("mdtrt_type")
  17072. if id_card_type == 5 {
  17073. id_card_type = 4
  17074. }
  17075. timeLayout := "2006-01-02"
  17076. loc, _ := time.LoadLocation("Local")
  17077. birthdays, _ := time.ParseInLocation(timeLayout+" 15:04:05", birthday+" 00:00:00", loc)
  17078. birthUnix := birthdays.Unix()
  17079. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  17080. if err != nil {
  17081. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  17082. return
  17083. }
  17084. recordDateTime := theTime.Unix()
  17085. adminInfo := c.GetAdminUserInfo()
  17086. var patient service.Patients
  17087. if id == 0 {
  17088. patient, _ = service.GetPatientByIDCard(id_card, adminInfo.CurrentOrgId)
  17089. } else {
  17090. patient, _ = service.GetPatientByIDTwo(adminInfo.CurrentOrgId, id)
  17091. }
  17092. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  17093. if patientPrescription.ID == 0 {
  17094. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  17095. }
  17096. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  17097. if patient.ID == 0 {
  17098. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  17099. return
  17100. }
  17101. if len(patient.IdCardNo) == 0 {
  17102. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  17103. return
  17104. }
  17105. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  17106. roles, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, admin_user_id)
  17107. doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, doctor)
  17108. //就诊结算未完成,不能进行二次挂号
  17109. //his, _ := service.GetHisPatientInfoTwo(adminInfo.CurrentOrgId, patient.ID, recordDateTime)
  17110. //if len(his) >= 1 {
  17111. // order, _ := service.GetNewHisOrderTwo(adminInfo.CurrentOrgId, his[len(his)-1].Number, his[len(his)-1].PatientId, recordDateTime)
  17112. // if len(his) >= 1 && order.ID == 0 {
  17113. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisPatientParamWrong)
  17114. // return
  17115. // }
  17116. //}
  17117. //var register_log string
  17118. if config.IsOpen == 1 {
  17119. var res ResultTwo
  17120. var res10265 ResultTwo10265
  17121. var PsnNo string
  17122. var PsnCertType string
  17123. var Certno string
  17124. var PsnName string
  17125. var Gend string
  17126. var Naty string
  17127. var Brdy string
  17128. var Age float64
  17129. var infoStr string
  17130. var idetinfoStr string
  17131. var infocode int64
  17132. var verify_number string
  17133. fmt.Println(verify_number)
  17134. if miConfig.MdtrtareaAdmvs == "421300" || miConfig.MdtrtareaAdmvs == "420200" || miConfig.MdtrtareaAdmvs == "421182" || miConfig.MdtrtareaAdmvs == "420902" {
  17135. psn_info, _ := service.GetPsnByPatientId(id)
  17136. PsnNo = psn_info.PsnNo
  17137. PsnCertType = psn_info.PsnCertType
  17138. Certno = psn_info.Certno
  17139. PsnName = psn_info.PsnName
  17140. Gend = psn_info.Gend
  17141. Naty = psn_info.Naty
  17142. Brdy = psn_info.Brdy
  17143. Age = psn_info.Age
  17144. infoStr = psn_info.Insuinfo
  17145. idetinfoStr = psn_info.Idetinfo
  17146. infocode = 0
  17147. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  17148. psn_info, _ := service.GetPsnByPatientId(id)
  17149. PsnNo = psn_info.PsnNo
  17150. PsnCertType = psn_info.PsnCertType
  17151. Certno = psn_info.Certno
  17152. PsnName = psn_info.PsnName
  17153. Gend = psn_info.Gend
  17154. Naty = psn_info.Naty
  17155. Brdy = psn_info.Brdy
  17156. Age = psn_info.Age
  17157. infoStr = psn_info.Insuinfo
  17158. idetinfoStr = psn_info.Idetinfo
  17159. infocode = 0
  17160. verify_number = psn_info.VerifyNumber
  17161. } else if miConfig.MdtrtareaAdmvs == "150499" {
  17162. if id_card_type == 2 {
  17163. //请求内网数据
  17164. api := "http://172.16.13.254:9532/" + "nmyb/1101?cert_no=" + patient.IdCardNo +
  17165. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  17166. "&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
  17167. resp, requestErr := http.Get(api)
  17168. if requestErr != nil {
  17169. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17170. return
  17171. }
  17172. body, ioErr := ioutil.ReadAll(resp.Body)
  17173. if ioErr != nil {
  17174. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  17175. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17176. return
  17177. }
  17178. var respJSON map[string]interface{}
  17179. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  17180. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  17181. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17182. return
  17183. }
  17184. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  17185. result_byte, _ := json.Marshal(respJSON)
  17186. result := string(result_byte)
  17187. var dat map[string]interface{}
  17188. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  17189. fmt.Println(dat)
  17190. } else {
  17191. fmt.Println(err)
  17192. }
  17193. userJSONBytes, _ := json.Marshal(dat)
  17194. var res ResultTwo
  17195. var resTwo10265 ResultTwo10265
  17196. if miConfig.Code == "H15049901371" {
  17197. if err := json.Unmarshal(userJSONBytes, &resTwo10265); err != nil {
  17198. utils.ErrorLog("解析失败:%v", err)
  17199. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17200. return
  17201. }
  17202. Infcode, _ := strconv.ParseInt(resTwo10265.Infcode, 10, 64)
  17203. res.Infcode = Infcode
  17204. res.ErrMsg = resTwo10265.ErrMsg
  17205. res.Output = resTwo10265.Output
  17206. res.InfRefmsgid = resTwo10265.InfRefmsgid
  17207. res.RespondTime = resTwo10265.RespondTime
  17208. res.WarnInfo = resTwo10265.WarnInfo
  17209. } else {
  17210. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  17211. utils.ErrorLog("解析失败:%v", err)
  17212. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17213. return
  17214. }
  17215. }
  17216. //var insutypes []string
  17217. //var insutype string
  17218. //var is390 int = 0
  17219. //var is310 int = 0
  17220. //for _, item := range res.Output.Iinfo {
  17221. // if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  17222. // insutypes = append(insutypes, item.Insutype)
  17223. // }
  17224. //}
  17225. //if len(insutypes) == 1 {
  17226. // insutype = insutypes[0]
  17227. //} else {
  17228. // for _, i := range insutypes {
  17229. // if i == "390" {
  17230. // is390 = 1
  17231. // }
  17232. //
  17233. // if i == "310" {
  17234. // is310 = 1
  17235. // }
  17236. // }
  17237. //}
  17238. //if is390 == 1 {
  17239. // insutype = "390"
  17240. //}
  17241. //if is310 == 1 {
  17242. // insutype = "310"
  17243. //}
  17244. //if len(insutypes) == 0 {
  17245. // insutype = "310"
  17246. //}
  17247. PsnNo = res.Output.Baseinfo.PsnNo
  17248. PsnCertType = res.Output.Baseinfo.PsnCertType
  17249. Certno = res.Output.Baseinfo.Certno
  17250. PsnName = res.Output.Baseinfo.PsnName
  17251. Gend = res.Output.Baseinfo.Gend
  17252. Naty = res.Output.Baseinfo.Naty
  17253. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  17254. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  17255. infoStr = string(Iinfos)
  17256. idetinfoStr = string(Idetinfos)
  17257. infocode = res.Infcode
  17258. //infocode = 0
  17259. //verify_number = psn_info.VerifyNumber
  17260. } else {
  17261. psn_info, _ := service.GetPsnByPatientId(id)
  17262. PsnNo = psn_info.PsnNo
  17263. PsnCertType = psn_info.PsnCertType
  17264. Certno = psn_info.Certno
  17265. PsnName = psn_info.PsnName
  17266. Gend = psn_info.Gend
  17267. Naty = psn_info.Naty
  17268. Brdy = psn_info.Brdy
  17269. Age = psn_info.Age
  17270. infoStr = psn_info.Insuinfo
  17271. idetinfoStr = psn_info.Idetinfo
  17272. infocode = 0
  17273. verify_number = psn_info.VerifyNumber
  17274. }
  17275. } else if miConfig.MdtrtareaAdmvs == "350500" {
  17276. if id_card_type == 1 {
  17277. psn_info, _ := service.GetPsnByPatientId(id)
  17278. PsnNo = psn_info.PsnNo
  17279. PsnCertType = psn_info.PsnCertType
  17280. Certno = psn_info.Certno
  17281. PsnName = psn_info.PsnName
  17282. Gend = psn_info.Gend
  17283. Naty = psn_info.Naty
  17284. Brdy = psn_info.Brdy
  17285. Age = psn_info.Age
  17286. infoStr = psn_info.Insuinfo
  17287. idetinfoStr = psn_info.Idetinfo
  17288. infocode = 0
  17289. verify_number = psn_info.VerifyNumber
  17290. } else if id_card_type == 2 {
  17291. 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)
  17292. fmt.Println(errMsgLog)
  17293. saveLog(result, requestLog, "1101", "人员基本信息获取")
  17294. if err := json.Unmarshal([]byte(result), &res); err != nil {
  17295. utils.ErrorLog("解析失败:%v", err)
  17296. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17297. return
  17298. }
  17299. PsnNo = res.Output.Baseinfo.PsnNo
  17300. PsnCertType = res.Output.Baseinfo.PsnCertType
  17301. Certno = res.Output.Baseinfo.Certno
  17302. PsnName = res.Output.Baseinfo.PsnName
  17303. Gend = res.Output.Baseinfo.Gend
  17304. Naty = res.Output.Baseinfo.Naty
  17305. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  17306. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  17307. infoStr = string(Iinfos)
  17308. idetinfoStr = string(Idetinfos)
  17309. infocode = res.Infcode
  17310. }
  17311. } else if miConfig.MdtrtareaAdmvs == "360302" {
  17312. if id_card_type == 1 {
  17313. psn_info, _ := service.GetPsnByPatientId(id)
  17314. PsnNo = psn_info.PsnNo
  17315. PsnCertType = psn_info.PsnCertType
  17316. Certno = psn_info.Certno
  17317. PsnName = psn_info.PsnName
  17318. Gend = psn_info.Gend
  17319. Naty = psn_info.Naty
  17320. Brdy = psn_info.Brdy
  17321. Age = psn_info.Age
  17322. infoStr = psn_info.Insuinfo
  17323. idetinfoStr = psn_info.Idetinfo
  17324. infocode = 0
  17325. verify_number = psn_info.VerifyNumber
  17326. } else if id_card_type == 2 {
  17327. 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, "")
  17328. saveLog(result, requestLog, "1101", "人员基本信息获取")
  17329. if err := json.Unmarshal([]byte(result), &res); err != nil {
  17330. utils.ErrorLog("解析失败:%v", err)
  17331. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17332. return
  17333. }
  17334. PsnNo = res.Output.Baseinfo.PsnNo
  17335. PsnCertType = res.Output.Baseinfo.PsnCertType
  17336. Certno = res.Output.Baseinfo.Certno
  17337. PsnName = res.Output.Baseinfo.PsnName
  17338. Gend = res.Output.Baseinfo.Gend
  17339. Naty = res.Output.Baseinfo.Naty
  17340. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  17341. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  17342. infoStr = string(Iinfos)
  17343. idetinfoStr = string(Idetinfos)
  17344. infocode = res.Infcode
  17345. } else {
  17346. psn_info, _ := service.GetPsnByPatientId(id)
  17347. PsnNo = psn_info.PsnNo
  17348. PsnCertType = psn_info.PsnCertType
  17349. Certno = psn_info.Certno
  17350. PsnName = psn_info.PsnName
  17351. Gend = psn_info.Gend
  17352. Naty = psn_info.Naty
  17353. Brdy = psn_info.Brdy
  17354. Age = psn_info.Age
  17355. infoStr = psn_info.Insuinfo
  17356. idetinfoStr = psn_info.Idetinfo
  17357. infocode = 0
  17358. verify_number = psn_info.VerifyNumber
  17359. }
  17360. } else if miConfig.MdtrtareaAdmvs == "341203" {
  17361. psn_info, _ := service.GetPsnByPatientId(id)
  17362. PsnNo = psn_info.PsnNo
  17363. PsnCertType = psn_info.PsnCertType
  17364. Certno = psn_info.Certno
  17365. PsnName = psn_info.PsnName
  17366. Gend = psn_info.Gend
  17367. Naty = psn_info.Naty
  17368. Brdy = psn_info.Brdy
  17369. Age = psn_info.Age
  17370. infoStr = psn_info.Insuinfo
  17371. idetinfoStr = psn_info.Idetinfo
  17372. infocode = 0
  17373. verify_number = psn_info.VerifyNumber
  17374. } else if miConfig.MdtrtareaAdmvs == "430800" {
  17375. if id_card_type == 1 {
  17376. psn_info, _ := service.GetPsnByPatientId(id)
  17377. PsnNo = psn_info.PsnNo
  17378. PsnCertType = psn_info.PsnCertType
  17379. Certno = psn_info.Certno
  17380. PsnName = psn_info.PsnName
  17381. Gend = psn_info.Gend
  17382. Naty = psn_info.Naty
  17383. Brdy = psn_info.Brdy
  17384. Age = psn_info.Age
  17385. infoStr = psn_info.Insuinfo
  17386. idetinfoStr = psn_info.Idetinfo
  17387. infocode = 0
  17388. verify_number = psn_info.VerifyNumber
  17389. } else if id_card_type == 2 {
  17390. 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)
  17391. saveLog(result, requestLog, "1101", "人员基本信息获取")
  17392. if err := json.Unmarshal([]byte(result), &res); err != nil {
  17393. utils.ErrorLog("解析失败:%v", err)
  17394. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17395. return
  17396. }
  17397. PsnNo = res.Output.Baseinfo.PsnNo
  17398. PsnCertType = res.Output.Baseinfo.PsnCertType
  17399. Certno = res.Output.Baseinfo.Certno
  17400. PsnName = res.Output.Baseinfo.PsnName
  17401. Gend = res.Output.Baseinfo.Gend
  17402. Naty = res.Output.Baseinfo.Naty
  17403. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  17404. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  17405. infoStr = string(Iinfos)
  17406. idetinfoStr = string(Idetinfos)
  17407. infocode = res.Infcode
  17408. } else if id_card_type == 4 {
  17409. psn_info, _ := service.GetPsnByPatientId(id)
  17410. PsnNo = psn_info.PsnNo
  17411. PsnCertType = psn_info.PsnCertType
  17412. Certno = psn_info.Certno
  17413. PsnName = psn_info.PsnName
  17414. Gend = psn_info.Gend
  17415. Naty = psn_info.Naty
  17416. Brdy = psn_info.Brdy
  17417. Age = psn_info.Age
  17418. infoStr = psn_info.Insuinfo
  17419. idetinfoStr = psn_info.Idetinfo
  17420. infocode = 0
  17421. verify_number = psn_info.VerifyNumber
  17422. }
  17423. } else if miConfig.MdtrtareaAdmvs == "131023" {
  17424. var result string
  17425. var requestLog string
  17426. 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), "")
  17427. if id_card_type == 4 {
  17428. psn_info, _ := service.GetPsnByPatientId(id)
  17429. PsnNo = psn_info.PsnNo
  17430. PsnCertType = psn_info.PsnCertType
  17431. Certno = psn_info.Certno
  17432. PsnName = psn_info.PsnName
  17433. Gend = psn_info.Gend
  17434. Naty = psn_info.Naty
  17435. Brdy = psn_info.Brdy
  17436. Age = psn_info.Age
  17437. infoStr = psn_info.Insuinfo
  17438. idetinfoStr = psn_info.Idetinfo
  17439. infocode = 0
  17440. verify_number = psn_info.VerifyNumber
  17441. } else {
  17442. saveLog(result, requestLog, "1101", "人员基本信息获取")
  17443. if miConfig.Code == "H15049901371" {
  17444. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  17445. utils.ErrorLog("解析失败:%v", err)
  17446. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17447. return
  17448. }
  17449. res.ErrMsg = res10265.ErrMsg
  17450. res.Output = res10265.Output
  17451. res.InfRefmsgid = res10265.InfRefmsgid
  17452. } else {
  17453. if err := json.Unmarshal([]byte(result), &res); err != nil {
  17454. utils.ErrorLog("解析失败:%v", err)
  17455. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17456. return
  17457. }
  17458. }
  17459. PsnNo = res.Output.Baseinfo.PsnNo
  17460. PsnCertType = res.Output.Baseinfo.PsnCertType
  17461. Certno = res.Output.Baseinfo.Certno
  17462. PsnName = res.Output.Baseinfo.PsnName
  17463. Gend = res.Output.Baseinfo.Gend
  17464. Naty = res.Output.Baseinfo.Naty
  17465. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  17466. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  17467. infoStr = string(Iinfos)
  17468. idetinfoStr = string(Idetinfos)
  17469. if miConfig.Code == "H15049901371" {
  17470. infocode, _ = strconv.ParseInt(res10265.Infcode, 10, 64)
  17471. } else {
  17472. infocode = res.Infcode
  17473. }
  17474. }
  17475. } else if miConfig.MdtrtareaAdmvs == "441799" {
  17476. psn_info, _ := service.GetPsnByPatientId(id)
  17477. PsnNo = psn_info.PsnNo
  17478. PsnCertType = psn_info.PsnCertType
  17479. Certno = psn_info.Certno
  17480. PsnName = psn_info.PsnName
  17481. Gend = psn_info.Gend
  17482. Naty = psn_info.Naty
  17483. Brdy = psn_info.Brdy
  17484. Age = psn_info.Age
  17485. infoStr = psn_info.Insuinfo
  17486. idetinfoStr = psn_info.Idetinfo
  17487. infocode = 0
  17488. verify_number = psn_info.VerifyNumber
  17489. } else if miConfig.MdtrtareaAdmvs == "450721" {
  17490. psn_info, _ := service.GetPsnByPatientId(id)
  17491. PsnNo = psn_info.PsnNo
  17492. PsnCertType = psn_info.PsnCertType
  17493. Certno = psn_info.Certno
  17494. PsnName = psn_info.PsnName
  17495. Gend = psn_info.Gend
  17496. Naty = psn_info.Naty
  17497. Brdy = psn_info.Brdy
  17498. Age = psn_info.Age
  17499. infoStr = psn_info.Insuinfo
  17500. idetinfoStr = psn_info.Idetinfo
  17501. infocode = 0
  17502. verify_number = psn_info.VerifyNumber
  17503. } else {
  17504. var result string
  17505. var requestLog string
  17506. //if miConfig.UserOrgId == 10138 {
  17507. if id_card_type != 4 || id_card_type != 1 {
  17508. var insa string
  17509. if len(patient.InsuplcAdmdvs) > 0 {
  17510. insa = patient.InsuplcAdmdvs
  17511. } else {
  17512. insa = miConfig.InsuplcAdmdvs
  17513. }
  17514. //psn_info, _ := service.GetPsnByPatientId(id)
  17515. //result, requestLog = service.Gdyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_info.VerifyNumber)
  17516. 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)
  17517. }
  17518. //}
  17519. //else {
  17520. // var insa string
  17521. // if len(patient.InsuplcAdmdvs) > 0 {
  17522. // insa = patient.InsuplcAdmdvs
  17523. // } else {
  17524. // insa = miConfig.InsuplcAdmdvs
  17525. // }
  17526. // 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)
  17527. //}
  17528. if id_card_type == 4 || id_card_type == 1 {
  17529. psn_info, _ := service.GetPsnByPatientId(id)
  17530. PsnNo = psn_info.PsnNo
  17531. PsnCertType = psn_info.PsnCertType
  17532. Certno = psn_info.Certno
  17533. PsnName = psn_info.PsnName
  17534. Gend = psn_info.Gend
  17535. Naty = psn_info.Naty
  17536. Brdy = psn_info.Brdy
  17537. Age = psn_info.Age
  17538. infoStr = psn_info.Insuinfo
  17539. idetinfoStr = psn_info.Idetinfo
  17540. infocode = 0
  17541. verify_number = psn_info.VerifyNumber
  17542. } else {
  17543. saveLog(result, requestLog, "1101", "人员基本信息获取")
  17544. if miConfig.Code == "H15049901371" {
  17545. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  17546. utils.ErrorLog("解析失败:%v", err)
  17547. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17548. return
  17549. }
  17550. res.ErrMsg = res10265.ErrMsg
  17551. res.Output = res10265.Output
  17552. res.InfRefmsgid = res10265.InfRefmsgid
  17553. } else {
  17554. if err := json.Unmarshal([]byte(result), &res); err != nil {
  17555. utils.ErrorLog("解析失败:%v", err)
  17556. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17557. return
  17558. }
  17559. }
  17560. PsnNo = res.Output.Baseinfo.PsnNo
  17561. PsnCertType = res.Output.Baseinfo.PsnCertType
  17562. Certno = res.Output.Baseinfo.Certno
  17563. PsnName = res.Output.Baseinfo.PsnName
  17564. Gend = res.Output.Baseinfo.Gend
  17565. Naty = res.Output.Baseinfo.Naty
  17566. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  17567. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  17568. infoStr = string(Iinfos)
  17569. idetinfoStr = string(Idetinfos)
  17570. if miConfig.Code == "H15049901371" {
  17571. infocode, _ = strconv.ParseInt(res10265.Infcode, 10, 64)
  17572. } else {
  17573. infocode = res.Infcode
  17574. }
  17575. }
  17576. }
  17577. if infocode == 0 {
  17578. his := models.VMHisPatient{
  17579. Name: name,
  17580. Gender: gender,
  17581. Birthday: birthUnix,
  17582. MedicalTreatmentType: medical_care,
  17583. IdType: certificates,
  17584. IdCardNo: id_card,
  17585. BalanceAccountsType: settlementValue,
  17586. SocialType: social_type,
  17587. MedicalInsuranceNumber: medical_insurance_card,
  17588. RegisterType: register_type,
  17589. RegisterCost: registration_fee,
  17590. TreatmentCost: medical_expenses,
  17591. Status: 1,
  17592. Ctime: time.Now().Unix(),
  17593. Mtime: time.Now().Unix(),
  17594. PsnNo: PsnNo,
  17595. PsnCertType: PsnCertType,
  17596. Certno: Certno,
  17597. PsnName: PsnName,
  17598. Gend: Gend,
  17599. Naty: Naty,
  17600. Brdy: Brdy,
  17601. Age: Age,
  17602. Iinfo: infoStr,
  17603. Idetinfo: idetinfoStr,
  17604. PatientId: patient.ID,
  17605. RecordDate: theTime.Unix(),
  17606. UserOrgId: adminInfo.CurrentOrgId,
  17607. AdminUserId: admin_user_id,
  17608. IsReturn: 1,
  17609. IdCardType: id_card_type,
  17610. Doctor: doctor,
  17611. Departments: department,
  17612. MdtrtGrpType: mdtrt_type,
  17613. }
  17614. timestamp := time.Now().Unix()
  17615. tempTime := time.Unix(timestamp, 0)
  17616. timeFormat := tempTime.Format("20060102150405")
  17617. chrgBchno := rand.Intn(100000) + 10000
  17618. ipt_otp_no := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  17619. his.Number = ipt_otp_no
  17620. //count, _ := service.FindHisRegisterRecord(theTime.Unix(), patient.ID, adminInfo.CurrentOrgId)
  17621. department, _ := service.GetDepartMentDetail(department)
  17622. //doctor_id := strconv.FormatInt(patientPrescription., 10)
  17623. IdCardNo := ""
  17624. if id_card_type == 1 {
  17625. // IdCardNo = medical_insurance_card
  17626. IdCardNo = patient.IdCardNo
  17627. } else {
  17628. IdCardNo = patient.IdCardNo
  17629. }
  17630. var rf []*ResultFive
  17631. json.Unmarshal([]byte(his.Iinfo), &rf)
  17632. var insutypes []*ResultFive
  17633. var insutype string
  17634. var insuplc_admdvs_temp string
  17635. var is390 int = 0
  17636. var is310 int = 0
  17637. for _, item := range rf {
  17638. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  17639. insutypes = append(insutypes, item)
  17640. }
  17641. }
  17642. if len(insutypes) == 1 {
  17643. insutype = insutypes[0].Insutype
  17644. insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  17645. if insutype == "390" {
  17646. is390 = 1
  17647. }
  17648. if insutype == "310" {
  17649. is310 = 1
  17650. }
  17651. } else {
  17652. for _, i := range insutypes {
  17653. if i.Insutype == "390" {
  17654. is390 = 1
  17655. }
  17656. if i.Insutype == "310" {
  17657. is310 = 1
  17658. }
  17659. }
  17660. }
  17661. if is390 == 1 {
  17662. insutype = "390"
  17663. }
  17664. if is310 == 1 {
  17665. insutype = "310"
  17666. }
  17667. fmt.Println(social_type)
  17668. if social_type > 0 {
  17669. insutype = strconv.FormatInt(social_type, 10)
  17670. }
  17671. var infocode int64
  17672. var resThree ResultThree
  17673. var resThree10265 ResultThree10265
  17674. if len(insuplc_admdvs) == 0 {
  17675. psn_info, _ := service.GetPsnByPatientId(id)
  17676. //if len(psn_info.InsuplcAdmdvs) > 0 {
  17677. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  17678. //}
  17679. } else {
  17680. insuplc_admdvs_temp = insuplc_admdvs
  17681. }
  17682. if miConfig.MdtrtareaAdmvs == "421300" {
  17683. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  17684. psn_info, _ := service.GetPsnByPatientId(id)
  17685. api := "http://192.168.124.4:9532/" + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  17686. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  17687. "&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
  17688. resp, requestErr := http.Get(api)
  17689. if requestErr != nil {
  17690. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17691. return
  17692. }
  17693. body, ioErr := ioutil.ReadAll(resp.Body)
  17694. if ioErr != nil {
  17695. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  17696. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17697. return
  17698. }
  17699. var respJSON map[string]interface{}
  17700. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  17701. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  17702. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17703. return
  17704. }
  17705. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  17706. result, _ := json.Marshal(respJSON)
  17707. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  17708. utils.ErrorLog("解析失败:%v", err)
  17709. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17710. return
  17711. }
  17712. infocode = resThree.Infcode
  17713. } else if miConfig.MdtrtareaAdmvs == "420200" {
  17714. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  17715. //if strings.Contains(insuplc_admdvs_temp, "4202") {
  17716. // insuplc_admdvs_temp =
  17717. //}
  17718. //if strings.Contains(insuplc_admdvs_temp, "4413") {
  17719. // insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  17720. //}
  17721. api := "http://192.168.0.197:9532/" + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  17722. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  17723. "&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
  17724. resp, requestErr := http.Get(api)
  17725. if requestErr != nil {
  17726. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17727. return
  17728. }
  17729. body, ioErr := ioutil.ReadAll(resp.Body)
  17730. if ioErr != nil {
  17731. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  17732. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17733. return
  17734. }
  17735. var respJSON map[string]interface{}
  17736. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  17737. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  17738. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17739. return
  17740. }
  17741. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  17742. result, _ := json.Marshal(respJSON)
  17743. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  17744. utils.ErrorLog("解析失败:%v", err)
  17745. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17746. return
  17747. }
  17748. infocode = resThree.Infcode
  17749. } else if miConfig.MdtrtareaAdmvs == "420902" {
  17750. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  17751. //if strings.Contains(insuplc_admdvs_temp, "4202") {
  17752. // insuplc_admdvs_temp =
  17753. //}
  17754. //if strings.Contains(insuplc_admdvs_temp, "4413") {
  17755. // insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  17756. //}
  17757. utils.ErrorLog("解析失败:%v", insutype)
  17758. utils.ErrorLog("解析失败:%v", PsnNo)
  17759. utils.ErrorLog("解析失败:%v", Certno)
  17760. utils.ErrorLog("解析失败:%v", ipt_otp_no)
  17761. utils.ErrorLog("解析失败:%v", hb_doctor_info.UserName)
  17762. utils.ErrorLog("解析失败:%v", insuplc_admdvs_temp)
  17763. utils.ErrorLog("解析失败:%v", hb_doctor_info.DoctorNumber)
  17764. utils.ErrorLog("解析失败:%v", PsnNo)
  17765. utils.ErrorLog("解析失败:%v", department.Number)
  17766. utils.ErrorLog("解析失败:%v", department.Name)
  17767. utils.ErrorLog("解析失败:%v", roles.UserName)
  17768. api := miConfig.Url + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  17769. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  17770. "&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
  17771. resp, requestErr := http.Get(api)
  17772. if requestErr != nil {
  17773. utils.ErrorLog("解析失败:%v", requestErr)
  17774. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17775. return
  17776. }
  17777. body, ioErr := ioutil.ReadAll(resp.Body)
  17778. if ioErr != nil {
  17779. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  17780. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17781. return
  17782. }
  17783. var respJSON map[string]interface{}
  17784. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  17785. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  17786. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17787. return
  17788. }
  17789. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  17790. result, _ := json.Marshal(respJSON)
  17791. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  17792. utils.ErrorLog("解析失败:%v", err)
  17793. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17794. return
  17795. }
  17796. infocode = resThree.Infcode
  17797. } else if miConfig.MdtrtareaAdmvs == "421182" {
  17798. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  17799. //if strings.Contains(insuplc_admdvs_temp, "4202") {
  17800. // insuplc_admdvs_temp =
  17801. //}
  17802. //if strings.Contains(insuplc_admdvs_temp, "4413") {
  17803. // insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  17804. //}
  17805. api := miConfig.Url + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  17806. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  17807. "&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
  17808. resp, requestErr := http.Get(api)
  17809. if requestErr != nil {
  17810. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17811. return
  17812. }
  17813. body, ioErr := ioutil.ReadAll(resp.Body)
  17814. if ioErr != nil {
  17815. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  17816. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17817. return
  17818. }
  17819. var respJSON map[string]interface{}
  17820. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  17821. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  17822. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17823. return
  17824. }
  17825. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  17826. result, _ := json.Marshal(respJSON)
  17827. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  17828. utils.ErrorLog("解析失败:%v", err)
  17829. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17830. return
  17831. }
  17832. infocode = resThree.Infcode
  17833. } else if miConfig.MdtrtareaAdmvs == "150499" {
  17834. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  17835. psn_info, _ := service.GetPsnByPatientId(id)
  17836. var verify_number string
  17837. if id_card_type == 4 {
  17838. verify_number = psn_info.VerifyNumber
  17839. } else if id_card_type == 1 {
  17840. bas := strings.Split(psn_info.CardInfo, "|")
  17841. cardNumber := bas[2]
  17842. verify_number = cardNumber
  17843. }
  17844. api := "http://172.16.13.254:9532/" + "nmyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  17845. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  17846. "&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
  17847. resp, requestErr := http.Get(api)
  17848. if requestErr != nil {
  17849. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17850. return
  17851. }
  17852. body, ioErr := ioutil.ReadAll(resp.Body)
  17853. if ioErr != nil {
  17854. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  17855. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17856. return
  17857. }
  17858. var respJSON map[string]interface{}
  17859. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  17860. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  17861. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17862. return
  17863. }
  17864. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  17865. result, _ := json.Marshal(respJSON)
  17866. //if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  17867. // utils.ErrorLog("解析失败:%v", err)
  17868. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17869. // return
  17870. //}
  17871. //infocode = resThree.Infcode
  17872. //result, _ := json.Marshal(respJSON)
  17873. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  17874. utils.ErrorLog("解析失败:%v", err)
  17875. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17876. return
  17877. }
  17878. resThree.ErrMsg = resThree10265.ErrMsg
  17879. resThree.Output = resThree10265.Output
  17880. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  17881. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  17882. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  17883. psn_info, _ := service.GetPsnByPatientId(id)
  17884. his.PsnNo = psn_info.PsnNo
  17885. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  17886. var cert_no string
  17887. if id_card_type == 3 {
  17888. psn_info.VerifyNumber = IdCardNo + "|" + psn_info.VerifyNumber
  17889. cert_no = IdCardNo
  17890. } else if id_card_type == 4 {
  17891. cert_no = IdCardNo
  17892. psn_info.VerifyNumber = psn_info.VerifyNumber
  17893. } else {
  17894. bas := strings.Split(psn_info.CardInfo, "|")
  17895. cert_no = bas[2]
  17896. }
  17897. var hisPrescription []*models.HisPrescription
  17898. for _, item := range rf {
  17899. if item.Insutype == insutype {
  17900. //insuplc_admdvs = item.InsuplcAdmdvs
  17901. his.InsuplcAdmdvs = insuplc_admdvs
  17902. }
  17903. }
  17904. his.Insutype = insutype
  17905. res3101 := Check3101ForOne(c, patient.ID, his, admin_user_id, "1", record_time, hisPrescription)
  17906. fmt.Println(res3101)
  17907. fmt.Println(res3101.Infcode)
  17908. if res3101.Infcode == "0" {
  17909. fmt.Println("33333333")
  17910. if len(res3101.Output.Result) > 0 {
  17911. fmt.Println("222222")
  17912. for _, item := range res3101.Output.Result {
  17913. if len(res3101.ErrMsg) == 0 {
  17914. res3101.ErrMsg = item.VolaCont
  17915. } else {
  17916. res3101.ErrMsg = res3101.ErrMsg + "\n" + item.VolaCont
  17917. }
  17918. }
  17919. c.ServeSuccessJSON(map[string]interface{}{
  17920. "failed_code": -10,
  17921. "msg": res3101.ErrMsg,
  17922. })
  17923. return
  17924. } else {
  17925. fmt.Println("11111")
  17926. var api string
  17927. if miConfig.MdtrtareaAdmvs == "320921" {
  17928. ipt_otp_no = timeFormat
  17929. api = "http://192.168.2.3:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  17930. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  17931. "&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
  17932. } else {
  17933. ipt_otp_no = timeFormat
  17934. api = "http://192.168.5.251:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  17935. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  17936. "&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
  17937. }
  17938. resp, requestErr := http.Get(api)
  17939. if requestErr != nil {
  17940. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17941. return
  17942. }
  17943. body, ioErr := ioutil.ReadAll(resp.Body)
  17944. if ioErr != nil {
  17945. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  17946. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17947. return
  17948. }
  17949. var respJSON map[string]interface{}
  17950. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  17951. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  17952. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17953. return
  17954. }
  17955. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  17956. result, _ := json.Marshal(respJSON)
  17957. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  17958. utils.ErrorLog("解析失败:%v", err)
  17959. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17960. return
  17961. }
  17962. resThree.ErrMsg = resThree10265.ErrMsg
  17963. resThree.Output = resThree10265.Output
  17964. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  17965. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  17966. }
  17967. } else if res3101.Infcode != "0" {
  17968. c.ServeSuccessJSON(map[string]interface{}{
  17969. "failed_code": -10,
  17970. "msg": res3101.ErrMsg,
  17971. })
  17972. return
  17973. }
  17974. } else if miConfig.MdtrtareaAdmvs == "350500" {
  17975. psn_info, _ := service.GetPsnByPatientId(id)
  17976. var cert_no string
  17977. if id_card_type == 1 {
  17978. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  17979. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  17980. } else if id_card_type == 4 {
  17981. cert_no = psn_info.VerifyNumber
  17982. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  17983. } else {
  17984. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  17985. cert_no = psn_info.VerifyNumber
  17986. }
  17987. 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)
  17988. saveLog(result, requestLog, "2201", "挂号")
  17989. if miConfig.Code == "H15049901371" {
  17990. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  17991. utils.ErrorLog("解析失败:%v", err)
  17992. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17993. return
  17994. }
  17995. resThree.ErrMsg = resThree10265.ErrMsg
  17996. resThree.Output = resThree10265.Output
  17997. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  17998. } else {
  17999. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  18000. utils.ErrorLog("解析失败:%v", err)
  18001. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18002. return
  18003. }
  18004. }
  18005. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  18006. } else if miConfig.MdtrtareaAdmvs == "360302" { //江西萍乡
  18007. psn_info, _ := service.GetPsnByPatientId(id)
  18008. var result string
  18009. var requestLog string
  18010. if id_card_type == 1 {
  18011. bas := strings.Split(psn_info.CardInfo, "|")
  18012. basNumber := bas[2]
  18013. card_sn := bas[3]
  18014. 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)
  18015. saveLog(result, requestLog, "2201A", "挂号")
  18016. } else if id_card_type == 2 {
  18017. 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, "", "", "", "", "", "")
  18018. saveLog(result, requestLog, "2201A", "挂号")
  18019. } else {
  18020. 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)
  18021. saveLog(result, requestLog, "2201A", "挂号")
  18022. }
  18023. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  18024. utils.ErrorLog("解析失败:%v", err)
  18025. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18026. return
  18027. }
  18028. infocode = resThree.Infcode
  18029. } else if miConfig.MdtrtareaAdmvs == "341203" {
  18030. psn_info, _ := service.GetPsnByPatientId(id)
  18031. his.PsnNo = psn_info.PsnNo
  18032. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  18033. var cert_no string
  18034. if id_card_type == 1 {
  18035. bas := strings.Split(psn_info.CardInfo, "|")
  18036. cert_no = bas[2]
  18037. } else if id_card_type == 4 {
  18038. cert_no = IdCardNo
  18039. psn_info.VerifyNumber = psn_info.VerifyNumber
  18040. } else {
  18041. cert_no = IdCardNo
  18042. psn_info.VerifyNumber = cert_no
  18043. }
  18044. for _, item := range rf {
  18045. if item.Insutype == insutype {
  18046. his.InsuplcAdmdvs = insuplc_admdvs
  18047. }
  18048. }
  18049. his.Insutype = insutype
  18050. var api string
  18051. ipt_otp_no = timeFormat
  18052. api = miConfig.SecretKey + "ahyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  18053. "&org_name=" + miConfig.OrgName + "&opera=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  18054. "&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
  18055. resp, requestErr := http.Get(api)
  18056. if requestErr != nil {
  18057. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18058. return
  18059. }
  18060. body, ioErr := ioutil.ReadAll(resp.Body)
  18061. if ioErr != nil {
  18062. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  18063. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18064. return
  18065. }
  18066. var respJSON map[string]interface{}
  18067. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  18068. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18069. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18070. return
  18071. }
  18072. status := respJSON["data"].(map[string]interface{})["status"].(string)
  18073. if status == "0" {
  18074. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  18075. c.ServeSuccessJSON(map[string]interface{}{
  18076. "failed_code": -10,
  18077. "msg": err_msg,
  18078. })
  18079. return
  18080. }
  18081. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  18082. result, _ := json.Marshal(respJSON)
  18083. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  18084. utils.ErrorLog("解析失败:%v", err)
  18085. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18086. return
  18087. }
  18088. infocode = resThree.Infcode
  18089. } else if miConfig.MdtrtareaAdmvs == "430800" {
  18090. psn_info, _ := service.GetPsnByPatientId(id)
  18091. var result string
  18092. var requestLog string
  18093. if id_card_type == 1 {
  18094. bas := strings.Split(psn_info.CardInfo, "|")
  18095. basNumber := bas[2]
  18096. card_sn := bas[3]
  18097. 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)
  18098. saveLog(result, requestLog, "2201A", "挂号")
  18099. } else if id_card_type == 2 {
  18100. 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, "", "")
  18101. saveLog(result, requestLog, "2201A", "挂号")
  18102. } else {
  18103. 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, "", "")
  18104. saveLog(result, requestLog, "2201A", "挂号")
  18105. }
  18106. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  18107. utils.ErrorLog("解析失败:%v", err)
  18108. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18109. return
  18110. }
  18111. infocode = resThree.Infcode
  18112. } else if miConfig.MdtrtareaAdmvs == "131023" {
  18113. psn_info, _ := service.GetPsnByPatientId(id)
  18114. 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)
  18115. saveLog(result, requestLog, "2201A", "挂号")
  18116. if miConfig.Code == "H15049901371" {
  18117. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  18118. utils.ErrorLog("解析失败:%v", err)
  18119. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18120. return
  18121. }
  18122. resThree.ErrMsg = resThree10265.ErrMsg
  18123. resThree.Output = resThree10265.Output
  18124. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  18125. } else {
  18126. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  18127. utils.ErrorLog("解析失败:%v", err)
  18128. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18129. return
  18130. }
  18131. }
  18132. if miConfig.Code == "H15049901371" {
  18133. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  18134. } else {
  18135. infocode = resThree.Infcode
  18136. }
  18137. } else {
  18138. psn_info, _ := service.GetPsnByPatientId(id)
  18139. if id_card_type == 4 || id_card_type == 1 {
  18140. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  18141. }
  18142. var rf []*ResultFive
  18143. json.Unmarshal([]byte(psn_info.Insuinfo), &rf)
  18144. var insutypes []*ResultFive
  18145. var insutype string
  18146. var is390 int = 0
  18147. var is310 int = 0
  18148. for _, item := range rf {
  18149. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  18150. insutypes = append(insutypes, item)
  18151. }
  18152. }
  18153. if len(insutypes) == 1 {
  18154. insutype = insutypes[0].Insutype
  18155. insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  18156. } else {
  18157. for _, i := range insutypes {
  18158. if i.Insutype == "390" {
  18159. is390 = 1
  18160. }
  18161. if i.Insutype == "310" {
  18162. is310 = 1
  18163. }
  18164. }
  18165. }
  18166. if is390 == 1 {
  18167. insutype = "390"
  18168. }
  18169. if is310 == 1 {
  18170. insutype = "310"
  18171. }
  18172. fmt.Println(len(insutypes))
  18173. if len(insutypes) == 0 {
  18174. for index, item := range rf {
  18175. if index == 0 {
  18176. insutype = item.Insutype
  18177. insuplc_admdvs = item.InsuplcAdmdvs
  18178. }
  18179. }
  18180. fmt.Println(insutype)
  18181. fmt.Println(insuplc_admdvs)
  18182. }
  18183. if social_type > 0 {
  18184. insutype = strconv.FormatInt(social_type, 10)
  18185. }
  18186. fmt.Println("--------")
  18187. fmt.Println(psn_info)
  18188. fmt.Println(psn_info.PsnNo)
  18189. if miConfig.MdtrtareaAdmvs == "441202" {
  18190. var hisPrescription []*models.HisPrescription
  18191. res3101 := Checkgd3101ForOne(c, patient.ID, his, admin_user_id, "1", record_time, hisPrescription)
  18192. if res3101.Infcode == 0 {
  18193. fmt.Println("33333333")
  18194. if len(res3101.Output.Result) > 0 {
  18195. fmt.Println("222222")
  18196. for _, item := range res3101.Output.Result {
  18197. if len(res3101.ErrMsg) == 0 {
  18198. res3101.ErrMsg = item.VolaCont
  18199. } else {
  18200. res3101.ErrMsg = res3101.ErrMsg + "\n" + item.VolaCont
  18201. }
  18202. }
  18203. c.ServeSuccessJSON(map[string]interface{}{
  18204. "failed_code": -10,
  18205. "msg": res3101.ErrMsg,
  18206. })
  18207. return
  18208. } else {
  18209. hour := time.Now().Format("15")
  18210. min := time.Now().Format("04")
  18211. sec := time.Now().Format("05")
  18212. record_time_two := record_time + " " + hour + ":" + min + ":" + sec
  18213. fmt.Println(record_time_two)
  18214. 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)
  18215. saveLog(result, requestLog, "2201A", "挂号")
  18216. if miConfig.Code == "H15049901371" {
  18217. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  18218. utils.ErrorLog("解析失败:%v", err)
  18219. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18220. return
  18221. }
  18222. resThree.ErrMsg = resThree10265.ErrMsg
  18223. resThree.Output = resThree10265.Output
  18224. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  18225. } else {
  18226. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  18227. utils.ErrorLog("解析失败:%v", err)
  18228. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18229. return
  18230. }
  18231. }
  18232. if miConfig.Code == "H15049901371" {
  18233. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  18234. } else {
  18235. infocode = resThree.Infcode
  18236. }
  18237. }
  18238. } else if res3101.Infcode != 0 {
  18239. c.ServeSuccessJSON(map[string]interface{}{
  18240. "failed_code": -10,
  18241. "msg": res3101.ErrMsg,
  18242. })
  18243. return
  18244. }
  18245. } else if miConfig.MdtrtareaAdmvs == "441799" {
  18246. doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  18247. psn_info, _ := service.GetPsnByPatientId(id)
  18248. var verify_number string
  18249. if id_card_type == 4 {
  18250. verify_number = psn_info.VerifyNumber
  18251. } else if id_card_type == 1 {
  18252. bas := strings.Split(psn_info.CardInfo, "|")
  18253. cardNumber := bas[2]
  18254. verify_number = cardNumber
  18255. } else {
  18256. verify_number = psn_info.Certno
  18257. }
  18258. api := miConfig.Url + "gdyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  18259. "&org_name=" + miConfig.OrgName + "&operator=" + roles.UserName + "&doctor=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  18260. "&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
  18261. resp, requestErr := http.Get(api)
  18262. if requestErr != nil {
  18263. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18264. return
  18265. }
  18266. body, ioErr := ioutil.ReadAll(resp.Body)
  18267. if ioErr != nil {
  18268. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  18269. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18270. return
  18271. }
  18272. var respJSON map[string]interface{}
  18273. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  18274. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18275. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18276. return
  18277. }
  18278. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  18279. result, _ := json.Marshal(respJSON)
  18280. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  18281. utils.ErrorLog("解析失败:%v", err)
  18282. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18283. return
  18284. }
  18285. infocode = resThree.Infcode
  18286. } else {
  18287. hour := time.Now().Format("15")
  18288. min := time.Now().Format("04")
  18289. sec := time.Now().Format("05")
  18290. record_time_two := record_time + " " + hour + ":" + min + ":" + sec
  18291. if id_card_type == 1 {
  18292. for _, item := range rf {
  18293. if item.Insutype == strconv.FormatInt(social_type, 10) {
  18294. if strconv.FormatInt(social_type, 10) == "310" && item.PsnInsuStas == "1" {
  18295. insuplc_admdvs_temp = item.InsuplcAdmdvs
  18296. } else if strconv.FormatInt(social_type, 10) == "390" {
  18297. insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  18298. } else {
  18299. insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  18300. }
  18301. }
  18302. }
  18303. }
  18304. if miConfig.MdtrtareaAdmvs == "440205" && strconv.FormatInt(social_type, 10) == "390" {
  18305. insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  18306. }
  18307. if id_card_type == 1 {
  18308. utils.ErrorLog("解析失败:%v", psn_info.CardInfo)
  18309. bas := strings.Split(psn_info.CardInfo, "|")
  18310. basNumber := bas[1]
  18311. IdCardNo = basNumber
  18312. }
  18313. if miConfig.MdtrtareaAdmvs == "450721" && id_card_type == 1 {
  18314. IdCardNo = psn_info.VerifyNumber
  18315. }
  18316. 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)
  18317. saveLog(result, requestLog, "2201A", "挂号")
  18318. if miConfig.Code == "H15049901371" {
  18319. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  18320. utils.ErrorLog("解析失败:%v", err)
  18321. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18322. return
  18323. }
  18324. resThree.ErrMsg = resThree10265.ErrMsg
  18325. resThree.Output = resThree10265.Output
  18326. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  18327. } else {
  18328. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  18329. utils.ErrorLog("解析失败:%v", err)
  18330. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18331. return
  18332. }
  18333. }
  18334. if miConfig.Code == "H15049901371" {
  18335. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  18336. } else {
  18337. infocode = resThree.Infcode
  18338. }
  18339. }
  18340. }
  18341. if infocode != 0 {
  18342. adminUser := c.GetAdminUserInfo()
  18343. errlog := &models.HisOrderError{
  18344. UserOrgId: adminUser.CurrentOrgId,
  18345. Ctime: time.Now().Unix(),
  18346. Mtime: time.Now().Unix(),
  18347. ErrMsg: resThree.ErrMsg,
  18348. Status: 1,
  18349. PatientId: id,
  18350. RecordTime: recordDateTime,
  18351. Stage: 2,
  18352. }
  18353. service.CreateErrMsgLog(errlog)
  18354. c.ServeSuccessJSON(map[string]interface{}{
  18355. "failed_code": -10,
  18356. "msg": resThree.ErrMsg,
  18357. })
  18358. return
  18359. }
  18360. his.Number = resThree.Output.Data.MdtrtID
  18361. his.PsnNo = resThree.Output.Data.PsnNo
  18362. his.IptOtpNo = resThree.Output.Data.IptOtpNo
  18363. his.IdCardNo = patient.IdCardNo
  18364. his.PhoneNumber = patient.Phone
  18365. his.UserOrgId = adminInfo.CurrentOrgId
  18366. his.Insutype = insutype
  18367. his.Ctime = time.Now().Unix()
  18368. his.Mtime = time.Now().Unix()
  18369. his.InsuplcAdmdvs = insuplc_admdvs_temp
  18370. if miConfig.MdtrtareaAdmvs == "421300" && strings.Contains(insuplc_admdvs_temp, "4213") {
  18371. his.InsuplcAdmdvs = miConfig.MdtrtareaAdmvs
  18372. }
  18373. if miConfig.MdtrtareaAdmvs == "420200" && strings.Contains(insuplc_admdvs_temp, "4202") {
  18374. his.InsuplcAdmdvs = miConfig.MdtrtareaAdmvs
  18375. }
  18376. if miConfig.MdtrtareaAdmvs == "421182" && strings.Contains(insuplc_admdvs_temp, "4211") {
  18377. his.InsuplcAdmdvs = miConfig.MdtrtareaAdmvs
  18378. }
  18379. his.Status = 1
  18380. his.MdtrtGrpType = mdtrt_type
  18381. service.UpdateHisPatientStatus(&his)
  18382. service.UpdateHisPrescriptionHisID(his.ID, patient.ID, recordDateTime, adminInfo.CurrentOrgId)
  18383. c.ServeSuccessJSON(map[string]interface{}{
  18384. "his_info": his,
  18385. })
  18386. } else {
  18387. adminUser := c.GetAdminUserInfo()
  18388. errlog := &models.HisOrderError{
  18389. UserOrgId: adminUser.CurrentOrgId,
  18390. Ctime: time.Now().Unix(),
  18391. Mtime: time.Now().Unix(),
  18392. ErrMsg: res.ErrMsg,
  18393. Status: 1,
  18394. PatientId: id,
  18395. RecordTime: recordDateTime,
  18396. Stage: 1,
  18397. }
  18398. service.CreateErrMsgLog(errlog)
  18399. c.ServeSuccessJSON(map[string]interface{}{
  18400. "failed_code": -10,
  18401. "msg": res.ErrMsg,
  18402. })
  18403. return
  18404. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  18405. }
  18406. }
  18407. }
  18408. func (c *HisApiController) GetUploadInfo() {
  18409. id, _ := c.GetInt64("id")
  18410. record_time := c.GetString("record_time")
  18411. his_patient_id, _ := c.GetInt64("his_patient_id")
  18412. order_id, _ := c.GetInt64("order_id")
  18413. pay_way, _ := c.GetInt64("pay_way")
  18414. pay_ways := c.GetString("pay_ways")
  18415. oth_desc := c.GetString("oth_desc")
  18416. pay_price, _ := c.GetFloat("pay_price")
  18417. pay_card_no := c.GetString("pay_card_no")
  18418. discount_price, _ := c.GetFloat("discount_price")
  18419. preferential_price, _ := c.GetFloat("preferential_price")
  18420. reality_price, _ := c.GetFloat("reality_price")
  18421. found_price, _ := c.GetFloat("found_price")
  18422. medical_insurance_price, _ := c.GetFloat("medical_insurance_price")
  18423. private_price, _ := c.GetFloat("private_price")
  18424. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  18425. admin_user_id, _ := c.GetInt64("admin_user_id")
  18426. fapiao_code := c.GetString("fapiao_code")
  18427. fapiao_number := c.GetString("fapiao_number")
  18428. diagnosis_id := c.GetString("diagnosis")
  18429. sick_type, _ := c.GetInt64("sick_type")
  18430. reg_type, _ := c.GetInt64("p_type")
  18431. begin_time := c.GetString("begin_time")
  18432. acct_used_flag_num, _ := c.GetInt64("acct_used_flag")
  18433. cash_pay := c.GetString("cash_pay")
  18434. band_card_pay := c.GetString("band_card_pay")
  18435. wechat_pay := c.GetString("wechat_pay")
  18436. ali_pay := c.GetString("ali_pay")
  18437. jifen_pay := c.GetString("jifen_pay")
  18438. acct_used_flag := strconv.FormatInt(acct_used_flag_num, 10)
  18439. fmt.Println(acct_used_flag)
  18440. id_str := c.GetString("ids")
  18441. ids_arr := strings.Split(id_str, ",")
  18442. timeLayout := "2006-01-02"
  18443. loc, _ := time.LoadLocation("Local")
  18444. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  18445. if err != nil {
  18446. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  18447. return
  18448. }
  18449. recordDateTime := theTime.Unix()
  18450. adminUser := c.GetAdminUserInfo()
  18451. var tempOrder models.HisOrder
  18452. tempOrder, _ = service.GetHisOrderByID(order_id)
  18453. var prescriptions []*models.HisPrescription
  18454. var start_time int64
  18455. var end_time int64
  18456. //押金模块
  18457. dec_way := c.GetString("dec_way") //是否使用押金支付bool类型
  18458. tmp_decimal := c.GetString("tmp_decimal")
  18459. var decimal float64 //本次使用的押金
  18460. var errmsg error
  18461. if dec_way == "true" && tmp_decimal == "0" || dec_way == "true" && tmp_decimal == "" {
  18462. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "押金不能为0")
  18463. return
  18464. }
  18465. if len(tmp_decimal) > 0 {
  18466. if tmp_decimal[0] == 45 {
  18467. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "押金不能为负数")
  18468. return
  18469. }
  18470. }
  18471. tt, errs := strconv.ParseFloat(tmp_decimal, 64)
  18472. fmt.Println(errs)
  18473. decimal = tt
  18474. //if adminUser.CurrentOrgId == 10106{
  18475. // if len(fapiao_code) == 0{
  18476. // fapiao_code = "144072080589"
  18477. // }
  18478. // if len(fapiao_number) == 0{
  18479. // order, _ := service.GetLastHisOrder(adminUser.CurrentOrgId)
  18480. // if order.ID == 0{
  18481. // fapiao_number = "00001520"
  18482. // }else{
  18483. // //fapiao_code = "00001520"
  18484. // fpNumber, _ := strconv.Atoi(order.FaPiaoNumber)
  18485. // var zero string
  18486. // if fpNumber >= 1000{
  18487. // zero = "0000" + strconv.Itoa(fpNumber)
  18488. // }else if fpNumber >= 10000{
  18489. // zero = "000" + strconv.Itoa(fpNumber)
  18490. // } else if fpNumber >= 100000{
  18491. // zero = "00" + strconv.Itoa(fpNumber)
  18492. // } else if fpNumber >= 1000000{
  18493. // zero = "0" + strconv.Itoa(fpNumber)
  18494. // }else {
  18495. // zero = strconv.Itoa(fpNumber)
  18496. // }
  18497. // fapiao_number = zero
  18498. // }
  18499. // }
  18500. //}
  18501. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  18502. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  18503. var patientPrescription models.HisPrescriptionInfo
  18504. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  18505. if patientPrescription.ID == 0 {
  18506. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  18507. }
  18508. //if patientPrescription.Do
  18509. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  18510. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  18511. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  18512. diagnosis_ids := strings.Split(diagnosis_id, ",")
  18513. var config []*models.HisXtDiagnoseConfig
  18514. for _, item := range diagnosis_ids {
  18515. id, _ := strconv.ParseInt(item, 10, 64)
  18516. diagnosisConfig, _ := service.FindDiagnoseById(id)
  18517. config = append(config, &diagnosisConfig)
  18518. }
  18519. sickConfig, _ := service.FindSickById(sick_type)
  18520. //if tempOrder.ID == 0 {
  18521. // tempOrder, _ = service.GetTodayHisOrder(adminUser.CurrentOrgId, id, recordDateTime, his.Number)
  18522. //}
  18523. if tempOrder.ID == 0 {
  18524. var result string
  18525. var requestLog string
  18526. var res2 ResultSix
  18527. var res3 GZResultSix
  18528. var ressix10265 ResultSix10265
  18529. if miConfig.MdtrtareaAdmvs == "421300" {
  18530. data := make(map[string]interface{})
  18531. client := &http.Client{}
  18532. data["psn_no"] = his.PsnNo
  18533. data["mdtrt_id"] = his.Number
  18534. data["opter"] = roles.UserName
  18535. data["org_name"] = miConfig.OrgName
  18536. data["med_type"] = strconv.FormatInt(reg_type, 10)
  18537. data["doctor_id"] = doctor_info.DoctorNumber
  18538. data["doctor_name"] = doctor_info.UserName
  18539. data["department"] = department.Name
  18540. data["fixmedins_code"] = miConfig.Code
  18541. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  18542. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  18543. data["secret_key"] = miConfig.SecretKey
  18544. data["sick_code"] = sickConfig.CountryCode
  18545. data["sick_name"] = sickConfig.ClassName
  18546. data["dept"] = strconv.FormatInt(department.ID, 10)
  18547. data["config"] = config
  18548. data["begin_time"] = begin_time
  18549. bytesData, _ := json.Marshal(data)
  18550. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  18551. resp, _ := client.Do(req)
  18552. defer resp.Body.Close()
  18553. body, ioErr := ioutil.ReadAll(resp.Body)
  18554. if ioErr != nil {
  18555. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  18556. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18557. return
  18558. }
  18559. var respJSON map[string]interface{}
  18560. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  18561. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18562. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18563. return
  18564. }
  18565. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  18566. userJSONBytes, _ := json.Marshal(respJSON)
  18567. fmt.Println("log")
  18568. fmt.Println(string(userJSONBytes))
  18569. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  18570. utils.ErrorLog("解析失败:%v", err)
  18571. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18572. return
  18573. }
  18574. } else if miConfig.MdtrtareaAdmvs == "420200" {
  18575. data := make(map[string]interface{})
  18576. client := &http.Client{}
  18577. data["psn_no"] = his.PsnNo
  18578. data["mdtrt_id"] = his.Number
  18579. data["opter"] = roles.UserName
  18580. data["org_name"] = miConfig.OrgName
  18581. if reg_type == 11 && his.Insutype == "390" {
  18582. data["med_type"] = "110104"
  18583. } else {
  18584. data["med_type"] = strconv.FormatInt(reg_type, 10)
  18585. }
  18586. data["doctor_id"] = doctor_info.DoctorNumber
  18587. data["doctor_name"] = doctor_info.UserName
  18588. data["department"] = department.Name
  18589. data["fixmedins_code"] = miConfig.Code
  18590. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  18591. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  18592. data["secret_key"] = miConfig.SecretKey
  18593. data["sick_code"] = sickConfig.CountryCode
  18594. data["sick_name"] = sickConfig.ClassName
  18595. data["dept"] = strconv.FormatInt(department.ID, 10)
  18596. data["config"] = config
  18597. data["begin_time"] = begin_time
  18598. bytesData, _ := json.Marshal(data)
  18599. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  18600. resp, _ := client.Do(req)
  18601. defer resp.Body.Close()
  18602. body, ioErr := ioutil.ReadAll(resp.Body)
  18603. if ioErr != nil {
  18604. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  18605. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18606. return
  18607. }
  18608. var respJSON map[string]interface{}
  18609. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  18610. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18611. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18612. return
  18613. }
  18614. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  18615. userJSONBytes, _ := json.Marshal(respJSON)
  18616. fmt.Println("log")
  18617. fmt.Println(string(userJSONBytes))
  18618. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  18619. utils.ErrorLog("解析失败:%v", err)
  18620. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18621. return
  18622. }
  18623. } else if miConfig.MdtrtareaAdmvs == "420902" {
  18624. data := make(map[string]interface{})
  18625. client := &http.Client{}
  18626. data["psn_no"] = his.PsnNo
  18627. data["mdtrt_id"] = his.Number
  18628. data["opter"] = roles.UserName
  18629. data["org_name"] = miConfig.OrgName
  18630. if reg_type == 11 && his.Insutype == "390" {
  18631. data["med_type"] = "110104"
  18632. } else {
  18633. data["med_type"] = strconv.FormatInt(reg_type, 10)
  18634. }
  18635. data["doctor_id"] = doctor_info.DoctorNumber
  18636. data["doctor_name"] = doctor_info.UserName
  18637. data["department"] = department.Name
  18638. data["fixmedins_code"] = miConfig.Code
  18639. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  18640. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  18641. data["secret_key"] = miConfig.SecretKey
  18642. data["sick_code"] = sickConfig.CountryCode
  18643. data["sick_name"] = sickConfig.ClassName
  18644. data["dept"] = strconv.FormatInt(department.ID, 10)
  18645. data["config"] = config
  18646. data["begin_time"] = begin_time
  18647. bytesData, _ := json.Marshal(data)
  18648. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2203", bytes.NewReader(bytesData))
  18649. resp, _ := client.Do(req)
  18650. defer resp.Body.Close()
  18651. body, ioErr := ioutil.ReadAll(resp.Body)
  18652. if ioErr != nil {
  18653. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  18654. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18655. return
  18656. }
  18657. var respJSON map[string]interface{}
  18658. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  18659. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18660. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18661. return
  18662. }
  18663. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  18664. userJSONBytes, _ := json.Marshal(respJSON)
  18665. fmt.Println("log")
  18666. fmt.Println(string(userJSONBytes))
  18667. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  18668. utils.ErrorLog("解析失败:%v", err)
  18669. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18670. return
  18671. }
  18672. } else if miConfig.MdtrtareaAdmvs == "421182" {
  18673. data := make(map[string]interface{})
  18674. client := &http.Client{}
  18675. data["psn_no"] = his.PsnNo
  18676. data["mdtrt_id"] = his.Number
  18677. data["opter"] = roles.UserName
  18678. data["org_name"] = miConfig.OrgName
  18679. if reg_type == 11 && his.Insutype == "390" {
  18680. data["med_type"] = "110104"
  18681. } else {
  18682. data["med_type"] = strconv.FormatInt(reg_type, 10)
  18683. }
  18684. data["doctor_id"] = doctor_info.DoctorNumber
  18685. data["doctor_name"] = doctor_info.UserName
  18686. data["department"] = department.Name
  18687. data["fixmedins_code"] = miConfig.Code
  18688. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  18689. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  18690. data["secret_key"] = miConfig.SecretKey
  18691. data["sick_code"] = sickConfig.CountryCode
  18692. data["sick_name"] = sickConfig.ClassName
  18693. data["dept"] = strconv.FormatInt(department.ID, 10)
  18694. data["config"] = config
  18695. data["begin_time"] = begin_time
  18696. bytesData, _ := json.Marshal(data)
  18697. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2203", bytes.NewReader(bytesData))
  18698. resp, _ := client.Do(req)
  18699. defer resp.Body.Close()
  18700. body, ioErr := ioutil.ReadAll(resp.Body)
  18701. if ioErr != nil {
  18702. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  18703. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18704. return
  18705. }
  18706. var respJSON map[string]interface{}
  18707. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  18708. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18709. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18710. return
  18711. }
  18712. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  18713. userJSONBytes, _ := json.Marshal(respJSON)
  18714. fmt.Println("log")
  18715. fmt.Println(string(userJSONBytes))
  18716. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  18717. utils.ErrorLog("解析失败:%v", err)
  18718. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18719. return
  18720. }
  18721. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  18722. data := make(map[string]interface{})
  18723. client := &http.Client{}
  18724. data["psn_no"] = his.PsnNo
  18725. data["mdtrt_id"] = his.Number
  18726. data["doctor"] = roles.UserName
  18727. data["department"] = department.Name
  18728. data["org_name"] = miConfig.OrgName
  18729. data["med_type"] = strconv.FormatInt(reg_type, 10)
  18730. data["doctor_id"] = doctor_info.DoctorNumber
  18731. data["new_doctor_name"] = doctor_info.UserName
  18732. data["fixmedins_code"] = miConfig.Code
  18733. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  18734. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  18735. data["secret_key"] = miConfig.SecretKey
  18736. data["sick_code"] = sickConfig.CountryCode
  18737. data["sick_name"] = sickConfig.ClassName
  18738. data["url"] = miConfig.Url
  18739. data["ak"] = miConfig.AccessKey
  18740. data["begin_time"] = begin_time
  18741. data["cainfo"] = miConfig.Cainfo
  18742. data["dept"] = strconv.FormatInt(department.ID, 10)
  18743. data["config"] = config
  18744. bytesData, _ := json.Marshal(data)
  18745. var req *http.Request
  18746. if miConfig.MdtrtareaAdmvs == "320921" {
  18747. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  18748. //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 +
  18749. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo
  18750. } else {
  18751. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  18752. }
  18753. resp, _ := client.Do(req)
  18754. defer resp.Body.Close()
  18755. body, ioErr := ioutil.ReadAll(resp.Body)
  18756. if ioErr != nil {
  18757. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  18758. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18759. return
  18760. }
  18761. var respJSON map[string]interface{}
  18762. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  18763. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18764. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18765. return
  18766. }
  18767. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  18768. userJSONBytes, _ := json.Marshal(respJSON)
  18769. fmt.Println("log")
  18770. fmt.Println(string(userJSONBytes))
  18771. if err := json.Unmarshal(userJSONBytes, &ressix10265); err != nil {
  18772. utils.ErrorLog("解析失败:%v", err)
  18773. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18774. return
  18775. }
  18776. res2.InfRefmsgid = ressix10265.InfRefmsgid
  18777. res2.Output = ressix10265.Output
  18778. res2.ErrMsg = ressix10265.ErrMsg
  18779. res2.Cainfo = ressix10265.Cainfo
  18780. res2.WarnMsg = ressix10265.WarnMsg
  18781. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  18782. res2.Infcode = infocode
  18783. } else if miConfig.MdtrtareaAdmvs == "150499" {
  18784. data := make(map[string]interface{})
  18785. client := &http.Client{}
  18786. data["psn_no"] = his.PsnNo
  18787. data["mdtrt_id"] = his.Number
  18788. data["doctor"] = roles.UserName
  18789. data["department"] = department.Name
  18790. data["org_name"] = miConfig.OrgName
  18791. data["med_type"] = strconv.FormatInt(reg_type, 10)
  18792. data["doctor_id"] = doctor_info.DoctorNumber
  18793. data["new_doctor_name"] = doctor_info.UserName
  18794. data["fixmedins_code"] = miConfig.Code
  18795. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  18796. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  18797. data["secret_key"] = miConfig.SecretKey
  18798. data["sick_code"] = sickConfig.CountryCode
  18799. data["sick_name"] = sickConfig.ClassName
  18800. data["url"] = miConfig.Url
  18801. data["ak"] = miConfig.AccessKey
  18802. data["begin_time"] = begin_time
  18803. data["cainfo"] = miConfig.Cainfo
  18804. data["dept"] = strconv.FormatInt(department.ID, 10)
  18805. data["config"] = config
  18806. bytesData, _ := json.Marshal(data)
  18807. var req *http.Request
  18808. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2203", bytes.NewReader(bytesData))
  18809. resp, _ := client.Do(req)
  18810. defer resp.Body.Close()
  18811. body, ioErr := ioutil.ReadAll(resp.Body)
  18812. if ioErr != nil {
  18813. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  18814. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18815. return
  18816. }
  18817. var respJSON map[string]interface{}
  18818. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  18819. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18820. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18821. return
  18822. }
  18823. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  18824. userJSONBytes, _ := json.Marshal(respJSON)
  18825. fmt.Println("log")
  18826. fmt.Println(string(userJSONBytes))
  18827. if err := json.Unmarshal(userJSONBytes, &ressix10265); err != nil {
  18828. utils.ErrorLog("解析失败:%v", err)
  18829. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18830. return
  18831. }
  18832. res2.InfRefmsgid = ressix10265.InfRefmsgid
  18833. res2.Output = ressix10265.Output
  18834. res2.ErrMsg = ressix10265.ErrMsg
  18835. res2.Cainfo = ressix10265.Cainfo
  18836. res2.WarnMsg = ressix10265.WarnMsg
  18837. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  18838. res2.Infcode = infocode
  18839. } else if miConfig.MdtrtareaAdmvs == "350500" {
  18840. 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)
  18841. saveLog(result, requestLog, "2203", "上传就诊信息")
  18842. var respJSON2 map[string]interface{}
  18843. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  18844. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18845. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18846. return
  18847. }
  18848. userJSONBytes2, _ := json.Marshal(respJSON2)
  18849. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  18850. utils.ErrorLog("解析失败:%v", err)
  18851. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18852. return
  18853. }
  18854. 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)
  18855. fmt.Println(result2)
  18856. fmt.Println(src_request)
  18857. } else if miConfig.MdtrtareaAdmvs == "441799" {
  18858. data := make(map[string]interface{})
  18859. client := &http.Client{}
  18860. data["psn_no"] = his.PsnNo
  18861. data["mdtrt_id"] = his.Number
  18862. data["doctor"] = roles.UserName
  18863. data["department"] = department.Name
  18864. data["org_name"] = miConfig.OrgName
  18865. data["med_type"] = strconv.FormatInt(reg_type, 10)
  18866. data["doctor_id"] = doctor_info.DoctorNumber
  18867. data["new_doctor_name"] = doctor_info.UserName
  18868. data["fixmedins_code"] = miConfig.Code
  18869. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  18870. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  18871. data["secret_key"] = miConfig.SecretKey
  18872. data["sick_code"] = sickConfig.CountryCode
  18873. data["sick_name"] = sickConfig.ClassName
  18874. data["url"] = miConfig.Url
  18875. data["ak"] = miConfig.AccessKey
  18876. data["begin_time"] = begin_time
  18877. data["cainfo"] = miConfig.Cainfo
  18878. data["dept"] = strconv.FormatInt(department.ID, 10)
  18879. data["config"] = config
  18880. bytesData, _ := json.Marshal(data)
  18881. var req *http.Request
  18882. req, _ = http.NewRequest("POST", "http://172.20.10.81:9532/"+"gdyb/2203", bytes.NewReader(bytesData))
  18883. resp, _ := client.Do(req)
  18884. defer resp.Body.Close()
  18885. body, ioErr := ioutil.ReadAll(resp.Body)
  18886. if ioErr != nil {
  18887. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  18888. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18889. return
  18890. }
  18891. var respJSON map[string]interface{}
  18892. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  18893. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18894. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18895. return
  18896. }
  18897. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  18898. userJSONBytes, _ := json.Marshal(respJSON)
  18899. fmt.Println("log")
  18900. fmt.Println(string(userJSONBytes))
  18901. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  18902. utils.ErrorLog("解析失败:%v", err)
  18903. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18904. return
  18905. }
  18906. } else {
  18907. if miConfig.MdtrtareaAdmvs == "440781" { //
  18908. 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)
  18909. } else {
  18910. if miConfig.Code == "H15049901371" {
  18911. //赤峰地区国家医保医疗类别
  18912. //职工透析:医疗类别选特殊情况门诊990502
  18913. //居民定额血透门慢: 医疗类别选门诊慢病140104
  18914. var med_type string
  18915. if his.Insutype == "390" {
  18916. if reg_type == 14 {
  18917. med_type = "9933"
  18918. } else if reg_type == 11 {
  18919. med_type = "11"
  18920. }
  18921. } else if his.Insutype == "310" {
  18922. if reg_type == 14 {
  18923. med_type = "990502"
  18924. } else if reg_type == 11 {
  18925. med_type = "11"
  18926. }
  18927. }
  18928. 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)
  18929. } else {
  18930. 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)
  18931. }
  18932. }
  18933. saveLog(result, requestLog, "2203", "上传就诊信息")
  18934. var respJSON2 map[string]interface{}
  18935. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  18936. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18937. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18938. return
  18939. }
  18940. userJSONBytes2, _ := json.Marshal(respJSON2)
  18941. if miConfig.Code == "H15049901371" {
  18942. if err := json.Unmarshal(userJSONBytes2, &ressix10265); err != nil {
  18943. utils.ErrorLog("解析失败:%v", err)
  18944. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18945. return
  18946. }
  18947. res2.InfRefmsgid = ressix10265.InfRefmsgid
  18948. res2.Output = ressix10265.Output
  18949. res2.ErrMsg = ressix10265.ErrMsg
  18950. res2.Cainfo = ressix10265.Cainfo
  18951. res2.WarnMsg = ressix10265.WarnMsg
  18952. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  18953. res2.Infcode = infocode
  18954. } else {
  18955. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  18956. if err := json.Unmarshal(userJSONBytes2, &res3); err != nil {
  18957. utils.ErrorLog("解析失败:%v", err)
  18958. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18959. return
  18960. }
  18961. res2.Infcode = res3.Infcode
  18962. } else {
  18963. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  18964. utils.ErrorLog("解析失败:%v", err)
  18965. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18966. return
  18967. }
  18968. }
  18969. }
  18970. }
  18971. if res2.Infcode != 0 {
  18972. adminUser := c.GetAdminUserInfo()
  18973. errlog := &models.HisOrderError{
  18974. UserOrgId: adminUser.CurrentOrgId,
  18975. Ctime: time.Now().Unix(),
  18976. Mtime: time.Now().Unix(),
  18977. ErrMsg: res2.ErrMsg,
  18978. Status: 1,
  18979. PatientId: id,
  18980. RecordTime: recordDateTime,
  18981. Stage: 3,
  18982. }
  18983. service.CreateErrMsgLog(errlog)
  18984. c.ServeSuccessJSON(map[string]interface{}{
  18985. "failed_code": -10,
  18986. "msg": res2.ErrMsg,
  18987. })
  18988. return
  18989. } else {
  18990. his.Diagnosis = diagnosis_id
  18991. his.SickType = sickConfig.ID
  18992. //var p_type int64
  18993. //if reg_type == 1111 || reg_type == 1112 {
  18994. // p_type = 11
  18995. //
  18996. //}
  18997. his.PType = fmt.Sprintf("%d", reg_type)
  18998. service.UpdateHisPatientThree(&his)
  18999. data := make(map[string]interface{})
  19000. if settle_accounts_type == 1 { //日结
  19001. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  19002. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  19003. } else {
  19004. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  19005. }
  19006. //prescriptions, _ = service.GetNewHisPrescriptionTwo(adminUser.CurrentOrgId, his_patient_id, recordDateTime, reg_type)
  19007. data["pre"] = prescriptions
  19008. } else { //月结
  19009. start_time_str := c.GetString("start_time")
  19010. end_time_str := c.GetString("end_time")
  19011. timeLayout := "2006-01-02"
  19012. loc, _ := time.LoadLocation("Local")
  19013. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  19014. if err != nil {
  19015. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  19016. return
  19017. }
  19018. recordStartTime := theStartTime.Unix()
  19019. start_time = recordStartTime
  19020. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  19021. if err != nil {
  19022. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  19023. return
  19024. }
  19025. recordEndTime := theEndTime.Unix()
  19026. end_time = recordEndTime
  19027. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  19028. data["pre"] = prescriptions
  19029. }
  19030. timestamp := time.Now().Unix()
  19031. tempTime := time.Unix(timestamp, 0)
  19032. timeFormat := tempTime.Format("20060102150405")
  19033. chrgBchno := rand.Intn(100000) + 10000
  19034. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  19035. strconv.FormatInt(his.PatientId, 10)
  19036. client := &http.Client{}
  19037. data["psn_no"] = his.PsnNo
  19038. data["mdtrt_id"] = his.Number
  19039. data["chrg_bchno"] = chrg_bchno
  19040. data["org_name"] = miConfig.OrgName
  19041. data["doctor"] = doctor_info.UserName
  19042. data["doctor_id"] = doctor_info.DoctorNumber
  19043. data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  19044. data["fixmedins_code"] = miConfig.Code
  19045. data["dept_code"] = department.Number
  19046. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  19047. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  19048. data["secret_key"] = miConfig.SecretKey
  19049. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  19050. data["url"] = miConfig.Url
  19051. data["ak"] = miConfig.AccessKey
  19052. data["new_doctor_name"] = patientPrescription.Doctor
  19053. data["diag_code"] = sickConfig.CountryCode
  19054. data["cainfo"] = miConfig.Cainfo
  19055. data["opter"] = roles.UserName
  19056. var ids []int64
  19057. for _, item := range prescriptions {
  19058. ids = append(ids, item.ID)
  19059. }
  19060. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  19061. if config.IsOpen == 1 { //对接了医保,走医保流程
  19062. var res ResultFour
  19063. var resFour10265 ResultFour10265
  19064. if miConfig.MdtrtareaAdmvs == "421300" {
  19065. bytesData, _ := json.Marshal(data)
  19066. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  19067. resp, _ := client.Do(req)
  19068. defer resp.Body.Close()
  19069. body, ioErr := ioutil.ReadAll(resp.Body)
  19070. if ioErr != nil {
  19071. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19072. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19073. return
  19074. }
  19075. var respJSON map[string]interface{}
  19076. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  19077. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19078. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19079. return
  19080. }
  19081. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  19082. userJSONBytes, _ := json.Marshal(respJSON)
  19083. fmt.Println("log")
  19084. fmt.Println(string(userJSONBytes))
  19085. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19086. utils.ErrorLog("解析失败:%v", err)
  19087. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19088. return
  19089. }
  19090. } else if miConfig.MdtrtareaAdmvs == "420200" {
  19091. bytesData, _ := json.Marshal(data)
  19092. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  19093. resp, _ := client.Do(req)
  19094. defer resp.Body.Close()
  19095. body, ioErr := ioutil.ReadAll(resp.Body)
  19096. if ioErr != nil {
  19097. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19098. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19099. return
  19100. }
  19101. var respJSON map[string]interface{}
  19102. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  19103. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19104. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19105. return
  19106. }
  19107. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  19108. userJSONBytes, _ := json.Marshal(respJSON)
  19109. fmt.Println("log")
  19110. fmt.Println(string(userJSONBytes))
  19111. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19112. utils.ErrorLog("解析失败:%v", err)
  19113. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19114. return
  19115. }
  19116. } else if miConfig.MdtrtareaAdmvs == "420902" {
  19117. bytesData, _ := json.Marshal(data)
  19118. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2204", bytes.NewReader(bytesData))
  19119. resp, _ := client.Do(req)
  19120. defer resp.Body.Close()
  19121. body, ioErr := ioutil.ReadAll(resp.Body)
  19122. if ioErr != nil {
  19123. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19124. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19125. return
  19126. }
  19127. var respJSON map[string]interface{}
  19128. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  19129. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19130. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19131. return
  19132. }
  19133. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  19134. userJSONBytes, _ := json.Marshal(respJSON)
  19135. fmt.Println("log")
  19136. fmt.Println(string(userJSONBytes))
  19137. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19138. utils.ErrorLog("解析失败:%v", err)
  19139. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19140. return
  19141. }
  19142. } else if miConfig.MdtrtareaAdmvs == "421182" {
  19143. bytesData, _ := json.Marshal(data)
  19144. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2204", bytes.NewReader(bytesData))
  19145. resp, _ := client.Do(req)
  19146. defer resp.Body.Close()
  19147. body, ioErr := ioutil.ReadAll(resp.Body)
  19148. if ioErr != nil {
  19149. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19150. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19151. return
  19152. }
  19153. var respJSON map[string]interface{}
  19154. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  19155. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19156. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19157. return
  19158. }
  19159. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  19160. userJSONBytes, _ := json.Marshal(respJSON)
  19161. fmt.Println("log")
  19162. fmt.Println(string(userJSONBytes))
  19163. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19164. utils.ErrorLog("解析失败:%v", err)
  19165. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19166. return
  19167. }
  19168. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  19169. result3101 := Check3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  19170. if result3101.Infcode == "0" {
  19171. if len(result3101.Output.Result) > 0 {
  19172. var errMsgs []string
  19173. for _, item := range result3101.Output.Result {
  19174. errMsgs = append(errMsgs, item.VolaCont)
  19175. }
  19176. c.ServeSuccessJSON(map[string]interface{}{
  19177. "failed_code": -10,
  19178. "msg": errMsgs,
  19179. })
  19180. return
  19181. }
  19182. }
  19183. bytesData, _ := json.Marshal(data)
  19184. var req *http.Request
  19185. if miConfig.MdtrtareaAdmvs == "320921" {
  19186. data["diag_code"] = sickConfig.CountryCode
  19187. fmt.Println(data)
  19188. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  19189. } else {
  19190. data["diag_code"] = sickConfig.CountryCode
  19191. fmt.Println(data)
  19192. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  19193. }
  19194. resp, _ := client.Do(req)
  19195. defer resp.Body.Close()
  19196. body, ioErr := ioutil.ReadAll(resp.Body)
  19197. if ioErr != nil {
  19198. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19199. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19200. return
  19201. }
  19202. var respJSON map[string]interface{}
  19203. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  19204. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19205. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19206. return
  19207. }
  19208. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  19209. userJSONBytes, _ := json.Marshal(respJSON)
  19210. fmt.Println("log")
  19211. fmt.Println(string(userJSONBytes))
  19212. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  19213. utils.ErrorLog("解析失败:%v", err)
  19214. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19215. return
  19216. }
  19217. res.InfRefmsgid = resFour10265.InfRefmsgid
  19218. res.Output = resFour10265.Output
  19219. res.ErrMsg = resFour10265.ErrMsg
  19220. res.Cainfo = resFour10265.Cainfo
  19221. res.WarnMsg = resFour10265.WarnMsg
  19222. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  19223. res.Infcode = infocode
  19224. } else if miConfig.MdtrtareaAdmvs == "150499" {
  19225. var pagesize int = 2
  19226. var start int = 1
  19227. var stop int
  19228. var pagecount int
  19229. var curpage int
  19230. var isSuccess bool = true
  19231. data["doctor_id"] = doctor_info.DoctorNumber
  19232. //总页数,向上取整,注意除之前要先转换类型为float64
  19233. pagecount = int(math.Ceil(float64(len(prescriptions)) / float64(pagesize)))
  19234. for curpage = 1; curpage <= pagecount; curpage++ {
  19235. if curpage == 1 {
  19236. start = 1
  19237. } else {
  19238. start = (curpage-1)*pagesize + 1
  19239. }
  19240. stop = curpage * pagesize
  19241. if stop > len(prescriptions) {
  19242. stop = len(prescriptions)
  19243. }
  19244. //var requestLog string
  19245. data["pre"] = prescriptions[start-1 : stop]
  19246. fmt.Println(data["pre"])
  19247. bytesData, _ := json.Marshal(data)
  19248. var req *http.Request
  19249. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2204", bytes.NewReader(bytesData))
  19250. resp, _ := client.Do(req)
  19251. defer resp.Body.Close()
  19252. body, ioErr := ioutil.ReadAll(resp.Body)
  19253. if ioErr != nil {
  19254. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19255. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19256. return
  19257. }
  19258. var respJSON map[string]interface{}
  19259. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  19260. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19261. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19262. return
  19263. }
  19264. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  19265. userJSONBytes, _ := json.Marshal(respJSON)
  19266. fmt.Println("log")
  19267. fmt.Println(string(userJSONBytes))
  19268. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  19269. utils.ErrorLog("解析失败:%v", err)
  19270. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19271. return
  19272. }
  19273. res.InfRefmsgid = resFour10265.InfRefmsgid
  19274. res.Output = resFour10265.Output
  19275. res.ErrMsg = resFour10265.ErrMsg
  19276. res.Cainfo = resFour10265.Cainfo
  19277. res.WarnMsg = resFour10265.WarnMsg
  19278. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  19279. res.Infcode = infocode
  19280. if infocode == 0 {
  19281. res.Output.Result = append(res.Output.Result, res.Output.Result...)
  19282. } else {
  19283. isSuccess = false
  19284. errlog := &models.HisOrderError{
  19285. UserOrgId: adminUser.CurrentOrgId,
  19286. Ctime: time.Now().Unix(),
  19287. Mtime: time.Now().Unix(),
  19288. Number: chrg_bchno,
  19289. ErrMsg: "",
  19290. Status: 1,
  19291. PatientId: id,
  19292. RecordTime: recordDateTime,
  19293. Stage: 4,
  19294. }
  19295. service.CreateErrMsgLog(errlog)
  19296. c.ServeSuccessJSON(map[string]interface{}{
  19297. "failed_code": -10,
  19298. "msg": res.ErrMsg,
  19299. })
  19300. return
  19301. }
  19302. }
  19303. if isSuccess {
  19304. res.Infcode = 0
  19305. }
  19306. } else if miConfig.MdtrtareaAdmvs == "350500" {
  19307. 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)
  19308. var dat map[string]interface{}
  19309. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  19310. fmt.Println(dat)
  19311. } else {
  19312. fmt.Println(err)
  19313. }
  19314. saveLog(result, request_log, "2204", "上传费用明细")
  19315. userJSONBytes, _ := json.Marshal(dat)
  19316. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  19317. utils.ErrorLog("解析失败:%v", err)
  19318. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19319. return
  19320. }
  19321. res.InfRefmsgid = resFour10265.InfRefmsgid
  19322. res.Output = resFour10265.Output
  19323. res.ErrMsg = resFour10265.ErrMsg
  19324. res.Cainfo = resFour10265.Cainfo
  19325. res.WarnMsg = resFour10265.WarnMsg
  19326. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  19327. res.Infcode = infocode
  19328. } else if miConfig.MdtrtareaAdmvs == "441799" {
  19329. bytesData, _ := json.Marshal(data)
  19330. req, _ := http.NewRequest("POST", miConfig.Url+"gdyb/2204", bytes.NewReader(bytesData))
  19331. resp, _ := client.Do(req)
  19332. defer resp.Body.Close()
  19333. body, ioErr := ioutil.ReadAll(resp.Body)
  19334. if ioErr != nil {
  19335. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19336. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19337. return
  19338. }
  19339. var respJSON map[string]interface{}
  19340. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  19341. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19342. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19343. return
  19344. }
  19345. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  19346. userJSONBytes, _ := json.Marshal(respJSON)
  19347. fmt.Println("log")
  19348. fmt.Println(string(userJSONBytes))
  19349. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19350. utils.ErrorLog("解析失败:%v", err)
  19351. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19352. return
  19353. }
  19354. } else {
  19355. if miConfig.Code == "H15049901371" {
  19356. 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)
  19357. var dat map[string]interface{}
  19358. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  19359. fmt.Println(dat)
  19360. } else {
  19361. fmt.Println(err)
  19362. }
  19363. saveLog(result, request_log, "2204", "上传费用明细")
  19364. userJSONBytes, _ := json.Marshal(dat)
  19365. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  19366. utils.ErrorLog("解析失败:%v", err)
  19367. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19368. return
  19369. }
  19370. res.InfRefmsgid = resFour10265.InfRefmsgid
  19371. res.Output = resFour10265.Output
  19372. res.ErrMsg = resFour10265.ErrMsg
  19373. res.Cainfo = resFour10265.Cainfo
  19374. res.WarnMsg = resFour10265.WarnMsg
  19375. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  19376. res.Infcode = infocode
  19377. } else {
  19378. 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)
  19379. var dat map[string]interface{}
  19380. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  19381. fmt.Println(dat)
  19382. } else {
  19383. fmt.Println(err)
  19384. }
  19385. saveLog(result, request_log, "2204", "上传费用明细")
  19386. userJSONBytes, _ := json.Marshal(dat)
  19387. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19388. utils.ErrorLog("解析失败:%v", err)
  19389. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19390. return
  19391. }
  19392. }
  19393. }
  19394. if res.Infcode == 0 {
  19395. order := &models.HisOrder{
  19396. UserOrgId: adminUser.CurrentOrgId,
  19397. HisPatientId: his.ID,
  19398. PatientId: his.PatientId,
  19399. SettleAccountsDate: recordDateTime,
  19400. MdtrtId: his.Number,
  19401. PsnNo: his.PsnNo,
  19402. MedType: strconv.FormatInt(reg_type, 10),
  19403. Ctime: time.Now().Unix(),
  19404. Mtime: time.Now().Unix(),
  19405. Status: 1,
  19406. Number: chrg_bchno,
  19407. Infcode: res.Infcode,
  19408. WarnMsg: res.WarnMsg,
  19409. Cainfo: res.Cainfo,
  19410. ErrMsg: res.ErrMsg,
  19411. RespondTime: res.RefmsgTime,
  19412. InfRefmsgid: res.InfRefmsgid,
  19413. OrderStatus: 1,
  19414. PayWay: pay_way,
  19415. PayWays: pay_ways,
  19416. OthDesc: oth_desc,
  19417. PayPrice: pay_price,
  19418. PayCardNo: pay_card_no,
  19419. DiscountPrice: discount_price,
  19420. PreferentialPrice: preferential_price,
  19421. RealityPrice: reality_price,
  19422. FoundPrice: found_price,
  19423. MedicalInsurancePrice: medical_insurance_price,
  19424. PrivatePrice: private_price,
  19425. IsMedicineInsurance: 1,
  19426. SettleType: settle_accounts_type,
  19427. SettleStartTime: start_time,
  19428. SettleEndTime: end_time,
  19429. Creator: roles.AdminUserId,
  19430. Modify: roles.AdminUserId,
  19431. FaPiaoNumber: fapiao_number,
  19432. FaPiaoCode: fapiao_code,
  19433. PType: 2,
  19434. Diagnosis: diagnosis_id,
  19435. CashPay: cash_pay,
  19436. WechatPay: wechat_pay,
  19437. AliPay: ali_pay,
  19438. JifenPay: jifen_pay,
  19439. BandCardPay: band_card_pay,
  19440. }
  19441. err = service.CreateOrder(order)
  19442. if err != nil {
  19443. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  19444. return
  19445. }
  19446. for _, item := range res.Output.Result {
  19447. temp := strings.Split(item.FeedetlSn, "-")
  19448. var advice_id int64 = 0
  19449. var project_id int64 = 0
  19450. var types int64 = 0
  19451. id, _ := strconv.ParseInt(temp[2], 10, 64)
  19452. types, _ = strconv.ParseInt(temp[1], 10, 64)
  19453. if temp[1] == "1" {
  19454. advice_id = id
  19455. project_id = 0
  19456. } else if temp[1] == "2" {
  19457. advice_id = 0
  19458. project_id = id
  19459. }
  19460. if item.MedChrgitmType == "9" {
  19461. item.MedChrgitmType = "09"
  19462. }
  19463. info := &models.HisOrderInfo{
  19464. OrderNumber: order.Number,
  19465. FeedetlSn: item.FeedetlSn,
  19466. UploadDate: time.Now().Unix(),
  19467. AdviceId: advice_id,
  19468. DetItemFeeSumamt: item.DetItemFeeSumamt,
  19469. Cnt: item.Cnt,
  19470. Pric: float64(item.Pric),
  19471. PatientId: his.PatientId,
  19472. PricUplmtAmt: item.PricUplmtAmt,
  19473. SelfpayProp: item.SelfpayProp,
  19474. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  19475. OverlmtAmt: item.OverlmtAmt,
  19476. PreselfpayAmt: item.PreselfpayAmt,
  19477. BasMednFlag: item.BasMednFlag,
  19478. MedChrgitmType: item.MedChrgitmType,
  19479. HiNegoDrugFlag: item.HiNegoDrugFlag,
  19480. Status: 1,
  19481. Memo: item.Memo,
  19482. Mtime: time.Now().Unix(),
  19483. InscpScpAmt: item.InscpScpAmt,
  19484. DrtReimFlag: item.DrtReimFlag,
  19485. Ctime: time.Now().Unix(),
  19486. ListSpItemFlag: item.ListSpItemFlag,
  19487. ChldMedcFlag: item.ChldMedcFlag,
  19488. LmtUsedFlag: item.LmtUsedFlag,
  19489. ChrgitmLv: item.ChrgitmLv,
  19490. UserOrgId: adminUser.CurrentOrgId,
  19491. HisPatientId: his.ID,
  19492. OrderId: order.ID,
  19493. ProjectId: project_id,
  19494. Type: types,
  19495. }
  19496. service.CreateOrderInfo(info)
  19497. }
  19498. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  19499. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  19500. var total float64
  19501. for _, item := range prescriptions {
  19502. if item.Type == 1 { //药品
  19503. for _, subItem := range item.HisDoctorAdviceInfo {
  19504. price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  19505. total_one := price * subItem.PrescribingNumber
  19506. total = total + total_one
  19507. }
  19508. }
  19509. if item.Type == 2 { //项目
  19510. for _, subItem := range item.HisPrescriptionProject {
  19511. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  19512. price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  19513. total_one := price * cnt
  19514. total = total + total_one
  19515. }
  19516. }
  19517. }
  19518. allTotal := fmt.Sprintf("%.2f", total)
  19519. //if adminUser.CurrentOrgId == 9919 {
  19520. //
  19521. // allTotal = fmt.Sprintf("%.2f", total)
  19522. //
  19523. //} else {
  19524. //
  19525. // allTotal = fmt.Sprintf("%.2f", total)
  19526. //
  19527. //}
  19528. if res.Infcode == 0 {
  19529. var rf []*ResultFive
  19530. json.Unmarshal([]byte(his.Iinfo), &rf)
  19531. chrg_bchno := chrg_bchno
  19532. cert_no := his.Certno
  19533. var insutypes []string
  19534. var insutype string
  19535. var is390 int = 0
  19536. var is310 int = 0
  19537. for _, item := range rf {
  19538. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  19539. insutypes = append(insutypes, item.Insutype)
  19540. }
  19541. }
  19542. if len(insutypes) == 1 {
  19543. insutype = insutypes[0]
  19544. } else {
  19545. for _, i := range insutypes {
  19546. if i == "390" {
  19547. is390 = 1
  19548. }
  19549. if i == "310" {
  19550. is310 = 1
  19551. }
  19552. }
  19553. }
  19554. if is390 == 1 {
  19555. insutype = "390"
  19556. }
  19557. if is310 == 1 {
  19558. insutype = "310"
  19559. }
  19560. if len(insutypes) == 0 {
  19561. insutype = "310"
  19562. }
  19563. if len(insutypes) == 2 {
  19564. insutype = strconv.FormatInt(his.SocialType, 10)
  19565. }
  19566. insutype = strconv.FormatInt(his.SocialType, 10)
  19567. //insutype = "390"
  19568. if his.IdCardType == 1 {
  19569. // cert_no = his.MedicalInsuranceNumber
  19570. cert_no = his.Certno
  19571. } else {
  19572. cert_no = his.Certno
  19573. }
  19574. var res ResultSeven
  19575. var resSeven10265 ResultSeven10265
  19576. var gzresSeven10265Two GZResultSeven10265Two
  19577. var src_resquest string
  19578. var result2 string
  19579. if miConfig.MdtrtareaAdmvs == "421300" {
  19580. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  19581. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  19582. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  19583. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  19584. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  19585. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  19586. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  19587. resp, requestErr := http.Get(api)
  19588. if requestErr != nil {
  19589. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19590. return
  19591. }
  19592. body, ioErr := ioutil.ReadAll(resp.Body)
  19593. if ioErr != nil {
  19594. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19595. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19596. return
  19597. }
  19598. var respJSON map[string]interface{}
  19599. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  19600. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19601. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19602. return
  19603. }
  19604. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  19605. result, _ := json.Marshal(respJSON)
  19606. if miConfig.Code == "H15049901371" {
  19607. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  19608. utils.ErrorLog("解析失败:%v", err)
  19609. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19610. return
  19611. }
  19612. res.InfRefmsgid = resSeven10265.InfRefmsgid
  19613. res.Output = resSeven10265.Output
  19614. res.ErrMsg = resSeven10265.ErrMsg
  19615. res.Cainfo = resSeven10265.Cainfo
  19616. res.WarnMsg = resSeven10265.WarnMsg
  19617. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  19618. res.Infcode = infocode
  19619. } else {
  19620. if err := json.Unmarshal([]byte(result), &res); err != nil {
  19621. utils.ErrorLog("解析失败:%v", err)
  19622. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19623. return
  19624. }
  19625. }
  19626. } else if miConfig.MdtrtareaAdmvs == "420200" {
  19627. if reg_type == 11 && his.Insutype == "390" {
  19628. reg_type = 110104
  19629. }
  19630. api := "http://192.168.0.197:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  19631. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  19632. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  19633. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  19634. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  19635. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  19636. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  19637. resp, requestErr := http.Get(api)
  19638. if requestErr != nil {
  19639. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19640. return
  19641. }
  19642. body, ioErr := ioutil.ReadAll(resp.Body)
  19643. if ioErr != nil {
  19644. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19645. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19646. return
  19647. }
  19648. var respJSON map[string]interface{}
  19649. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  19650. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19651. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19652. return
  19653. }
  19654. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  19655. result, _ := json.Marshal(respJSON)
  19656. if miConfig.Code == "H15049901371" {
  19657. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  19658. utils.ErrorLog("解析失败:%v", err)
  19659. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19660. return
  19661. }
  19662. res.InfRefmsgid = resSeven10265.InfRefmsgid
  19663. res.Output = resSeven10265.Output
  19664. res.ErrMsg = resSeven10265.ErrMsg
  19665. res.Cainfo = resSeven10265.Cainfo
  19666. res.WarnMsg = resSeven10265.WarnMsg
  19667. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  19668. res.Infcode = infocode
  19669. } else {
  19670. if err := json.Unmarshal([]byte(result), &res); err != nil {
  19671. utils.ErrorLog("解析失败:%v", err)
  19672. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19673. return
  19674. }
  19675. }
  19676. } else if miConfig.MdtrtareaAdmvs == "420902" {
  19677. if reg_type == 11 && his.Insutype == "390" {
  19678. reg_type = 110104
  19679. }
  19680. api := miConfig.Url + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  19681. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  19682. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  19683. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  19684. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  19685. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  19686. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  19687. resp, requestErr := http.Get(api)
  19688. if requestErr != nil {
  19689. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19690. return
  19691. }
  19692. body, ioErr := ioutil.ReadAll(resp.Body)
  19693. if ioErr != nil {
  19694. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19695. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19696. return
  19697. }
  19698. var respJSON map[string]interface{}
  19699. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  19700. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19701. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19702. return
  19703. }
  19704. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  19705. result, _ := json.Marshal(respJSON)
  19706. if miConfig.Code == "H15049901371" {
  19707. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  19708. utils.ErrorLog("解析失败:%v", err)
  19709. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19710. return
  19711. }
  19712. res.InfRefmsgid = resSeven10265.InfRefmsgid
  19713. res.Output = resSeven10265.Output
  19714. res.ErrMsg = resSeven10265.ErrMsg
  19715. res.Cainfo = resSeven10265.Cainfo
  19716. res.WarnMsg = resSeven10265.WarnMsg
  19717. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  19718. res.Infcode = infocode
  19719. } else {
  19720. if err := json.Unmarshal([]byte(result), &res); err != nil {
  19721. utils.ErrorLog("解析失败:%v", err)
  19722. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19723. return
  19724. }
  19725. }
  19726. } else if miConfig.MdtrtareaAdmvs == "421182" {
  19727. if reg_type == 11 && his.Insutype == "390" {
  19728. reg_type = 110104
  19729. }
  19730. api := miConfig.Url + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  19731. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  19732. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  19733. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  19734. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  19735. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  19736. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  19737. resp, requestErr := http.Get(api)
  19738. if requestErr != nil {
  19739. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19740. return
  19741. }
  19742. body, ioErr := ioutil.ReadAll(resp.Body)
  19743. if ioErr != nil {
  19744. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19745. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19746. return
  19747. }
  19748. var respJSON map[string]interface{}
  19749. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  19750. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19751. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19752. return
  19753. }
  19754. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  19755. result, _ := json.Marshal(respJSON)
  19756. if miConfig.Code == "H15049901371" {
  19757. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  19758. utils.ErrorLog("解析失败:%v", err)
  19759. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19760. return
  19761. }
  19762. res.InfRefmsgid = resSeven10265.InfRefmsgid
  19763. res.Output = resSeven10265.Output
  19764. res.ErrMsg = resSeven10265.ErrMsg
  19765. res.Cainfo = resSeven10265.Cainfo
  19766. res.WarnMsg = resSeven10265.WarnMsg
  19767. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  19768. res.Infcode = infocode
  19769. } else {
  19770. if err := json.Unmarshal([]byte(result), &res); err != nil {
  19771. utils.ErrorLog("解析失败:%v", err)
  19772. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19773. return
  19774. }
  19775. }
  19776. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  19777. result3101 := Check3102(c, id, his_patient_id, admin_user_id, "7", order.ID)
  19778. if result3101.Infcode == "0" {
  19779. if len(result3101.Output.Result) > 0 {
  19780. var errMsgs []string
  19781. for _, item := range result3101.Output.Result {
  19782. errMsgs = append(errMsgs, item.VolaCont)
  19783. }
  19784. c.ServeSuccessJSON(map[string]interface{}{
  19785. "failed_code": -10,
  19786. "msg": errMsgs,
  19787. })
  19788. return
  19789. } else {
  19790. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  19791. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  19792. bas := strings.Split(psn_info.CardInfo, "|")
  19793. if his.IdCardType == 1 {
  19794. cert_no = bas[2]
  19795. } else if his.IdCardType == 3 {
  19796. cert_no = his.Certno
  19797. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  19798. } else if his.IdCardType == 4 {
  19799. cert_no = his.Certno
  19800. psn_info.VerifyNumber = psn_info.VerifyNumber
  19801. }
  19802. var api string
  19803. if miConfig.MdtrtareaAdmvs == "320921" {
  19804. api = "http://192.168.2.3:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  19805. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  19806. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  19807. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  19808. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  19809. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  19810. "&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
  19811. } else {
  19812. api = "http://192.168.5.251:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  19813. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  19814. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  19815. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  19816. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  19817. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  19818. "&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
  19819. }
  19820. resp, requestErr := http.Get(api)
  19821. if requestErr != nil {
  19822. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19823. return
  19824. }
  19825. body, ioErr := ioutil.ReadAll(resp.Body)
  19826. if ioErr != nil {
  19827. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19828. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19829. return
  19830. }
  19831. var respJSON map[string]interface{}
  19832. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  19833. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19834. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19835. return
  19836. }
  19837. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  19838. result, _ := json.Marshal(respJSON)
  19839. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  19840. utils.ErrorLog("解析失败:%v", err)
  19841. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19842. return
  19843. }
  19844. res.InfRefmsgid = resSeven10265.InfRefmsgid
  19845. res.Output = resSeven10265.Output
  19846. res.ErrMsg = resSeven10265.ErrMsg
  19847. res.Cainfo = resSeven10265.Cainfo
  19848. res.WarnMsg = resSeven10265.WarnMsg
  19849. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  19850. res.Infcode = infocode
  19851. }
  19852. }
  19853. } else if miConfig.MdtrtareaAdmvs == "150499" {
  19854. psn_info, _ := service.GetPsnByPatientId(id)
  19855. var verify_number string
  19856. if psn_info.IdCardType == 4 {
  19857. verify_number = psn_info.VerifyNumber
  19858. } else if psn_info.IdCardType == 1 {
  19859. bas := strings.Split(psn_info.CardInfo, "|")
  19860. cardNumber := bas[2]
  19861. verify_number = cardNumber
  19862. } else {
  19863. psn_info.IdCardType = 2
  19864. verify_number = psn_info.Certno
  19865. }
  19866. var api string
  19867. api = "http://172.16.13.254:9532/" + "nmyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  19868. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  19869. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  19870. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  19871. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  19872. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  19873. "&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
  19874. resp, requestErr := http.Get(api)
  19875. if requestErr != nil {
  19876. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19877. return
  19878. }
  19879. body, ioErr := ioutil.ReadAll(resp.Body)
  19880. if ioErr != nil {
  19881. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19882. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19883. return
  19884. }
  19885. var respJSON map[string]interface{}
  19886. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  19887. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19888. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19889. return
  19890. }
  19891. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  19892. result, _ := json.Marshal(respJSON)
  19893. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  19894. utils.ErrorLog("解析失败:%v", err)
  19895. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19896. return
  19897. }
  19898. res.InfRefmsgid = resSeven10265.InfRefmsgid
  19899. res.Output = resSeven10265.Output
  19900. res.ErrMsg = resSeven10265.ErrMsg
  19901. res.Cainfo = resSeven10265.Cainfo
  19902. res.WarnMsg = resSeven10265.WarnMsg
  19903. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  19904. res.Infcode = infocode
  19905. } else if miConfig.MdtrtareaAdmvs == "350500" {
  19906. var cert_no string
  19907. if his.IdCardType == 4 {
  19908. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  19909. cert_no = psn_info.VerifyNumber
  19910. 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)
  19911. } else if his.IdCardType == 1 {
  19912. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  19913. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  19914. 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)
  19915. }
  19916. //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)
  19917. var dat map[string]interface{}
  19918. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  19919. fmt.Println(dat)
  19920. } else {
  19921. fmt.Println(err)
  19922. }
  19923. saveLog(result2, src_resquest, "2207", "结算")
  19924. userJSONBytes, _ := json.Marshal(dat)
  19925. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  19926. utils.ErrorLog("解析失败:%v", err)
  19927. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19928. return
  19929. }
  19930. res.InfRefmsgid = resSeven10265.InfRefmsgid
  19931. res.Output = resSeven10265.Output
  19932. res.ErrMsg = resSeven10265.ErrMsg
  19933. res.Cainfo = resSeven10265.Cainfo
  19934. res.WarnMsg = resSeven10265.WarnMsg
  19935. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  19936. res.Infcode = infocode
  19937. } else if miConfig.MdtrtareaAdmvs == "450721" {
  19938. res2 := c.GetoleInfo()
  19939. if res2.Infcode == 0 {
  19940. var result string
  19941. var request_log string
  19942. var result_log string
  19943. if res2.Output.MdtrtCertType == "02" {
  19944. 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)
  19945. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  19946. } else if res2.Output.MdtrtCertType == "01" {
  19947. 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)
  19948. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  19949. } else {
  19950. 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)
  19951. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  19952. }
  19953. var dat map[string]interface{}
  19954. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  19955. fmt.Println(dat)
  19956. } else {
  19957. fmt.Println(err)
  19958. }
  19959. userJSONBytes, _ := json.Marshal(dat)
  19960. var res5 ResultTwo
  19961. //var resTwo10265 ResultTwo10265
  19962. if err := json.Unmarshal(userJSONBytes, &res5); err != nil {
  19963. utils.ErrorLog("解析失败:%v", err)
  19964. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19965. return
  19966. }
  19967. if res5.Infcode == -1 {
  19968. c.ServeSuccessJSON(map[string]interface{}{
  19969. "failed_code": -10,
  19970. "msg": res5.ErrMsg,
  19971. })
  19972. return
  19973. }
  19974. var insutypes []string
  19975. var insutype string
  19976. var is390 int = 0
  19977. var is310 int = 0
  19978. for _, item := range res5.Output.Iinfo {
  19979. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  19980. insutypes = append(insutypes, item.Insutype)
  19981. }
  19982. }
  19983. if len(insutypes) == 1 {
  19984. insutype = insutypes[0]
  19985. } else {
  19986. for _, i := range insutypes {
  19987. if i == "390" {
  19988. is390 = 1
  19989. }
  19990. if i == "310" {
  19991. is310 = 1
  19992. }
  19993. }
  19994. }
  19995. if is390 == 1 {
  19996. insutype = "390"
  19997. }
  19998. if is310 == 1 {
  19999. insutype = "310"
  20000. }
  20001. if len(insutypes) == 0 {
  20002. insutype = "310"
  20003. }
  20004. Iinfos, _ := json.Marshal(res5.Output.Iinfo)
  20005. Idetinfos, _ := json.Marshal(res5.Output.Idetinfo)
  20006. infoStr := string(Iinfos)
  20007. idetinfoStr := string(Idetinfos)
  20008. psn := &models.HisPsn{
  20009. PsnNo: res5.Output.Baseinfo.PsnNo,
  20010. PatientId: id,
  20011. Certno: res5.Output.Baseinfo.Certno,
  20012. Gend: res5.Output.Baseinfo.Gend,
  20013. Naty: res5.Output.Baseinfo.Naty,
  20014. PsnCertType: res5.Output.Baseinfo.PsnCertType,
  20015. PsnName: res5.Output.Baseinfo.PsnName,
  20016. Idetinfo: idetinfoStr,
  20017. Insuinfo: infoStr,
  20018. CardInfo: res2.Output.CardNo + "|" + res2.Output.CardSN,
  20019. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  20020. VerifyNumber: res2.Output.EcToken,
  20021. }
  20022. if res2.Output.MdtrtCertType == "01" {
  20023. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  20024. psn.VerifyNumber = res2.Output.EcToken
  20025. } else if res2.Output.MdtrtCertType == "02" {
  20026. psn.VerifyNumber = res2.Output.CardNo
  20027. } else {
  20028. psn.VerifyNumber = res2.Output.MdtrtCertNo
  20029. }
  20030. service.CreateHisPsn(psn)
  20031. if res2.Output.MdtrtCertType == "01" {
  20032. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  20033. token := res2.Output.EcToken
  20034. 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)
  20035. } else if res2.Output.MdtrtCertType == "02" {
  20036. 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)
  20037. } else {
  20038. 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)
  20039. }
  20040. var dat2 map[string]interface{}
  20041. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  20042. fmt.Println(dat2)
  20043. } else {
  20044. fmt.Println(err)
  20045. }
  20046. userJSONBytes3, _ := json.Marshal(dat2)
  20047. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  20048. utils.ErrorLog("解析失败:%v", err)
  20049. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20050. return
  20051. }
  20052. saveLog(result2, src_resquest, "2207", "结算")
  20053. } else {
  20054. c.ServeSuccessJSON(map[string]interface{}{
  20055. "failed_code": -10,
  20056. "msg": res2.ErrMsg,
  20057. })
  20058. return
  20059. }
  20060. } else {
  20061. if miConfig.Code == "H15049901371" {
  20062. //赤峰地区国家医保医疗类别
  20063. //职工透析:医疗类别选特殊情况门诊990502
  20064. //居民定额血透门慢: 医疗类别选门诊慢病140104
  20065. var med_type string
  20066. if his.Insutype == "390" {
  20067. if reg_type == 14 {
  20068. med_type = "9933"
  20069. } else if reg_type == 11 {
  20070. med_type = "11"
  20071. }
  20072. } else if his.Insutype == "310" {
  20073. if reg_type == 14 {
  20074. med_type = "990502"
  20075. } else if reg_type == 11 {
  20076. med_type = "11"
  20077. }
  20078. }
  20079. 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)
  20080. } else {
  20081. if his.IdCardType == 4 {
  20082. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  20083. var token string
  20084. token = psn_info.VerifyNumber
  20085. 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)
  20086. } else {
  20087. if his.IdCardType == 1 {
  20088. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  20089. bas := strings.Split(psn_info.CardInfo, "|")
  20090. basNumber := bas[2]
  20091. cert_no = basNumber
  20092. }
  20093. 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)
  20094. }
  20095. }
  20096. //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)
  20097. var dat map[string]interface{}
  20098. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  20099. fmt.Println(dat)
  20100. } else {
  20101. fmt.Println(err)
  20102. }
  20103. saveLog(result2, src_resquest, "2207", "结算")
  20104. userJSONBytes, _ := json.Marshal(dat)
  20105. if miConfig.Code == "H15049901371" {
  20106. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  20107. utils.ErrorLog("解析失败:%v", err)
  20108. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20109. return
  20110. }
  20111. res.InfRefmsgid = resSeven10265.InfRefmsgid
  20112. res.Output = resSeven10265.Output
  20113. res.ErrMsg = resSeven10265.ErrMsg
  20114. res.Cainfo = resSeven10265.Cainfo
  20115. res.WarnMsg = resSeven10265.WarnMsg
  20116. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  20117. res.Infcode = infocode
  20118. } else {
  20119. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  20120. if err := json.Unmarshal(userJSONBytes, &gzresSeven10265Two); err != nil {
  20121. utils.ErrorLog("解析失败:%v", err)
  20122. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20123. return
  20124. }
  20125. res.InfRefmsgid = gzresSeven10265Two.InfRefmsgid
  20126. res.Output.Setlinfo.AcctMulaidPay = gzresSeven10265Two.Output.Setlinfo.AcctMulaidPay
  20127. res.Output.Setlinfo.AcctPay = gzresSeven10265Two.Output.Setlinfo.AcctPay
  20128. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  20129. res.Output.Setlinfo.ActPayDedc = gzresSeven10265Two.Output.Setlinfo.ActPayDedc
  20130. res.Output.Setlinfo.Age = gzresSeven10265Two.Output.Setlinfo.Age
  20131. res.Output.Setlinfo.Balc = gzresSeven10265Two.Output.Setlinfo.Balc
  20132. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  20133. res.Output.Setlinfo.Certno = gzresSeven10265Two.Output.Setlinfo.Certno
  20134. res.Output.Setlinfo.ClrOptins = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  20135. res.Output.Setlinfo.ClrType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  20136. res.Output.Setlinfo.ClrWay = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  20137. res.Output.Setlinfo.CvlservFlag = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  20138. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  20139. res.Output.Setlinfo.FulamtOwnpayAmt = gzresSeven10265Two.Output.Setlinfo.FulamtOwnpayAmt
  20140. res.Output.Setlinfo.FundPaySumamt = gzresSeven10265Two.Output.Setlinfo.FundPaySumamt
  20141. res.Output.Setlinfo.Gend = gzresSeven10265Two.Output.Setlinfo.Gend
  20142. res.Output.Setlinfo.HifesPay = gzresSeven10265Two.Output.Setlinfo.HifesPay
  20143. res.Output.Setlinfo.HifmiPay = gzresSeven10265Two.Output.Setlinfo.HifmiPay
  20144. res.Output.Setlinfo.HifpPay = gzresSeven10265Two.Output.Setlinfo.HifpPay
  20145. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  20146. res.Output.Setlinfo.HospPartAmt = gzresSeven10265Two.Output.Setlinfo.HospPartAmt
  20147. res.Output.Setlinfo.InscpScpAmt = gzresSeven10265Two.Output.Setlinfo.InscpScpAmt
  20148. res.Output.Setlinfo.Insutype = gzresSeven10265Two.Output.Setlinfo.Insutype
  20149. res.Output.Setlinfo.MafPay = gzresSeven10265Two.Output.Setlinfo.MafPay
  20150. res.Output.Setlinfo.MdtrtCertType = gzresSeven10265Two.Output.Setlinfo.MdtrtCertType
  20151. res.Output.Setlinfo.HifobPay = gzresSeven10265Two.Output.Setlinfo.HifobPay
  20152. res.Output.Setlinfo.MdtrtID = gzresSeven10265Two.Output.Setlinfo.MdtrtID
  20153. res.Output.Setlinfo.MedType = gzresSeven10265Two.Output.Setlinfo.MedType
  20154. res.Output.Setlinfo.MedfeeSumamt = gzresSeven10265Two.Output.Setlinfo.MedfeeSumamt
  20155. res.Output.Setlinfo.MedinsSetlID = gzresSeven10265Two.Output.Setlinfo.MedinsSetlID
  20156. res.Output.Setlinfo.Naty = gzresSeven10265Two.Output.Setlinfo.Naty
  20157. res.Output.Setlinfo.OthPay = gzresSeven10265Two.Output.Setlinfo.OthPay
  20158. res.Output.Setlinfo.OverlmtSelfpay = gzresSeven10265Two.Output.Setlinfo.OverlmtSelfpay
  20159. PoolPropSelfpay, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.PoolPropSelfpay, 64)
  20160. res.Output.Setlinfo.PoolPropSelfpay = PoolPropSelfpay
  20161. res.Output.Setlinfo.PreselfpayAmt = gzresSeven10265Two.Output.Setlinfo.PreselfpayAmt
  20162. res.Output.Setlinfo.PsnCashPay = gzresSeven10265Two.Output.Setlinfo.PsnCashPay
  20163. res.Output.Setlinfo.PsnCertType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  20164. res.Output.Setlinfo.PsnName = gzresSeven10265Two.Output.Setlinfo.PsnName
  20165. res.Output.Setlinfo.PsnNo = gzresSeven10265Two.Output.Setlinfo.PsnNo
  20166. res.Output.Setlinfo.PsnPartAmt = gzresSeven10265Two.Output.Setlinfo.PsnPartAmt
  20167. res.Output.Setlinfo.PsnType = gzresSeven10265Two.Output.Setlinfo.PsnType
  20168. res.Output.Setlinfo.SetlID = gzresSeven10265Two.Output.Setlinfo.SetlID
  20169. res.Output.Setlinfo.SetlTime = gzresSeven10265Two.Output.Setlinfo.SetlTime
  20170. //res.Output.Setldetail = gzresSeven10265Two.Output.Setldetail
  20171. res.ErrMsg = gzresSeven10265Two.ErrMsg
  20172. res.Cainfo = gzresSeven10265Two.Cainfo
  20173. res.WarnMsg = gzresSeven10265Two.WarnMsg
  20174. //infocode, _ := strconv.ParseInt(resSeven10265Two.Infcode, 10, 64)
  20175. //res.Infcode = infocode
  20176. } else {
  20177. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20178. utils.ErrorLog("解析失败:%v", err)
  20179. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20180. return
  20181. }
  20182. }
  20183. }
  20184. }
  20185. if res.Infcode == -1 {
  20186. errlog := &models.HisOrderError{
  20187. UserOrgId: adminUser.CurrentOrgId,
  20188. Ctime: time.Now().Unix(),
  20189. Mtime: time.Now().Unix(),
  20190. Number: chrg_bchno,
  20191. ErrMsg: res.ErrMsg,
  20192. Status: 1,
  20193. PatientId: id,
  20194. RecordTime: recordDateTime,
  20195. Stage: 6,
  20196. }
  20197. service.CreateErrMsgLog(errlog)
  20198. c.ServeSuccessJSON(map[string]interface{}{
  20199. "failed_code": -10,
  20200. "msg": res.ErrMsg,
  20201. })
  20202. return
  20203. } else {
  20204. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  20205. order.OrderStatus = 2
  20206. order.Status = 1
  20207. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  20208. order.SetlId = res.Output.Setlinfo.SetlID
  20209. order.PsnNo = res.Output.Setlinfo.PsnNo
  20210. order.PsnName = res.Output.Setlinfo.PsnName
  20211. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  20212. order.Certno = res.Output.Setlinfo.Certno
  20213. order.Gend = res.Output.Setlinfo.Gend
  20214. order.Naty = res.Output.Setlinfo.Naty
  20215. order.Age = res.Output.Setlinfo.Age
  20216. order.Insutype = res.Output.Setlinfo.Insutype
  20217. order.PsnType = res.Output.Setlinfo.PsnType
  20218. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  20219. order.SetlTime = res.Output.Setlinfo.SetlTime
  20220. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  20221. if res.Output.Setlinfo.MedType == "140101" {
  20222. order.MedType = "14"
  20223. } else {
  20224. if res.Output.Setlinfo.MedType == "110104" {
  20225. order.MedType = "11"
  20226. } else {
  20227. order.MedType = res.Output.Setlinfo.MedType
  20228. }
  20229. }
  20230. if reg_type == 1112 {
  20231. order.MedType = "1112"
  20232. }
  20233. if reg_type == 1111 {
  20234. order.MedType = "1111"
  20235. }
  20236. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  20237. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  20238. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  20239. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  20240. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  20241. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  20242. order.HifpPay = res.Output.Setlinfo.HifpPay
  20243. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  20244. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  20245. order.HifesPay = res.Output.Setlinfo.HifesPay
  20246. order.HifobPay = res.Output.Setlinfo.HifobPay
  20247. order.MafPay = res.Output.Setlinfo.MafPay
  20248. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  20249. order.OthPay = res.Output.Setlinfo.OthPay
  20250. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  20251. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  20252. order.AcctPay = res.Output.Setlinfo.AcctPay
  20253. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  20254. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  20255. order.Balc = res.Output.Setlinfo.Balc
  20256. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  20257. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  20258. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  20259. order.ClrType = res.Output.Setlinfo.ClrType
  20260. order.ClrWay = res.Output.Setlinfo.ClrWay
  20261. order.Creator = order.Creator
  20262. order.Modify = roles.AdminUserId
  20263. order.RequestLog = src_resquest
  20264. order.FaPiaoNumber = fapiao_number
  20265. order.FaPiaoCode = fapiao_code
  20266. //setlDetail, _ := json.Marshal(res.Output.Setldetail)
  20267. //detailStr := string(setlDetail)
  20268. //order.SetlDetail = detailStr
  20269. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  20270. err = service.UpDateOrder(order)
  20271. if err == nil {
  20272. //判断是否使用了押金
  20273. if dec_way == "true" {
  20274. tmpstring := strconv.FormatInt(order.ID, 10)
  20275. order.Decimal = decimal
  20276. service.UpDateOrder(order)
  20277. //扣押金
  20278. errmsg = service.SpendDeposit(c.GetAdminUserInfo().CurrentOrgId, id, c.GetAdminUserInfo().AdminUser.Id, tmpstring, decimal)
  20279. if errmsg != nil {
  20280. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, errmsg.Error())
  20281. return
  20282. }
  20283. }
  20284. c.ServeSuccessJSON(map[string]interface{}{
  20285. "msg": "结算成功",
  20286. })
  20287. } else {
  20288. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  20289. return
  20290. }
  20291. }
  20292. } else {
  20293. adminUser := c.GetAdminUserInfo()
  20294. errlog := &models.HisOrderError{
  20295. UserOrgId: adminUser.CurrentOrgId,
  20296. Ctime: time.Now().Unix(),
  20297. Mtime: time.Now().Unix(),
  20298. ErrMsg: res.ErrMsg,
  20299. Status: 1,
  20300. PatientId: id,
  20301. RecordTime: recordDateTime,
  20302. Stage: 4,
  20303. }
  20304. service.CreateErrMsgLog(errlog)
  20305. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  20306. return
  20307. }
  20308. } else {
  20309. adminUser := c.GetAdminUserInfo()
  20310. errlog := &models.HisOrderError{
  20311. UserOrgId: adminUser.CurrentOrgId,
  20312. Ctime: time.Now().Unix(),
  20313. Mtime: time.Now().Unix(),
  20314. ErrMsg: res.ErrMsg,
  20315. Status: 1,
  20316. PatientId: id,
  20317. RecordTime: recordDateTime,
  20318. Stage: 4,
  20319. }
  20320. service.CreateErrMsgLog(errlog)
  20321. c.ServeSuccessJSON(map[string]interface{}{
  20322. "failed_code": -10,
  20323. "msg": res.ErrMsg,
  20324. })
  20325. return
  20326. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  20327. //return
  20328. }
  20329. }
  20330. }
  20331. } else if tempOrder.ID > 0 {
  20332. if tempOrder.IsPre == 1 {
  20333. allTotal := fmt.Sprintf("%.2f", tempOrder.MedfeeSumamt)
  20334. var rf []*ResultFive
  20335. json.Unmarshal([]byte(his.Iinfo), &rf)
  20336. chrg_bchno := tempOrder.Number
  20337. cert_no := his.Certno
  20338. var insutypes []string
  20339. var insutype string
  20340. var is390 int = 0
  20341. var is310 int = 0
  20342. for _, item := range rf {
  20343. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  20344. insutypes = append(insutypes, item.Insutype)
  20345. }
  20346. }
  20347. if len(insutypes) == 1 {
  20348. insutype = insutypes[0]
  20349. } else {
  20350. for _, i := range insutypes {
  20351. if i == "390" {
  20352. is390 = 1
  20353. }
  20354. if i == "310" {
  20355. is310 = 1
  20356. }
  20357. }
  20358. }
  20359. if is390 == 1 {
  20360. insutype = "390"
  20361. }
  20362. if is310 == 1 {
  20363. insutype = "310"
  20364. }
  20365. if len(insutypes) == 0 {
  20366. insutype = "310"
  20367. }
  20368. if len(insutypes) == 2 {
  20369. insutype = strconv.FormatInt(his.SocialType, 10)
  20370. }
  20371. //insutype = "390"
  20372. if his.IdCardType == 1 {
  20373. // cert_no = his.MedicalInsuranceNumber
  20374. cert_no = his.Certno
  20375. } else {
  20376. cert_no = his.Certno
  20377. }
  20378. var res ResultSeven
  20379. var ahres ResultSevenAH
  20380. var resSeven10265 ResultSeven10265
  20381. var gzresSeven10265Two GZResultSeven10265Two
  20382. var src_resquest string
  20383. var result2 string
  20384. if miConfig.MdtrtareaAdmvs == "450721" {
  20385. res2 := c.GetoleInfo()
  20386. if res2.Infcode == 0 {
  20387. var result string
  20388. var request_log string
  20389. var result_log string
  20390. if res2.Output.MdtrtCertType == "02" {
  20391. 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)
  20392. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  20393. } else if res2.Output.MdtrtCertType == "01" {
  20394. 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)
  20395. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  20396. } else {
  20397. 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)
  20398. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  20399. }
  20400. var dat map[string]interface{}
  20401. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  20402. fmt.Println(dat)
  20403. } else {
  20404. fmt.Println(err)
  20405. }
  20406. userJSONBytes, _ := json.Marshal(dat)
  20407. var res5 ResultTwo
  20408. //var resTwo10265 ResultTwo10265
  20409. if err := json.Unmarshal(userJSONBytes, &res5); err != nil {
  20410. utils.ErrorLog("解析失败:%v", err)
  20411. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20412. return
  20413. }
  20414. //utils.ErrorLog("解析失败:%v", res5.Infcode)
  20415. if res5.Infcode == -1 {
  20416. c.ServeSuccessJSON(map[string]interface{}{
  20417. "failed_code": -10,
  20418. "msg": res5.ErrMsg,
  20419. })
  20420. return
  20421. }
  20422. var insutypes []string
  20423. var insutype string
  20424. var is390 int = 0
  20425. var is310 int = 0
  20426. for _, item := range res5.Output.Iinfo {
  20427. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  20428. insutypes = append(insutypes, item.Insutype)
  20429. }
  20430. }
  20431. if len(insutypes) == 1 {
  20432. insutype = insutypes[0]
  20433. } else {
  20434. for _, i := range insutypes {
  20435. if i == "390" {
  20436. is390 = 1
  20437. }
  20438. if i == "310" {
  20439. is310 = 1
  20440. }
  20441. }
  20442. }
  20443. if is390 == 1 {
  20444. insutype = "390"
  20445. }
  20446. if is310 == 1 {
  20447. insutype = "310"
  20448. }
  20449. if len(insutypes) == 0 {
  20450. insutype = "310"
  20451. }
  20452. Iinfos, _ := json.Marshal(res5.Output.Iinfo)
  20453. Idetinfos, _ := json.Marshal(res5.Output.Idetinfo)
  20454. infoStr := string(Iinfos)
  20455. idetinfoStr := string(Idetinfos)
  20456. psn := &models.HisPsn{
  20457. PsnNo: res5.Output.Baseinfo.PsnNo,
  20458. PatientId: id,
  20459. Certno: res5.Output.Baseinfo.Certno,
  20460. Gend: res5.Output.Baseinfo.Gend,
  20461. Naty: res5.Output.Baseinfo.Naty,
  20462. PsnCertType: res5.Output.Baseinfo.PsnCertType,
  20463. PsnName: res5.Output.Baseinfo.PsnName,
  20464. Idetinfo: idetinfoStr,
  20465. Insuinfo: infoStr,
  20466. CardInfo: res2.Output.CardNo + "|" + res2.Output.CardSN,
  20467. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  20468. VerifyNumber: res2.Output.EcToken,
  20469. }
  20470. service.CreateHisPsn(psn)
  20471. if res2.Output.MdtrtCertType == "01" {
  20472. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  20473. token := res2.Output.EcToken
  20474. 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)
  20475. } else if res2.Output.MdtrtCertType == "02" {
  20476. 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)
  20477. } else {
  20478. 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)
  20479. }
  20480. var dat2 map[string]interface{}
  20481. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  20482. fmt.Println(dat2)
  20483. } else {
  20484. fmt.Println(err)
  20485. }
  20486. userJSONBytes3, _ := json.Marshal(dat2)
  20487. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  20488. utils.ErrorLog("解析失败:%v", err)
  20489. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20490. return
  20491. }
  20492. saveLog(result2, src_resquest, "2207", "结算")
  20493. } else {
  20494. c.ServeSuccessJSON(map[string]interface{}{
  20495. "failed_code": -10,
  20496. "msg": res2.ErrMsg,
  20497. })
  20498. return
  20499. }
  20500. } else if miConfig.MdtrtareaAdmvs == "421300" {
  20501. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  20502. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  20503. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  20504. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  20505. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  20506. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  20507. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  20508. resp, requestErr := http.Get(api)
  20509. if requestErr != nil {
  20510. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20511. return
  20512. }
  20513. body, ioErr := ioutil.ReadAll(resp.Body)
  20514. if ioErr != nil {
  20515. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  20516. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20517. return
  20518. }
  20519. var respJSON map[string]interface{}
  20520. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  20521. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  20522. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20523. return
  20524. }
  20525. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  20526. result, _ := json.Marshal(respJSON)
  20527. fmt.Println("log")
  20528. fmt.Println(string(result))
  20529. if err := json.Unmarshal([]byte(result), &res); err != nil {
  20530. utils.ErrorLog("解析失败:%v", err)
  20531. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20532. return
  20533. }
  20534. } else if miConfig.MdtrtareaAdmvs == "420200" {
  20535. if reg_type == 11 && his.Insutype == "390" {
  20536. reg_type = 110104
  20537. }
  20538. api := "http://192.168.0.197:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  20539. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  20540. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  20541. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  20542. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  20543. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  20544. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  20545. resp, requestErr := http.Get(api)
  20546. if requestErr != nil {
  20547. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20548. return
  20549. }
  20550. body, ioErr := ioutil.ReadAll(resp.Body)
  20551. if ioErr != nil {
  20552. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  20553. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20554. return
  20555. }
  20556. var respJSON map[string]interface{}
  20557. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  20558. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  20559. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20560. return
  20561. }
  20562. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  20563. result, _ := json.Marshal(respJSON)
  20564. fmt.Println("log")
  20565. fmt.Println(string(result))
  20566. if err := json.Unmarshal([]byte(result), &res); err != nil {
  20567. utils.ErrorLog("解析失败:%v", err)
  20568. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20569. return
  20570. }
  20571. } else if miConfig.MdtrtareaAdmvs == "420902" {
  20572. if reg_type == 11 && his.Insutype == "390" {
  20573. reg_type = 110104
  20574. }
  20575. api := miConfig.Url + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  20576. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  20577. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  20578. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  20579. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  20580. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  20581. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  20582. resp, requestErr := http.Get(api)
  20583. if requestErr != nil {
  20584. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20585. return
  20586. }
  20587. body, ioErr := ioutil.ReadAll(resp.Body)
  20588. if ioErr != nil {
  20589. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  20590. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20591. return
  20592. }
  20593. var respJSON map[string]interface{}
  20594. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  20595. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  20596. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20597. return
  20598. }
  20599. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  20600. result, _ := json.Marshal(respJSON)
  20601. fmt.Println("log")
  20602. fmt.Println(string(result))
  20603. if err := json.Unmarshal([]byte(result), &res); err != nil {
  20604. utils.ErrorLog("解析失败:%v", err)
  20605. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20606. return
  20607. }
  20608. } else if miConfig.MdtrtareaAdmvs == "421182" {
  20609. if reg_type == 11 && his.Insutype == "390" {
  20610. reg_type = 110104
  20611. }
  20612. api := miConfig.Url + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  20613. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  20614. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  20615. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  20616. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  20617. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  20618. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  20619. resp, requestErr := http.Get(api)
  20620. if requestErr != nil {
  20621. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20622. return
  20623. }
  20624. body, ioErr := ioutil.ReadAll(resp.Body)
  20625. if ioErr != nil {
  20626. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  20627. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20628. return
  20629. }
  20630. var respJSON map[string]interface{}
  20631. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  20632. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  20633. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20634. return
  20635. }
  20636. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  20637. result, _ := json.Marshal(respJSON)
  20638. fmt.Println("log")
  20639. fmt.Println(string(result))
  20640. if err := json.Unmarshal([]byte(result), &res); err != nil {
  20641. utils.ErrorLog("解析失败:%v", err)
  20642. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20643. return
  20644. }
  20645. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  20646. result3101 := Check3102(c, id, his_patient_id, admin_user_id, "7", tempOrder.ID)
  20647. if result3101.Infcode == "0" {
  20648. if len(result3101.Output.Result) > 0 {
  20649. var errMsgs []string
  20650. for _, item := range result3101.Output.Result {
  20651. errMsgs = append(errMsgs, item.VolaCont)
  20652. }
  20653. c.ServeSuccessJSON(map[string]interface{}{
  20654. "failed_code": -10,
  20655. "msg": errMsgs,
  20656. })
  20657. return
  20658. } else {
  20659. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  20660. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  20661. bas := strings.Split(psn_info.CardInfo, "|")
  20662. if his.IdCardType == 1 {
  20663. cert_no = bas[2]
  20664. } else if his.IdCardType == 3 {
  20665. cert_no = his.Certno
  20666. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  20667. } else if his.IdCardType == 4 {
  20668. cert_no = his.Certno
  20669. psn_info.VerifyNumber = psn_info.VerifyNumber
  20670. }
  20671. //江苏地区国家医保医疗类别
  20672. //职工透析:医疗类别选特殊情况门诊9933
  20673. //居民血透门慢: 医疗类别选门诊慢病1402
  20674. //var med_type string
  20675. //if his.Insutype == "310" {
  20676. // if reg_type == 14 {
  20677. // med_type = "9933"
  20678. // } else if reg_type == 11 {
  20679. // med_type = "11"
  20680. //
  20681. // }
  20682. //} else if his.Insutype == "390" {
  20683. // if reg_type == 14 {
  20684. // med_type = "1402"
  20685. // } else if reg_type == 11 {
  20686. // med_type = "11"
  20687. // }
  20688. //}
  20689. var api string
  20690. if miConfig.MdtrtareaAdmvs == "320921" {
  20691. api = "http://192.168.2.3:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  20692. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  20693. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  20694. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  20695. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  20696. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  20697. "&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
  20698. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  20699. } else {
  20700. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  20701. api = "http://192.168.5.251:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  20702. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  20703. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  20704. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  20705. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  20706. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  20707. "&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
  20708. }
  20709. resp, requestErr := http.Get(api)
  20710. if requestErr != nil {
  20711. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20712. return
  20713. }
  20714. body, ioErr := ioutil.ReadAll(resp.Body)
  20715. if ioErr != nil {
  20716. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  20717. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20718. return
  20719. }
  20720. var respJSON map[string]interface{}
  20721. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  20722. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  20723. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20724. return
  20725. }
  20726. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  20727. result, _ := json.Marshal(respJSON)
  20728. fmt.Println("log")
  20729. fmt.Println(string(result))
  20730. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  20731. utils.ErrorLog("解析失败:%v", err)
  20732. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20733. return
  20734. }
  20735. res.InfRefmsgid = resSeven10265.InfRefmsgid
  20736. res.Output = resSeven10265.Output
  20737. res.InfRefmsgid = resSeven10265.InfRefmsgid
  20738. res.ErrMsg = resSeven10265.ErrMsg
  20739. res.Cainfo = resSeven10265.Cainfo
  20740. res.WarnMsg = resSeven10265.WarnMsg
  20741. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  20742. res.Infcode = infocode
  20743. }
  20744. }
  20745. } else if miConfig.MdtrtareaAdmvs == "150499" {
  20746. psn_info, _ := service.GetPsnByPatientId(id)
  20747. var verify_number string
  20748. if psn_info.IdCardType == 4 {
  20749. verify_number = psn_info.VerifyNumber
  20750. } else if psn_info.IdCardType == 1 {
  20751. bas := strings.Split(psn_info.CardInfo, "|")
  20752. cardNumber := bas[2]
  20753. verify_number = cardNumber
  20754. } else {
  20755. verify_number = psn_info.Certno
  20756. psn_info.IdCardType = 2
  20757. }
  20758. var api string
  20759. api = "http://172.16.13.254:9532/" + "nmyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  20760. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  20761. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  20762. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  20763. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(psn_info.IdCardType, 10) +
  20764. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  20765. "&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
  20766. resp, requestErr := http.Get(api)
  20767. if requestErr != nil {
  20768. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20769. return
  20770. }
  20771. body, ioErr := ioutil.ReadAll(resp.Body)
  20772. if ioErr != nil {
  20773. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  20774. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20775. return
  20776. }
  20777. var respJSON map[string]interface{}
  20778. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  20779. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  20780. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20781. return
  20782. }
  20783. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  20784. result, _ := json.Marshal(respJSON)
  20785. fmt.Println("log")
  20786. fmt.Println(string(result))
  20787. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  20788. utils.ErrorLog("解析失败:%v", err)
  20789. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20790. return
  20791. }
  20792. res.InfRefmsgid = resSeven10265.InfRefmsgid
  20793. res.Output = resSeven10265.Output
  20794. res.InfRefmsgid = resSeven10265.InfRefmsgid
  20795. res.ErrMsg = resSeven10265.ErrMsg
  20796. res.Cainfo = resSeven10265.Cainfo
  20797. res.WarnMsg = resSeven10265.WarnMsg
  20798. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  20799. res.Infcode = infocode
  20800. } else if miConfig.MdtrtareaAdmvs == "350500" {
  20801. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  20802. var cert_no string
  20803. if his.IdCardType == 1 {
  20804. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  20805. } else {
  20806. cert_no = psn_info.VerifyNumber
  20807. }
  20808. 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)
  20809. var dat map[string]interface{}
  20810. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  20811. fmt.Println(dat)
  20812. } else {
  20813. fmt.Println(err)
  20814. }
  20815. saveLog(result2, src_resquest, "2207", "结算")
  20816. userJSONBytes, _ := json.Marshal(dat)
  20817. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20818. utils.ErrorLog("解析失败:%v", err)
  20819. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20820. return
  20821. }
  20822. } else if miConfig.MdtrtareaAdmvs == "360302" {
  20823. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  20824. var cert_no string
  20825. var card_sn string
  20826. if his.IdCardType == 1 {
  20827. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  20828. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  20829. bas := strings.Split(psn_info.CardInfo, "|")
  20830. card_sn = bas[3]
  20831. } else if his.IdCardType == 2 {
  20832. cert_no = his.IdCardNo
  20833. } else {
  20834. cert_no = psn_info.VerifyNumber
  20835. }
  20836. var rf []*ResultFive
  20837. json.Unmarshal([]byte(his.Iinfo), &rf)
  20838. var psn_type string
  20839. for _, item := range rf {
  20840. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  20841. psn_type = item.PsnType
  20842. }
  20843. }
  20844. 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)
  20845. var dat map[string]interface{}
  20846. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  20847. fmt.Println(dat)
  20848. } else {
  20849. fmt.Println(err)
  20850. }
  20851. saveLog(result2, src_resquest, "2207", "结算")
  20852. userJSONBytes, _ := json.Marshal(dat)
  20853. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20854. utils.ErrorLog("解析失败:%v", err)
  20855. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20856. return
  20857. }
  20858. } else if miConfig.MdtrtareaAdmvs == "341203" {
  20859. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  20860. if his.IdCardType == 1 {
  20861. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  20862. bas := strings.Split(psn_info.CardInfo, "|")
  20863. cert_no = bas[2]
  20864. } else if his.IdCardType == 3 {
  20865. cert_no = his.Certno
  20866. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  20867. } else if his.IdCardType == 4 {
  20868. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  20869. cert_no = his.Certno
  20870. psn_info.VerifyNumber = psn_info.VerifyNumber
  20871. } else {
  20872. cert_no = his.Certno
  20873. psn_info.VerifyNumber = his.Certno
  20874. }
  20875. var api string
  20876. var med_type string
  20877. if his.Insutype == "390" {
  20878. if reg_type == 992102 {
  20879. med_type = "992102"
  20880. }
  20881. if reg_type == 140104 {
  20882. med_type = "140104"
  20883. }
  20884. if reg_type == 14 {
  20885. med_type = "14"
  20886. }
  20887. } else if his.Insutype == "310" {
  20888. if reg_type == 992102 {
  20889. med_type = "992102"
  20890. }
  20891. if reg_type == 14 {
  20892. med_type = "14"
  20893. }
  20894. }
  20895. api = miConfig.SecretKey + "ahyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  20896. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  20897. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  20898. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  20899. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  20900. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  20901. "&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
  20902. resp, requestErr := http.Get(api)
  20903. if requestErr != nil {
  20904. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20905. return
  20906. }
  20907. body, ioErr := ioutil.ReadAll(resp.Body)
  20908. if ioErr != nil {
  20909. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  20910. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20911. return
  20912. }
  20913. var respJSON map[string]interface{}
  20914. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  20915. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  20916. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20917. return
  20918. }
  20919. status := respJSON["data"].(map[string]interface{})["status"].(string)
  20920. if status == "0" {
  20921. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  20922. c.ServeSuccessJSON(map[string]interface{}{
  20923. "failed_code": -10,
  20924. "msg": err_msg,
  20925. })
  20926. return
  20927. }
  20928. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  20929. result, _ := json.Marshal(respJSON)
  20930. fmt.Println("log")
  20931. fmt.Println(string(result))
  20932. if err := json.Unmarshal(result, &ahres); err != nil {
  20933. utils.ErrorLog("解析失败:%v", err)
  20934. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20935. return
  20936. }
  20937. res.InfRefmsgid = ahres.InfRefmsgid
  20938. timestamp := int64(ahres.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  20939. // 创建对应的Time类型
  20940. t := time.UnixMilli(timestamp)
  20941. // 格式化成指定的日期字符串
  20942. str := t.Format("2006-01-02 15:04:05")
  20943. res.Output.Setlinfo.SetlTime = str
  20944. res.Output.Setlinfo.AcctMulaidPay = ahres.Output.Setlinfo.AcctMulaidPay
  20945. res.Output.Setlinfo.AcctPay = ahres.Output.Setlinfo.AcctPay
  20946. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  20947. res.Output.Setlinfo.ActPayDedc = ahres.Output.Setlinfo.ActPayDedc
  20948. res.Output.Setlinfo.Age = ahres.Output.Setlinfo.Age
  20949. res.Output.Setlinfo.Balc = ahres.Output.Setlinfo.Balc
  20950. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  20951. res.Output.Setlinfo.Certno = ahres.Output.Setlinfo.Certno
  20952. res.Output.Setlinfo.ClrOptins = ahres.Output.Setlinfo.ClrOptins
  20953. res.Output.Setlinfo.ClrType = ahres.Output.Setlinfo.ClrOptins
  20954. res.Output.Setlinfo.ClrWay = ahres.Output.Setlinfo.ClrOptins
  20955. res.Output.Setlinfo.CvlservFlag = ahres.Output.Setlinfo.ClrOptins
  20956. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  20957. res.Output.Setlinfo.FulamtOwnpayAmt = ahres.Output.Setlinfo.FulamtOwnpayAmt
  20958. res.Output.Setlinfo.FundPaySumamt = ahres.Output.Setlinfo.FundPaySumamt
  20959. res.Output.Setlinfo.Gend = ahres.Output.Setlinfo.Gend
  20960. res.Output.Setlinfo.HifesPay = ahres.Output.Setlinfo.HifesPay
  20961. res.Output.Setlinfo.HifmiPay = ahres.Output.Setlinfo.HifmiPay
  20962. res.Output.Setlinfo.HifpPay = ahres.Output.Setlinfo.HifpPay
  20963. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  20964. res.Output.Setlinfo.HospPartAmt = ahres.Output.Setlinfo.HospPartAmt
  20965. res.Output.Setlinfo.InscpScpAmt = ahres.Output.Setlinfo.InscpScpAmt
  20966. res.Output.Setlinfo.Insutype = ahres.Output.Setlinfo.Insutype
  20967. res.Output.Setlinfo.MafPay = ahres.Output.Setlinfo.MafPay
  20968. res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  20969. res.Output.Setlinfo.HifobPay = ahres.Output.Setlinfo.HifobPay
  20970. res.Output.Setlinfo.MdtrtID = ahres.Output.Setlinfo.MdtrtID
  20971. res.Output.Setlinfo.MedType = ahres.Output.Setlinfo.MedType
  20972. res.Output.Setlinfo.MedfeeSumamt = ahres.Output.Setlinfo.MedfeeSumamt
  20973. res.Output.Setlinfo.MedinsSetlID = ahres.Output.Setlinfo.MedinsSetlID
  20974. res.Output.Setlinfo.Naty = ahres.Output.Setlinfo.Naty
  20975. res.Output.Setlinfo.OthPay = ahres.Output.Setlinfo.OthPay
  20976. res.Output.Setlinfo.OverlmtSelfpay = ahres.Output.Setlinfo.OverlmtSelfpay
  20977. res.Output.Setlinfo.PoolPropSelfpay = ahres.Output.Setlinfo.PoolPropSelfpay
  20978. res.Output.Setlinfo.PreselfpayAmt = ahres.Output.Setlinfo.PreselfpayAmt
  20979. res.Output.Setlinfo.PsnCashPay = ahres.Output.Setlinfo.PsnCashPay
  20980. res.Output.Setlinfo.PsnCertType = ahres.Output.Setlinfo.ClrOptins
  20981. res.Output.Setlinfo.ClrType = ahres.Output.Setlinfo.ClrType
  20982. res.Output.Setlinfo.PsnName = ahres.Output.Setlinfo.PsnName
  20983. res.Output.Setlinfo.PsnNo = ahres.Output.Setlinfo.PsnNo
  20984. res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  20985. res.Output.Setlinfo.PsnType = ahres.Output.Setlinfo.PsnType
  20986. res.Output.Setlinfo.SetlID = ahres.Output.Setlinfo.SetlID
  20987. res.Output.Setldetail = ahres.Output.Setldetail
  20988. res.ErrMsg = ahres.ErrMsg
  20989. res.Cainfo = ahres.Cainfo
  20990. res.WarnMsg = ahres.WarnMsg
  20991. res.Infcode = ahres.Infcode
  20992. } else if miConfig.MdtrtareaAdmvs == "430800" {
  20993. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  20994. var cert_no string
  20995. if his.IdCardType == 1 {
  20996. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  20997. } else if his.IdCardType == 2 {
  20998. cert_no = his.IdCardNo
  20999. } else {
  21000. cert_no = psn_info.VerifyNumber
  21001. }
  21002. 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, "")
  21003. var dat map[string]interface{}
  21004. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  21005. fmt.Println(dat)
  21006. } else {
  21007. fmt.Println(err)
  21008. }
  21009. saveLog(result2, src_resquest, "2207", "结算")
  21010. userJSONBytes, _ := json.Marshal(dat)
  21011. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  21012. utils.ErrorLog("解析失败:%v", err)
  21013. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21014. return
  21015. }
  21016. } else if miConfig.MdtrtareaAdmvs == "441799" {
  21017. psn_info, _ := service.GetPsnByPatientId(id)
  21018. var verify_number string
  21019. if psn_info.IdCardType == 4 {
  21020. verify_number = psn_info.VerifyNumber
  21021. } else if psn_info.IdCardType == 1 {
  21022. bas := strings.Split(psn_info.CardInfo, "|")
  21023. cardNumber := bas[2]
  21024. verify_number = cardNumber
  21025. } else {
  21026. verify_number = psn_info.Certno
  21027. psn_info.IdCardType = 2
  21028. }
  21029. var api string
  21030. api = miConfig.Url + "gdyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  21031. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  21032. "&operator=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  21033. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  21034. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(psn_info.IdCardType, 10) +
  21035. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  21036. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + tempOrder.MedType + "&acct_used_flag=" + acct_used_flag + "&verify_number=" + verify_number
  21037. resp, requestErr := http.Get(api)
  21038. if requestErr != nil {
  21039. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21040. return
  21041. }
  21042. body, ioErr := ioutil.ReadAll(resp.Body)
  21043. if ioErr != nil {
  21044. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  21045. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21046. return
  21047. }
  21048. var respJSON map[string]interface{}
  21049. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  21050. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21051. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21052. return
  21053. }
  21054. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  21055. result, _ := json.Marshal(respJSON)
  21056. if err := json.Unmarshal([]byte(result), &res); err != nil {
  21057. utils.ErrorLog("解析失败:%v", err)
  21058. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21059. return
  21060. }
  21061. } else {
  21062. var src_resquest string
  21063. if miConfig.Code == "H15049901371" {
  21064. //赤峰地区国家医保医疗类别
  21065. //职工透析:医疗类别选特殊情况门诊990502
  21066. //居民定额血透门慢: 医疗类别选门诊慢病140104
  21067. var med_type string
  21068. if his.Insutype == "390" {
  21069. if reg_type == 14 {
  21070. med_type = "9933"
  21071. } else if reg_type == 11 {
  21072. med_type = "11"
  21073. }
  21074. } else if his.Insutype == "310" {
  21075. if reg_type == 14 {
  21076. med_type = "990502"
  21077. } else if reg_type == 11 {
  21078. med_type = "11"
  21079. }
  21080. }
  21081. 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)
  21082. } else {
  21083. if his.IdCardType == 4 {
  21084. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  21085. token := psn_info.VerifyNumber
  21086. 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)
  21087. } else {
  21088. 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)
  21089. }
  21090. }
  21091. var dat map[string]interface{}
  21092. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  21093. fmt.Println(dat)
  21094. } else {
  21095. fmt.Println(err)
  21096. }
  21097. saveLog(result2, src_resquest, "2207", "结算")
  21098. userJSONBytes, _ := json.Marshal(dat)
  21099. if miConfig.Code == "H15049901371" {
  21100. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  21101. utils.ErrorLog("解析失败:%v", err)
  21102. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21103. return
  21104. }
  21105. res.InfRefmsgid = resSeven10265.InfRefmsgid
  21106. res.Output = resSeven10265.Output
  21107. res.ErrMsg = resSeven10265.ErrMsg
  21108. res.Cainfo = resSeven10265.Cainfo
  21109. res.WarnMsg = resSeven10265.WarnMsg
  21110. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  21111. res.Infcode = infocode
  21112. } else {
  21113. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  21114. if err := json.Unmarshal(userJSONBytes, &gzresSeven10265Two); err != nil {
  21115. utils.ErrorLog("解析失败:%v", err)
  21116. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21117. return
  21118. }
  21119. res.InfRefmsgid = gzresSeven10265Two.InfRefmsgid
  21120. res.Output.Setlinfo.AcctMulaidPay = gzresSeven10265Two.Output.Setlinfo.AcctMulaidPay
  21121. res.Output.Setlinfo.AcctPay = gzresSeven10265Two.Output.Setlinfo.AcctPay
  21122. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  21123. res.Output.Setlinfo.ActPayDedc = gzresSeven10265Two.Output.Setlinfo.ActPayDedc
  21124. res.Output.Setlinfo.Age = gzresSeven10265Two.Output.Setlinfo.Age
  21125. res.Output.Setlinfo.Balc = gzresSeven10265Two.Output.Setlinfo.Balc
  21126. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  21127. res.Output.Setlinfo.Certno = gzresSeven10265Two.Output.Setlinfo.Certno
  21128. res.Output.Setlinfo.ClrOptins = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  21129. res.Output.Setlinfo.ClrType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  21130. res.Output.Setlinfo.ClrWay = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  21131. res.Output.Setlinfo.CvlservFlag = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  21132. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  21133. res.Output.Setlinfo.FulamtOwnpayAmt = gzresSeven10265Two.Output.Setlinfo.FulamtOwnpayAmt
  21134. res.Output.Setlinfo.FundPaySumamt = gzresSeven10265Two.Output.Setlinfo.FundPaySumamt
  21135. res.Output.Setlinfo.Gend = gzresSeven10265Two.Output.Setlinfo.Gend
  21136. res.Output.Setlinfo.HifesPay = gzresSeven10265Two.Output.Setlinfo.HifesPay
  21137. res.Output.Setlinfo.HifmiPay = gzresSeven10265Two.Output.Setlinfo.HifmiPay
  21138. res.Output.Setlinfo.HifpPay = gzresSeven10265Two.Output.Setlinfo.HifpPay
  21139. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  21140. res.Output.Setlinfo.HospPartAmt = gzresSeven10265Two.Output.Setlinfo.HospPartAmt
  21141. res.Output.Setlinfo.InscpScpAmt = gzresSeven10265Two.Output.Setlinfo.InscpScpAmt
  21142. res.Output.Setlinfo.Insutype = gzresSeven10265Two.Output.Setlinfo.Insutype
  21143. res.Output.Setlinfo.MafPay = gzresSeven10265Two.Output.Setlinfo.MafPay
  21144. res.Output.Setlinfo.MdtrtCertType = gzresSeven10265Two.Output.Setlinfo.MdtrtCertType
  21145. res.Output.Setlinfo.HifobPay = gzresSeven10265Two.Output.Setlinfo.HifobPay
  21146. res.Output.Setlinfo.MdtrtID = gzresSeven10265Two.Output.Setlinfo.MdtrtID
  21147. res.Output.Setlinfo.MedType = gzresSeven10265Two.Output.Setlinfo.MedType
  21148. res.Output.Setlinfo.MedfeeSumamt = gzresSeven10265Two.Output.Setlinfo.MedfeeSumamt
  21149. res.Output.Setlinfo.MedinsSetlID = gzresSeven10265Two.Output.Setlinfo.MedinsSetlID
  21150. res.Output.Setlinfo.Naty = gzresSeven10265Two.Output.Setlinfo.Naty
  21151. res.Output.Setlinfo.OthPay = gzresSeven10265Two.Output.Setlinfo.OthPay
  21152. res.Output.Setlinfo.OverlmtSelfpay = gzresSeven10265Two.Output.Setlinfo.OverlmtSelfpay
  21153. PoolPropSelfpay, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.PoolPropSelfpay, 64)
  21154. res.Output.Setlinfo.PoolPropSelfpay = PoolPropSelfpay
  21155. res.Output.Setlinfo.PreselfpayAmt = gzresSeven10265Two.Output.Setlinfo.PreselfpayAmt
  21156. res.Output.Setlinfo.PsnCashPay = gzresSeven10265Two.Output.Setlinfo.PsnCashPay
  21157. res.Output.Setlinfo.PsnCertType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  21158. res.Output.Setlinfo.PsnName = gzresSeven10265Two.Output.Setlinfo.PsnName
  21159. res.Output.Setlinfo.PsnNo = gzresSeven10265Two.Output.Setlinfo.PsnNo
  21160. res.Output.Setlinfo.PsnPartAmt = gzresSeven10265Two.Output.Setlinfo.PsnPartAmt
  21161. res.Output.Setlinfo.PsnType = gzresSeven10265Two.Output.Setlinfo.PsnType
  21162. res.Output.Setlinfo.SetlID = gzresSeven10265Two.Output.Setlinfo.SetlID
  21163. res.Output.Setlinfo.SetlTime = gzresSeven10265Two.Output.Setlinfo.SetlTime
  21164. //res.Output.Setldetail = gzresSeven10265Two.Output.Setldetail
  21165. res.ErrMsg = gzresSeven10265Two.ErrMsg
  21166. res.Cainfo = gzresSeven10265Two.Cainfo
  21167. res.WarnMsg = gzresSeven10265Two.WarnMsg
  21168. //infocode, _ := strconv.ParseInt(resSeven10265Two.Infcode, 10, 64)
  21169. //res.Infcode = infocode
  21170. } else {
  21171. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  21172. utils.ErrorLog("解析失败:%v", err)
  21173. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21174. return
  21175. }
  21176. }
  21177. }
  21178. }
  21179. if res.Infcode != 0 {
  21180. errlog := &models.HisOrderError{
  21181. UserOrgId: adminUser.CurrentOrgId,
  21182. Ctime: time.Now().Unix(),
  21183. Mtime: time.Now().Unix(),
  21184. Number: chrg_bchno,
  21185. ErrMsg: res.ErrMsg,
  21186. Status: 1,
  21187. PatientId: id,
  21188. RecordTime: recordDateTime,
  21189. Stage: 6,
  21190. }
  21191. service.CreateErrMsgLog(errlog)
  21192. c.ServeSuccessJSON(map[string]interface{}{
  21193. "failed_code": -10,
  21194. "msg": res.ErrMsg,
  21195. })
  21196. return
  21197. } else {
  21198. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  21199. order.OrderStatus = 2
  21200. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  21201. order.SetlId = res.Output.Setlinfo.SetlID
  21202. order.PsnNo = res.Output.Setlinfo.PsnNo
  21203. order.PsnName = res.Output.Setlinfo.PsnName
  21204. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  21205. order.Certno = res.Output.Setlinfo.Certno
  21206. order.Gend = res.Output.Setlinfo.Gend
  21207. order.Naty = res.Output.Setlinfo.Naty
  21208. order.Age = res.Output.Setlinfo.Age
  21209. order.Insutype = res.Output.Setlinfo.Insutype
  21210. order.PsnType = res.Output.Setlinfo.PsnType
  21211. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  21212. order.SetlTime = res.Output.Setlinfo.SetlTime
  21213. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  21214. order.PayWays = pay_ways
  21215. order.AcctUsedFlag = acct_used_flag
  21216. order.WechatPay = wechat_pay
  21217. order.AliPay = ali_pay
  21218. order.JifenPay = jifen_pay
  21219. order.BandCardPay = band_card_pay
  21220. order.CashPay = cash_pay
  21221. order.OthDesc = oth_desc
  21222. //order.MedType = res.Output.Setlinfo.MedType
  21223. if reg_type == 1112 {
  21224. order.MedType = "1112"
  21225. }
  21226. if reg_type == 1111 {
  21227. order.MedType = "1111"
  21228. }
  21229. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  21230. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  21231. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  21232. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  21233. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  21234. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  21235. order.HifpPay = res.Output.Setlinfo.HifpPay
  21236. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  21237. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  21238. order.HifesPay = res.Output.Setlinfo.HifesPay
  21239. order.HifobPay = res.Output.Setlinfo.HifobPay
  21240. order.MafPay = res.Output.Setlinfo.MafPay
  21241. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  21242. order.OthPay = res.Output.Setlinfo.OthPay
  21243. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  21244. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  21245. order.AcctPay = res.Output.Setlinfo.AcctPay
  21246. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  21247. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  21248. order.Balc = res.Output.Setlinfo.Balc
  21249. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  21250. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  21251. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  21252. order.ClrWay = res.Output.Setlinfo.ClrWay
  21253. order.Creator = order.Creator
  21254. order.ClrType = res.Output.Setlinfo.ClrType
  21255. order.Modify = roles.AdminUserId
  21256. order.RequestLog = src_resquest
  21257. order.Diagnosis = diagnosis_id
  21258. order.FaPiaoNumber = fapiao_number
  21259. order.FaPiaoCode = fapiao_code
  21260. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  21261. detailStr := string(setlDetail)
  21262. order.SetlDetail = detailStr
  21263. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  21264. err = service.UpDateOrder(order)
  21265. if err == nil {
  21266. //判断是否使用了押金
  21267. if dec_way == "true" {
  21268. tmpstring := strconv.FormatInt(order.ID, 10)
  21269. //扣押金
  21270. order.Decimal = decimal
  21271. service.UpDateOrder(order)
  21272. errmsg = service.SpendDeposit(c.GetAdminUserInfo().CurrentOrgId, id, c.GetAdminUserInfo().AdminUser.Id, tmpstring, decimal)
  21273. if errmsg != nil {
  21274. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, errmsg.Error())
  21275. return
  21276. }
  21277. }
  21278. c.ServeSuccessJSON(map[string]interface{}{
  21279. "msg": "结算成功",
  21280. })
  21281. } else {
  21282. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  21283. return
  21284. }
  21285. }
  21286. }
  21287. }
  21288. }
  21289. // 上传明细-预结算-
  21290. func (c *HisApiController) GetPreUploadInfo() {
  21291. id, _ := c.GetInt64("id")
  21292. record_time := c.GetString("record_time")
  21293. his_patient_id, _ := c.GetInt64("his_patient_id")
  21294. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  21295. admin_user_id, _ := c.GetInt64("admin_user_id")
  21296. diagnosis_id := c.GetString("diagnosis")
  21297. sick_type, _ := c.GetInt64("sick_type")
  21298. reg_type, _ := c.GetInt64("p_type")
  21299. begin_time := c.GetString("begin_time")
  21300. acct_used_flag := c.GetString("acct_used_flag")
  21301. id_str := c.GetString("ids")
  21302. ids_arr := strings.Split(id_str, ",")
  21303. timeLayout := "2006-01-02"
  21304. loc, _ := time.LoadLocation("Local")
  21305. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  21306. if err != nil {
  21307. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  21308. return
  21309. }
  21310. recordDateTime := theTime.Unix()
  21311. adminUser := c.GetAdminUserInfo()
  21312. diagnosis_ids := strings.Split(diagnosis_id, ",")
  21313. var config []*models.HisXtDiagnoseConfig
  21314. for _, item := range diagnosis_ids {
  21315. id, _ := strconv.ParseInt(item, 10, 64)
  21316. diagnosisConfig, _ := service.FindDiagnoseById(id)
  21317. config = append(config, &diagnosisConfig)
  21318. }
  21319. //diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  21320. sickConfig, _ := service.FindSickById(sick_type)
  21321. var prescriptions []*models.HisPrescription
  21322. var start_time int64
  21323. var end_time int64
  21324. var isSuccess bool = true
  21325. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  21326. fmt.Println(his_patient_id)
  21327. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  21328. timestamp := time.Now().Unix()
  21329. tempTime := time.Unix(timestamp, 0)
  21330. timeFormat := tempTime.Format("20060102150405")
  21331. chrgBchno := rand.Intn(100000) + 10000
  21332. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10)
  21333. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  21334. var patientPrescription models.HisPrescriptionInfo
  21335. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  21336. if patientPrescription.ID == 0 {
  21337. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  21338. }
  21339. //miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  21340. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  21341. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  21342. strconv.FormatInt(his.PatientId, 10)
  21343. var res2406 Result2406
  21344. //安徽单病种处理
  21345. if miConfig.MdtrtareaAdmvs == "341203" && reg_type == 992102 {
  21346. data := make(map[string]interface{})
  21347. client := &http.Client{}
  21348. data["psn_no"] = his.PsnNo
  21349. data["mdtrt_id"] = his.Number
  21350. data["operator"] = roles.UserName
  21351. data["cert_no"] = his.IdCardNo
  21352. data["org_name"] = miConfig.OrgName
  21353. data["psn_name"] = his.Name
  21354. data["ipt_otp_no"] = his.IptOtpNo
  21355. data["ipt_psn_sp_flag_type"] = "0901"
  21356. data["ipt_psn_sp_flag"] = "1"
  21357. data["fixmedins_code"] = miConfig.Code
  21358. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  21359. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  21360. data["url"] = miConfig.Url
  21361. utils.ErrorLog("接口返回数据解析JSON失败: %v", data)
  21362. bytesData, _ := json.Marshal(data)
  21363. var req *http.Request
  21364. utils.ErrorLog("接口返回数据解析JSON失败: %v", miConfig.SecretKey)
  21365. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2406", bytes.NewReader(bytesData))
  21366. resp, _ := client.Do(req)
  21367. defer resp.Body.Close()
  21368. body, ioErr := ioutil.ReadAll(resp.Body)
  21369. if ioErr != nil {
  21370. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  21371. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21372. return
  21373. }
  21374. var respJSON map[string]interface{}
  21375. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  21376. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21377. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21378. return
  21379. }
  21380. status := respJSON["data"].(map[string]interface{})["status"].(string)
  21381. if status == "0" {
  21382. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  21383. c.ServeSuccessJSON(map[string]interface{}{
  21384. "failed_code": -10,
  21385. "msg": err_msg,
  21386. })
  21387. return
  21388. }
  21389. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  21390. userJSONBytes, _ := json.Marshal(respJSON)
  21391. fmt.Println("log")
  21392. fmt.Println(string(userJSONBytes))
  21393. if err := json.Unmarshal(userJSONBytes, &res2406); err != nil {
  21394. utils.ErrorLog("解析失败:%v", err)
  21395. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21396. return
  21397. }
  21398. }
  21399. if res2406.Infcode != 0 {
  21400. adminUser := c.GetAdminUserInfo()
  21401. errlog := &models.HisOrderError{
  21402. UserOrgId: adminUser.CurrentOrgId,
  21403. Ctime: time.Now().Unix(),
  21404. Mtime: time.Now().Unix(),
  21405. ErrMsg: res2406.ErrMsg,
  21406. Status: 1,
  21407. PatientId: id,
  21408. RecordTime: recordDateTime,
  21409. Stage: 3,
  21410. }
  21411. service.CreateErrMsgLog(errlog)
  21412. c.ServeSuccessJSON(map[string]interface{}{
  21413. "failed_code": -10,
  21414. "msg": res2406.ErrMsg,
  21415. })
  21416. return
  21417. }
  21418. var res2 ResultSix
  21419. var res3 GZResultSix
  21420. var resSix10265 ResultSix10265
  21421. //var time_stamp string
  21422. if miConfig.MdtrtareaAdmvs == "421300" {
  21423. data := make(map[string]interface{})
  21424. client := &http.Client{}
  21425. data["psn_no"] = his.PsnNo
  21426. data["mdtrt_id"] = his.Number
  21427. data["department"] = department.Name
  21428. data["org_name"] = miConfig.OrgName
  21429. data["med_type"] = strconv.FormatInt(reg_type, 10)
  21430. data["doctor_id"] = doctor_info.DoctorNumber
  21431. data["doctor_name"] = roles.UserName
  21432. data["fixmedins_code"] = miConfig.Code
  21433. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  21434. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  21435. data["secret_key"] = miConfig.SecretKey
  21436. data["sick_code"] = sickConfig.CountryCode
  21437. data["sick_name"] = sickConfig.ClassName
  21438. data["begin_time"] = begin_time
  21439. data["dept"] = strconv.FormatInt(department.ID, 10)
  21440. data["config"] = config
  21441. data["opter"] = roles.UserName
  21442. fmt.Println(data)
  21443. bytesData, _ := json.Marshal(data)
  21444. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  21445. resp, _ := client.Do(req)
  21446. defer resp.Body.Close()
  21447. body, ioErr := ioutil.ReadAll(resp.Body)
  21448. if ioErr != nil {
  21449. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  21450. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21451. return
  21452. }
  21453. var respJSON map[string]interface{}
  21454. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  21455. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21456. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21457. return
  21458. }
  21459. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  21460. userJSONBytes, _ := json.Marshal(respJSON)
  21461. fmt.Println("log")
  21462. fmt.Println(string(userJSONBytes))
  21463. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  21464. utils.ErrorLog("解析失败:%v", err)
  21465. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21466. return
  21467. }
  21468. } else if miConfig.MdtrtareaAdmvs == "420200" {
  21469. data := make(map[string]interface{})
  21470. client := &http.Client{}
  21471. data["psn_no"] = his.PsnNo
  21472. data["mdtrt_id"] = his.Number
  21473. data["department"] = department.Name
  21474. data["org_name"] = miConfig.OrgName
  21475. if reg_type == 11 && his.Insutype == "390" {
  21476. data["med_type"] = "110104"
  21477. } else {
  21478. data["med_type"] = strconv.FormatInt(reg_type, 10)
  21479. }
  21480. data["doctor_id"] = doctor_info.DoctorNumber
  21481. data["doctor_name"] = roles.UserName
  21482. data["fixmedins_code"] = miConfig.Code
  21483. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  21484. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  21485. data["secret_key"] = miConfig.SecretKey
  21486. data["sick_code"] = sickConfig.CountryCode
  21487. data["sick_name"] = sickConfig.ClassName
  21488. data["begin_time"] = begin_time
  21489. data["dept"] = strconv.FormatInt(department.ID, 10)
  21490. data["config"] = config
  21491. data["opter"] = roles.UserName
  21492. fmt.Println(data)
  21493. bytesData, _ := json.Marshal(data)
  21494. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  21495. resp, _ := client.Do(req)
  21496. defer resp.Body.Close()
  21497. body, ioErr := ioutil.ReadAll(resp.Body)
  21498. if ioErr != nil {
  21499. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  21500. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21501. return
  21502. }
  21503. var respJSON map[string]interface{}
  21504. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  21505. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21506. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21507. return
  21508. }
  21509. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  21510. userJSONBytes, _ := json.Marshal(respJSON)
  21511. fmt.Println("log")
  21512. fmt.Println(string(userJSONBytes))
  21513. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  21514. utils.ErrorLog("解析失败:%v", err)
  21515. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21516. return
  21517. }
  21518. } else if miConfig.MdtrtareaAdmvs == "420902" {
  21519. data := make(map[string]interface{})
  21520. client := &http.Client{}
  21521. data["psn_no"] = his.PsnNo
  21522. data["mdtrt_id"] = his.Number
  21523. data["department"] = department.Name
  21524. data["org_name"] = miConfig.OrgName
  21525. if reg_type == 11 && his.Insutype == "390" {
  21526. data["med_type"] = "110104"
  21527. } else {
  21528. data["med_type"] = strconv.FormatInt(reg_type, 10)
  21529. }
  21530. data["doctor_id"] = doctor_info.DoctorNumber
  21531. data["doctor_name"] = roles.UserName
  21532. data["fixmedins_code"] = miConfig.Code
  21533. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  21534. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  21535. data["secret_key"] = miConfig.SecretKey
  21536. data["sick_code"] = sickConfig.CountryCode
  21537. data["sick_name"] = sickConfig.ClassName
  21538. data["begin_time"] = begin_time
  21539. data["dept"] = strconv.FormatInt(department.ID, 10)
  21540. data["config"] = config
  21541. data["opter"] = roles.UserName
  21542. fmt.Println(data)
  21543. bytesData, _ := json.Marshal(data)
  21544. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2203", bytes.NewReader(bytesData))
  21545. resp, _ := client.Do(req)
  21546. defer resp.Body.Close()
  21547. body, ioErr := ioutil.ReadAll(resp.Body)
  21548. if ioErr != nil {
  21549. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  21550. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21551. return
  21552. }
  21553. var respJSON map[string]interface{}
  21554. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  21555. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21556. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21557. return
  21558. }
  21559. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  21560. userJSONBytes, _ := json.Marshal(respJSON)
  21561. fmt.Println("log")
  21562. fmt.Println(string(userJSONBytes))
  21563. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  21564. utils.ErrorLog("解析失败:%v", err)
  21565. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21566. return
  21567. }
  21568. } else if miConfig.MdtrtareaAdmvs == "421182" {
  21569. data := make(map[string]interface{})
  21570. client := &http.Client{}
  21571. data["psn_no"] = his.PsnNo
  21572. data["mdtrt_id"] = his.Number
  21573. data["department"] = department.Name
  21574. data["org_name"] = miConfig.OrgName
  21575. if reg_type == 11 && his.Insutype == "390" {
  21576. data["med_type"] = "110104"
  21577. } else {
  21578. data["med_type"] = strconv.FormatInt(reg_type, 10)
  21579. }
  21580. data["doctor_id"] = doctor_info.DoctorNumber
  21581. data["doctor_name"] = roles.UserName
  21582. data["fixmedins_code"] = miConfig.Code
  21583. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  21584. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  21585. data["secret_key"] = miConfig.SecretKey
  21586. data["sick_code"] = sickConfig.CountryCode
  21587. data["sick_name"] = sickConfig.ClassName
  21588. data["begin_time"] = begin_time
  21589. data["dept"] = strconv.FormatInt(department.ID, 10)
  21590. data["config"] = config
  21591. data["opter"] = roles.UserName
  21592. fmt.Println(data)
  21593. bytesData, _ := json.Marshal(data)
  21594. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2203", bytes.NewReader(bytesData))
  21595. resp, _ := client.Do(req)
  21596. defer resp.Body.Close()
  21597. body, ioErr := ioutil.ReadAll(resp.Body)
  21598. if ioErr != nil {
  21599. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  21600. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21601. return
  21602. }
  21603. var respJSON map[string]interface{}
  21604. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  21605. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21606. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21607. return
  21608. }
  21609. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  21610. userJSONBytes, _ := json.Marshal(respJSON)
  21611. fmt.Println("log")
  21612. fmt.Println(string(userJSONBytes))
  21613. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  21614. utils.ErrorLog("解析失败:%v", err)
  21615. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21616. return
  21617. }
  21618. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  21619. data := make(map[string]interface{})
  21620. client := &http.Client{}
  21621. data["psn_no"] = his.PsnNo
  21622. data["mdtrt_id"] = his.Number
  21623. data["doctor"] = roles.UserName
  21624. data["department"] = department.Name
  21625. data["org_name"] = miConfig.OrgName
  21626. data["med_type"] = strconv.FormatInt(reg_type, 10)
  21627. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  21628. data["fixmedins_code"] = miConfig.Code
  21629. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  21630. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  21631. data["secret_key"] = miConfig.SecretKey
  21632. data["sick_code"] = sickConfig.CountryCode
  21633. data["sick_name"] = sickConfig.ClassName
  21634. data["begin_time"] = begin_time
  21635. data["dept"] = strconv.FormatInt(department.ID, 10)
  21636. data["config"] = config
  21637. data["url"] = miConfig.Url
  21638. data["ak"] = miConfig.AccessKey
  21639. data["cainfo"] = miConfig.Cainfo
  21640. bytesData, _ := json.Marshal(data)
  21641. var req *http.Request
  21642. if miConfig.MdtrtareaAdmvs == "320921" {
  21643. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  21644. } else {
  21645. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  21646. }
  21647. resp, _ := client.Do(req)
  21648. defer resp.Body.Close()
  21649. body, ioErr := ioutil.ReadAll(resp.Body)
  21650. if ioErr != nil {
  21651. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  21652. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21653. return
  21654. }
  21655. var respJSON map[string]interface{}
  21656. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  21657. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21658. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21659. return
  21660. }
  21661. //time_stamp := strconv.FormatInt(int64(respJSON["data"].(map[string]interface{})["time_stamp"].(float64)), 10)
  21662. //fmt.Println(respJSON["data"].(map[string]interface{})["time_stamp"].(string))
  21663. //time_stamp = respJSON["data"].(map[string]interface{})["time_stamp"].(string)
  21664. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  21665. userJSONBytes, _ := json.Marshal(respJSON)
  21666. fmt.Println("log")
  21667. fmt.Println(string(userJSONBytes))
  21668. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  21669. utils.ErrorLog("解析失败:%v", err)
  21670. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21671. return
  21672. }
  21673. res2.InfRefmsgid = resSix10265.InfRefmsgid
  21674. res2.Output = resSix10265.Output
  21675. res2.ErrMsg = resSix10265.ErrMsg
  21676. res2.Cainfo = resSix10265.Cainfo
  21677. res2.WarnMsg = resSix10265.WarnMsg
  21678. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  21679. res2.Infcode = infocode
  21680. } else if miConfig.MdtrtareaAdmvs == "150499" {
  21681. data := make(map[string]interface{})
  21682. client := &http.Client{}
  21683. data["psn_no"] = his.PsnNo
  21684. data["mdtrt_id"] = his.Number
  21685. data["doctor"] = roles.UserName
  21686. data["department"] = department.Name
  21687. data["org_name"] = miConfig.OrgName
  21688. data["med_type"] = strconv.FormatInt(reg_type, 10)
  21689. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  21690. data["fixmedins_code"] = miConfig.Code
  21691. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  21692. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  21693. data["secret_key"] = miConfig.SecretKey
  21694. data["sick_code"] = sickConfig.CountryCode
  21695. data["sick_name"] = sickConfig.ClassName
  21696. data["begin_time"] = begin_time
  21697. data["dept"] = strconv.FormatInt(department.ID, 10)
  21698. data["config"] = config
  21699. //data["url"] = miConfig.Url
  21700. //data["ak"] = miConfig.AccessKey
  21701. data["cainfo"] = miConfig.Cainfo
  21702. fmt.Println(data)
  21703. bytesData, _ := json.Marshal(data)
  21704. var req *http.Request
  21705. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2203", bytes.NewReader(bytesData))
  21706. resp, _ := client.Do(req)
  21707. defer resp.Body.Close()
  21708. body, ioErr := ioutil.ReadAll(resp.Body)
  21709. if ioErr != nil {
  21710. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  21711. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21712. return
  21713. }
  21714. var respJSON map[string]interface{}
  21715. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  21716. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21717. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21718. return
  21719. }
  21720. //time_stamp := strconv.FormatInt(int64(respJSON["data"].(map[string]interface{})["time_stamp"].(float64)), 10)
  21721. //fmt.Println(respJSON["data"].(map[string]interface{})["time_stamp"].(string))
  21722. //time_stamp = respJSON["data"].(map[string]interface{})["time_stamp"].(string)
  21723. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  21724. userJSONBytes, _ := json.Marshal(respJSON)
  21725. fmt.Println("log")
  21726. fmt.Println(string(userJSONBytes))
  21727. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  21728. utils.ErrorLog("解析失败:%v", err)
  21729. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21730. return
  21731. }
  21732. res2.InfRefmsgid = resSix10265.InfRefmsgid
  21733. res2.Output = resSix10265.Output
  21734. res2.ErrMsg = resSix10265.ErrMsg
  21735. res2.Cainfo = resSix10265.Cainfo
  21736. res2.WarnMsg = resSix10265.WarnMsg
  21737. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  21738. res2.Infcode = infocode
  21739. } else if miConfig.MdtrtareaAdmvs == "350500" {
  21740. 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)
  21741. saveLog(result, requestLog, "2203", "上传就诊信息")
  21742. var respJSON2 map[string]interface{}
  21743. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  21744. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21745. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21746. return
  21747. }
  21748. userJSONBytes2, _ := json.Marshal(respJSON2)
  21749. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  21750. utils.ErrorLog("解析失败:%v", err)
  21751. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21752. return
  21753. }
  21754. } else if miConfig.MdtrtareaAdmvs == "360302" {
  21755. var result string
  21756. var requestLog string
  21757. 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, "")
  21758. saveLog(result, requestLog, "2203", "上传就诊信息")
  21759. var respJSON2 map[string]interface{}
  21760. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  21761. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21762. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21763. return
  21764. }
  21765. userJSONBytes2, _ := json.Marshal(respJSON2)
  21766. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  21767. utils.ErrorLog("解析失败:%v", err)
  21768. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21769. return
  21770. }
  21771. } else if miConfig.MdtrtareaAdmvs == "341203" {
  21772. data := make(map[string]interface{})
  21773. client := &http.Client{}
  21774. data["psn_no"] = his.PsnNo
  21775. data["mdtrt_id"] = his.Number
  21776. data["operator"] = roles.UserName
  21777. data["department"] = department.Name
  21778. data["org_name"] = miConfig.OrgName
  21779. var med_type string
  21780. if his.Insutype == "390" {
  21781. if reg_type == 992102 {
  21782. med_type = "992102"
  21783. data["sick_code"] = "ZDZ940"
  21784. data["sick_name"] = "慢性肾衰竭"
  21785. }
  21786. if reg_type == 140104 {
  21787. med_type = "140104"
  21788. data["sick_code"] = sickConfig.CountryCode
  21789. data["sick_name"] = sickConfig.ClassName
  21790. }
  21791. if reg_type == 14 {
  21792. med_type = "140104"
  21793. data["sick_code"] = sickConfig.CountryCode
  21794. data["sick_name"] = sickConfig.ClassName
  21795. }
  21796. } else if his.Insutype == "310" {
  21797. if reg_type == 992102 {
  21798. med_type = "992102"
  21799. data["sick_code"] = "ZDZ940"
  21800. data["sick_name"] = "慢性肾衰竭"
  21801. }
  21802. if reg_type == 140104 {
  21803. med_type = "140104"
  21804. data["sick_code"] = sickConfig.CountryCode
  21805. data["sick_name"] = sickConfig.ClassName
  21806. }
  21807. if reg_type == 14 {
  21808. med_type = "14"
  21809. data["sick_code"] = sickConfig.CountryCode
  21810. data["sick_name"] = sickConfig.ClassName
  21811. }
  21812. }
  21813. data["med_type"] = med_type
  21814. data["doctor_number"] = doctor_info.DoctorNumber
  21815. data["doctor_name"] = doctor_info.UserName
  21816. data["fixmedins_code"] = miConfig.Code
  21817. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  21818. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  21819. data["secret_key"] = miConfig.SecretKey
  21820. data["begin_time"] = begin_time
  21821. data["dept"] = strconv.FormatInt(department.ID, 10)
  21822. data["config"] = config
  21823. data["url"] = miConfig.Url
  21824. data["ak"] = miConfig.AccessKey
  21825. data["cainfo"] = miConfig.Cainfo
  21826. bytesData, _ := json.Marshal(data)
  21827. var req *http.Request
  21828. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2203", bytes.NewReader(bytesData))
  21829. resp, _ := client.Do(req)
  21830. defer resp.Body.Close()
  21831. body, ioErr := ioutil.ReadAll(resp.Body)
  21832. if ioErr != nil {
  21833. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  21834. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21835. return
  21836. }
  21837. var respJSON map[string]interface{}
  21838. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  21839. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21840. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21841. return
  21842. }
  21843. status := respJSON["data"].(map[string]interface{})["status"].(string)
  21844. if status == "0" {
  21845. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  21846. c.ServeSuccessJSON(map[string]interface{}{
  21847. "failed_code": -10,
  21848. "msg": err_msg,
  21849. })
  21850. return
  21851. }
  21852. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  21853. userJSONBytes, _ := json.Marshal(respJSON)
  21854. fmt.Println("log")
  21855. fmt.Println(string(userJSONBytes))
  21856. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  21857. utils.ErrorLog("解析失败:%v", err)
  21858. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21859. return
  21860. }
  21861. } else if miConfig.MdtrtareaAdmvs == "430800" {
  21862. var result string
  21863. var requestLog string
  21864. 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, "")
  21865. saveLog(result, requestLog, "2203", "上传就诊信息")
  21866. var respJSON2 map[string]interface{}
  21867. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  21868. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21869. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21870. return
  21871. }
  21872. userJSONBytes2, _ := json.Marshal(respJSON2)
  21873. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  21874. utils.ErrorLog("解析失败:%v", err)
  21875. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21876. return
  21877. }
  21878. } else if miConfig.MdtrtareaAdmvs == "441799" {
  21879. data := make(map[string]interface{})
  21880. client := &http.Client{}
  21881. data["psn_no"] = his.PsnNo
  21882. data["mdtrt_id"] = his.Number
  21883. data["doctor"] = roles.UserName
  21884. data["department"] = department.Name
  21885. data["org_name"] = miConfig.OrgName
  21886. data["med_type"] = strconv.FormatInt(reg_type, 10)
  21887. data["doctor_id"] = doctor_info.DoctorNumber
  21888. data["fixmedins_code"] = miConfig.Code
  21889. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  21890. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  21891. data["secret_key"] = miConfig.SecretKey
  21892. data["sick_code"] = sickConfig.CountryCode
  21893. data["sick_name"] = sickConfig.ClassName
  21894. data["begin_time"] = begin_time
  21895. data["new_doctor_name"] = doctor_info.UserName
  21896. data["dept"] = strconv.FormatInt(department.ID, 10)
  21897. data["config"] = config
  21898. bytesData, _ := json.Marshal(data)
  21899. var req *http.Request
  21900. req, _ = http.NewRequest("POST", miConfig.Url+"gdyb/2203", bytes.NewReader(bytesData))
  21901. resp, _ := client.Do(req)
  21902. defer resp.Body.Close()
  21903. body, ioErr := ioutil.ReadAll(resp.Body)
  21904. if ioErr != nil {
  21905. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  21906. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21907. return
  21908. }
  21909. var respJSON map[string]interface{}
  21910. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  21911. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21912. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21913. return
  21914. }
  21915. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  21916. userJSONBytes, _ := json.Marshal(respJSON)
  21917. fmt.Println("log")
  21918. fmt.Println(string(userJSONBytes))
  21919. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  21920. utils.ErrorLog("解析失败:%v", err)
  21921. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21922. return
  21923. }
  21924. } else {
  21925. var result string
  21926. var requestLog string
  21927. if miConfig.MdtrtareaAdmvs == "440781" { //
  21928. 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)
  21929. } else {
  21930. if miConfig.Code == "H15049901371" {
  21931. //赤峰地区国家医保医疗类别
  21932. //职工透析:医疗类别选特殊情况门诊990502
  21933. //居民定额血透门慢: 医疗类别选门诊慢病140104
  21934. var med_type string
  21935. if his.Insutype == "390" {
  21936. if reg_type == 14 {
  21937. med_type = "9933"
  21938. } else if reg_type == 11 {
  21939. med_type = "11"
  21940. }
  21941. } else if his.Insutype == "310" {
  21942. if reg_type == 14 {
  21943. med_type = "990502"
  21944. } else if reg_type == 11 {
  21945. med_type = "11"
  21946. }
  21947. }
  21948. 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)
  21949. } else {
  21950. 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)
  21951. }
  21952. saveLog(result, requestLog, "2203", "上传就诊信息")
  21953. var respJSON2 map[string]interface{}
  21954. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  21955. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21956. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21957. return
  21958. }
  21959. userJSONBytes2, _ := json.Marshal(respJSON2)
  21960. if miConfig.Code == "H15049901371" {
  21961. if err := json.Unmarshal(userJSONBytes2, &resSix10265); err != nil {
  21962. utils.ErrorLog("解析失败:%v", err)
  21963. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21964. return
  21965. }
  21966. res2.InfRefmsgid = resSix10265.InfRefmsgid
  21967. res2.Output = resSix10265.Output
  21968. res2.ErrMsg = resSix10265.ErrMsg
  21969. res2.Cainfo = resSix10265.Cainfo
  21970. res2.WarnMsg = resSix10265.WarnMsg
  21971. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  21972. res2.Infcode = infocode
  21973. } else {
  21974. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  21975. if err := json.Unmarshal(userJSONBytes2, &res3); err != nil {
  21976. utils.ErrorLog("解析失败:%v", err)
  21977. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21978. return
  21979. }
  21980. res2.Infcode = res3.Infcode
  21981. } else {
  21982. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  21983. utils.ErrorLog("解析失败:%v", err)
  21984. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21985. return
  21986. }
  21987. }
  21988. }
  21989. }
  21990. }
  21991. if res2.Infcode == -1 {
  21992. adminUser := c.GetAdminUserInfo()
  21993. errlog := &models.HisOrderError{
  21994. UserOrgId: adminUser.CurrentOrgId,
  21995. Ctime: time.Now().Unix(),
  21996. Mtime: time.Now().Unix(),
  21997. ErrMsg: res2.ErrMsg,
  21998. Status: 1,
  21999. PatientId: id,
  22000. RecordTime: recordDateTime,
  22001. Stage: 3,
  22002. }
  22003. service.CreateErrMsgLog(errlog)
  22004. c.ServeSuccessJSON(map[string]interface{}{
  22005. "failed_code": -10,
  22006. "msg": res2.ErrMsg,
  22007. })
  22008. return
  22009. }
  22010. if res2.Infcode != 0 {
  22011. adminUser := c.GetAdminUserInfo()
  22012. errlog := &models.HisOrderError{
  22013. UserOrgId: adminUser.CurrentOrgId,
  22014. Ctime: time.Now().Unix(),
  22015. Mtime: time.Now().Unix(),
  22016. ErrMsg: res2.ErrMsg,
  22017. Status: 1,
  22018. PatientId: id,
  22019. RecordTime: recordDateTime,
  22020. Stage: 3,
  22021. }
  22022. service.CreateErrMsgLog(errlog)
  22023. c.ServeSuccessJSON(map[string]interface{}{
  22024. "failed_code": -10,
  22025. "msg": res2.ErrMsg,
  22026. })
  22027. return
  22028. } else {
  22029. his.Diagnosis = diagnosis_id
  22030. his.SickType = sickConfig.ID
  22031. his.PType = fmt.Sprintf("%d", reg_type)
  22032. service.UpdateHisPatientThree(&his)
  22033. data := make(map[string]interface{})
  22034. if settle_accounts_type == 1 { //日结
  22035. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  22036. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  22037. } else {
  22038. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  22039. }
  22040. data["pre"] = prescriptions
  22041. } else { //月结
  22042. start_time_str := c.GetString("start_time")
  22043. end_time_str := c.GetString("end_time")
  22044. timeLayout := "2006-01-02"
  22045. loc, _ := time.LoadLocation("Local")
  22046. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  22047. if err != nil {
  22048. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  22049. return
  22050. }
  22051. recordStartTime := theStartTime.Unix()
  22052. start_time = recordStartTime
  22053. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  22054. if err != nil {
  22055. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  22056. return
  22057. }
  22058. recordEndTime := theEndTime.Unix()
  22059. end_time = recordEndTime
  22060. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  22061. data["pre"] = prescriptions
  22062. }
  22063. client := &http.Client{}
  22064. data["psn_no"] = his.PsnNo
  22065. data["mdtrt_id"] = his.Number
  22066. data["chrg_bchno"] = chrg_bchno
  22067. data["org_name"] = miConfig.OrgName
  22068. data["doctor"] = doctor_info.UserName
  22069. data["doctor_id"] = doctor_info.DoctorNumber
  22070. data["dept"] = department.Name
  22071. data["fixmedins_code"] = miConfig.Code
  22072. data["opter"] = roles.UserName
  22073. data["dept_code"] = department.Number
  22074. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  22075. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  22076. data["secret_key"] = miConfig.SecretKey
  22077. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  22078. data["url"] = miConfig.Url
  22079. data["ak"] = miConfig.AccessKey
  22080. data["new_doctor_name"] = patientPrescription.Doctor
  22081. if his.Insutype == "390" {
  22082. if reg_type == 992102 {
  22083. data["diag_code"] = "ZDZ940"
  22084. }
  22085. if reg_type == 140104 {
  22086. data["diag_code"] = sickConfig.CountryCode
  22087. }
  22088. if reg_type == 14 {
  22089. data["diag_code"] = sickConfig.CountryCode
  22090. }
  22091. } else if his.Insutype == "310" {
  22092. if reg_type == 992102 {
  22093. data["diag_code"] = "ZDZ940"
  22094. }
  22095. if reg_type == 14 {
  22096. data["diag_code"] = sickConfig.CountryCode
  22097. }
  22098. }
  22099. data["cainfo"] = miConfig.Cainfo
  22100. data["opter"] = roles.UserName
  22101. var ids []int64
  22102. for _, item := range prescriptions {
  22103. ids = append(ids, item.ID)
  22104. }
  22105. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  22106. if config.IsOpen == 1 { //对接了医保,走医保流程
  22107. var res ResultFour
  22108. var resFour10265 ResultFour10265
  22109. if miConfig.MdtrtareaAdmvs == "421300" {
  22110. bytesData, _ := json.Marshal(data)
  22111. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  22112. resp, _ := client.Do(req)
  22113. defer resp.Body.Close()
  22114. body, ioErr := ioutil.ReadAll(resp.Body)
  22115. if ioErr != nil {
  22116. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  22117. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22118. return
  22119. }
  22120. var respJSON map[string]interface{}
  22121. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  22122. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22123. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22124. return
  22125. }
  22126. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22127. userJSONBytes, _ := json.Marshal(respJSON)
  22128. fmt.Println("log")
  22129. fmt.Println(string(userJSONBytes))
  22130. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  22131. utils.ErrorLog("解析失败:%v", err)
  22132. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22133. return
  22134. }
  22135. } else if miConfig.MdtrtareaAdmvs == "420200" {
  22136. bytesData, _ := json.Marshal(data)
  22137. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  22138. resp, _ := client.Do(req)
  22139. defer resp.Body.Close()
  22140. body, ioErr := ioutil.ReadAll(resp.Body)
  22141. if ioErr != nil {
  22142. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  22143. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22144. return
  22145. }
  22146. var respJSON map[string]interface{}
  22147. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  22148. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22149. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22150. return
  22151. }
  22152. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22153. userJSONBytes, _ := json.Marshal(respJSON)
  22154. fmt.Println("log")
  22155. fmt.Println(string(userJSONBytes))
  22156. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  22157. utils.ErrorLog("解析失败:%v", err)
  22158. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22159. return
  22160. }
  22161. } else if miConfig.MdtrtareaAdmvs == "420902" {
  22162. bytesData, _ := json.Marshal(data)
  22163. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2204", bytes.NewReader(bytesData))
  22164. resp, _ := client.Do(req)
  22165. defer resp.Body.Close()
  22166. body, ioErr := ioutil.ReadAll(resp.Body)
  22167. if ioErr != nil {
  22168. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  22169. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22170. return
  22171. }
  22172. var respJSON map[string]interface{}
  22173. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  22174. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22175. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22176. return
  22177. }
  22178. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22179. userJSONBytes, _ := json.Marshal(respJSON)
  22180. fmt.Println("log")
  22181. fmt.Println(string(userJSONBytes))
  22182. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  22183. utils.ErrorLog("解析失败:%v", err)
  22184. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22185. return
  22186. }
  22187. } else if miConfig.MdtrtareaAdmvs == "421182" {
  22188. bytesData, _ := json.Marshal(data)
  22189. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2204", bytes.NewReader(bytesData))
  22190. resp, _ := client.Do(req)
  22191. defer resp.Body.Close()
  22192. body, ioErr := ioutil.ReadAll(resp.Body)
  22193. if ioErr != nil {
  22194. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  22195. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22196. return
  22197. }
  22198. var respJSON map[string]interface{}
  22199. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  22200. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22201. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22202. return
  22203. }
  22204. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22205. userJSONBytes, _ := json.Marshal(respJSON)
  22206. fmt.Println("log")
  22207. fmt.Println(string(userJSONBytes))
  22208. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  22209. utils.ErrorLog("解析失败:%v", err)
  22210. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22211. return
  22212. }
  22213. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  22214. result3101 := Check3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  22215. if result3101.Infcode == "0" {
  22216. if len(result3101.Output.Result) > 0 {
  22217. var errMsgs []string
  22218. for _, item := range result3101.Output.Result {
  22219. errMsgs = append(errMsgs, item.VolaCont)
  22220. }
  22221. c.ServeSuccessJSON(map[string]interface{}{
  22222. "failed_code": -10,
  22223. "msg": errMsgs,
  22224. })
  22225. return
  22226. } else {
  22227. if miConfig.MdtrtareaAdmvs == "320921" {
  22228. data["doctor_id"] = "D320923012139"
  22229. } else {
  22230. data["doctor_id"] = "D371621008686"
  22231. }
  22232. bytesData, _ := json.Marshal(data)
  22233. var req *http.Request
  22234. if miConfig.MdtrtareaAdmvs == "320921" {
  22235. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  22236. } else {
  22237. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  22238. }
  22239. resp, _ := client.Do(req)
  22240. defer resp.Body.Close()
  22241. body, ioErr := ioutil.ReadAll(resp.Body)
  22242. if ioErr != nil {
  22243. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  22244. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22245. return
  22246. }
  22247. var respJSON map[string]interface{}
  22248. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  22249. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22250. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22251. return
  22252. }
  22253. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22254. userJSONBytes, _ := json.Marshal(respJSON)
  22255. fmt.Println("log")
  22256. fmt.Println(string(userJSONBytes))
  22257. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  22258. utils.ErrorLog("解析失败:%v", err)
  22259. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22260. return
  22261. }
  22262. res.InfRefmsgid = resFour10265.InfRefmsgid
  22263. res.Output = resFour10265.Output
  22264. res.ErrMsg = resFour10265.ErrMsg
  22265. res.Cainfo = resFour10265.Cainfo
  22266. res.WarnMsg = resFour10265.WarnMsg
  22267. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  22268. res.Infcode = infocode
  22269. }
  22270. }
  22271. } else if miConfig.MdtrtareaAdmvs == "150499" {
  22272. var pagesize int = 5
  22273. var start int = 1
  22274. var stop int
  22275. var pagecount int
  22276. var curpage int
  22277. data["doctor_id"] = doctor_info.DoctorNumber
  22278. var res2 ResultFour
  22279. //var result res.
  22280. //总页数,向上取整,注意除之前要先转换类型为float64
  22281. pagecount = int(math.Ceil(float64(len(prescriptions)) / float64(pagesize)))
  22282. for curpage = 1; curpage <= pagecount; curpage++ {
  22283. if curpage == 1 {
  22284. start = 1
  22285. } else {
  22286. start = (curpage-1)*pagesize + 1
  22287. }
  22288. stop = curpage * pagesize
  22289. if stop > len(prescriptions) {
  22290. stop = len(prescriptions)
  22291. }
  22292. //var requestLog string
  22293. data["pre"] = prescriptions[start-1 : stop]
  22294. fmt.Println(data["pre"])
  22295. bytesData, _ := json.Marshal(data)
  22296. var req *http.Request
  22297. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2204", bytes.NewReader(bytesData))
  22298. resp, _ := client.Do(req)
  22299. defer resp.Body.Close()
  22300. body, ioErr := ioutil.ReadAll(resp.Body)
  22301. if ioErr != nil {
  22302. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  22303. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22304. return
  22305. }
  22306. var respJSON map[string]interface{}
  22307. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  22308. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22309. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22310. return
  22311. }
  22312. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22313. userJSONBytes, _ := json.Marshal(respJSON)
  22314. fmt.Println("log")
  22315. fmt.Println(string(userJSONBytes))
  22316. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  22317. utils.ErrorLog("解析失败:%v", err)
  22318. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22319. return
  22320. }
  22321. res.InfRefmsgid = resFour10265.InfRefmsgid
  22322. res.Output = resFour10265.Output
  22323. res.ErrMsg = resFour10265.ErrMsg
  22324. res.Cainfo = resFour10265.Cainfo
  22325. res.WarnMsg = resFour10265.WarnMsg
  22326. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  22327. res.Infcode = infocode
  22328. if infocode == 0 {
  22329. res2.Output.Result = append(res2.Output.Result, res.Output.Result...)
  22330. } else {
  22331. isSuccess = false
  22332. res2.ErrMsg = res2.ErrMsg + "," + res.ErrMsg
  22333. res.Infcode = -1
  22334. res.ErrMsg = resFour10265.ErrMsg
  22335. errlog := &models.HisOrderError{
  22336. UserOrgId: adminUser.CurrentOrgId,
  22337. Ctime: time.Now().Unix(),
  22338. Mtime: time.Now().Unix(),
  22339. Number: chrg_bchno,
  22340. ErrMsg: "",
  22341. Status: 1,
  22342. PatientId: id,
  22343. RecordTime: recordDateTime,
  22344. Stage: 4,
  22345. }
  22346. service.CreateErrMsgLog(errlog)
  22347. }
  22348. }
  22349. if isSuccess {
  22350. res.Infcode = 0
  22351. res.Output.Result = res2.Output.Result
  22352. } else {
  22353. order := &models.HisOrder{
  22354. UserOrgId: adminUser.CurrentOrgId,
  22355. HisPatientId: his.ID,
  22356. PatientId: his.PatientId,
  22357. SettleAccountsDate: recordDateTime,
  22358. Ctime: time.Now().Unix(),
  22359. Mtime: time.Now().Unix(),
  22360. MdtrtId: his.Number,
  22361. PsnNo: his.PsnNo,
  22362. MedType: strconv.FormatInt(reg_type, 10),
  22363. Status: 1,
  22364. Number: chrg_bchno,
  22365. Infcode: res.Infcode,
  22366. WarnMsg: res.WarnMsg,
  22367. Cainfo: res.Cainfo,
  22368. ErrMsg: res.ErrMsg,
  22369. RespondTime: res.RefmsgTime,
  22370. InfRefmsgid: res.InfRefmsgid,
  22371. OrderStatus: 1,
  22372. IsMedicineInsurance: 1,
  22373. SettleType: settle_accounts_type,
  22374. SettleStartTime: start_time,
  22375. SettleEndTime: end_time,
  22376. Creator: roles.AdminUserId,
  22377. Modify: roles.AdminUserId,
  22378. PType: 2,
  22379. Diagnosis: diagnosis_id,
  22380. }
  22381. err = service.CreateOrder(order)
  22382. if err != nil {
  22383. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  22384. return
  22385. }
  22386. c.ServeSuccessJSON(map[string]interface{}{
  22387. "failed_code": -10,
  22388. "msg": res2.ErrMsg,
  22389. })
  22390. return
  22391. }
  22392. } else if miConfig.MdtrtareaAdmvs == "350500" {
  22393. 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)
  22394. var dat map[string]interface{}
  22395. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  22396. fmt.Println(dat)
  22397. } else {
  22398. fmt.Println(err)
  22399. }
  22400. saveLog(result, request_log, "2204", "上传费用明细")
  22401. userJSONBytes, _ := json.Marshal(dat)
  22402. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  22403. utils.ErrorLog("解析失败:%v", err)
  22404. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22405. return
  22406. }
  22407. } else if miConfig.MdtrtareaAdmvs == "360302" {
  22408. 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, "", "")
  22409. var dat map[string]interface{}
  22410. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  22411. fmt.Println(dat)
  22412. } else {
  22413. fmt.Println(err)
  22414. }
  22415. saveLog(result, request_log, "2204", "上传费用明细")
  22416. userJSONBytes, _ := json.Marshal(dat)
  22417. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  22418. utils.ErrorLog("解析失败:%v", err)
  22419. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22420. return
  22421. }
  22422. } else if miConfig.MdtrtareaAdmvs == "341203" {
  22423. bytesData, _ := json.Marshal(data)
  22424. var req *http.Request
  22425. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2204", bytes.NewReader(bytesData))
  22426. resp, _ := client.Do(req)
  22427. defer resp.Body.Close()
  22428. body, ioErr := ioutil.ReadAll(resp.Body)
  22429. if ioErr != nil {
  22430. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  22431. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22432. return
  22433. }
  22434. var respJSON map[string]interface{}
  22435. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  22436. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22437. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22438. return
  22439. }
  22440. status := respJSON["data"].(map[string]interface{})["status"].(string)
  22441. if status == "0" {
  22442. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  22443. c.ServeSuccessJSON(map[string]interface{}{
  22444. "failed_code": -10,
  22445. "msg": err_msg,
  22446. })
  22447. return
  22448. }
  22449. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22450. userJSONBytes, _ := json.Marshal(respJSON)
  22451. fmt.Println("log")
  22452. fmt.Println(string(userJSONBytes))
  22453. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  22454. utils.ErrorLog("解析失败:%v", err)
  22455. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22456. return
  22457. }
  22458. } else if miConfig.MdtrtareaAdmvs == "430800" {
  22459. 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, "", "")
  22460. var dat map[string]interface{}
  22461. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  22462. fmt.Println(dat)
  22463. } else {
  22464. fmt.Println(err)
  22465. }
  22466. saveLog(result, request_log, "2204", "上传费用明细")
  22467. userJSONBytes, _ := json.Marshal(dat)
  22468. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  22469. utils.ErrorLog("解析失败:%v", err)
  22470. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22471. return
  22472. }
  22473. } else if miConfig.MdtrtareaAdmvs == "441799" {
  22474. bytesData, _ := json.Marshal(data)
  22475. req, _ := http.NewRequest("POST", miConfig.Url+"gdyb/2204", bytes.NewReader(bytesData))
  22476. resp, _ := client.Do(req)
  22477. defer resp.Body.Close()
  22478. body, ioErr := ioutil.ReadAll(resp.Body)
  22479. if ioErr != nil {
  22480. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  22481. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22482. return
  22483. }
  22484. var respJSON map[string]interface{}
  22485. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  22486. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22487. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22488. return
  22489. }
  22490. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22491. userJSONBytes, _ := json.Marshal(respJSON)
  22492. fmt.Println("log")
  22493. fmt.Println(string(userJSONBytes))
  22494. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  22495. utils.ErrorLog("解析失败:%v", err)
  22496. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22497. return
  22498. }
  22499. } else {
  22500. if miConfig.MdtrtareaAdmvs == "441202" {
  22501. result3101 := Checkgd3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  22502. if result3101.Infcode == 0 {
  22503. if len(result3101.Output.Result) > 0 {
  22504. var errMsgs []string
  22505. for _, item := range result3101.Output.Result {
  22506. errMsgs = append(errMsgs, item.VolaCont)
  22507. }
  22508. c.ServeSuccessJSON(map[string]interface{}{
  22509. "failed_code": -10,
  22510. "msg": errMsgs,
  22511. })
  22512. return
  22513. } else {
  22514. 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)
  22515. var dat map[string]interface{}
  22516. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  22517. fmt.Println(dat)
  22518. } else {
  22519. fmt.Println(err)
  22520. }
  22521. saveLog(result, request_log, "2204", "上传费用明细")
  22522. userJSONBytes, _ := json.Marshal(dat)
  22523. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  22524. utils.ErrorLog("解析失败:%v", err)
  22525. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22526. return
  22527. }
  22528. }
  22529. } else {
  22530. c.ServeSuccessJSON(map[string]interface{}{
  22531. "failed_code": -10,
  22532. "msg": result3101.ErrMsg,
  22533. })
  22534. return
  22535. }
  22536. } else {
  22537. if miConfig.Code == "H15049901371" {
  22538. 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)
  22539. var dat map[string]interface{}
  22540. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  22541. fmt.Println(dat)
  22542. } else {
  22543. fmt.Println(err)
  22544. }
  22545. saveLog(result, request_log, "2204", "上传费用明细")
  22546. userJSONBytes, _ := json.Marshal(dat)
  22547. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  22548. utils.ErrorLog("解析失败:%v", err)
  22549. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22550. return
  22551. }
  22552. res.InfRefmsgid = resFour10265.InfRefmsgid
  22553. res.Output = resFour10265.Output
  22554. res.ErrMsg = resFour10265.ErrMsg
  22555. res.Cainfo = resFour10265.Cainfo
  22556. res.WarnMsg = resFour10265.WarnMsg
  22557. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  22558. res.Infcode = infocode
  22559. } else {
  22560. 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)
  22561. var dat map[string]interface{}
  22562. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  22563. fmt.Println(dat)
  22564. } else {
  22565. fmt.Println(err)
  22566. }
  22567. saveLog(result, request_log, "2204", "上传费用明细")
  22568. userJSONBytes, _ := json.Marshal(dat)
  22569. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  22570. utils.ErrorLog("解析失败:%v", err)
  22571. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22572. return
  22573. }
  22574. }
  22575. }
  22576. }
  22577. var total_two float64
  22578. if res.Infcode == 0 {
  22579. order := &models.HisOrder{
  22580. UserOrgId: adminUser.CurrentOrgId,
  22581. HisPatientId: his.ID,
  22582. PatientId: his.PatientId,
  22583. SettleAccountsDate: recordDateTime,
  22584. Ctime: time.Now().Unix(),
  22585. Mtime: time.Now().Unix(),
  22586. MdtrtId: his.Number,
  22587. PsnNo: his.PsnNo,
  22588. MedType: strconv.FormatInt(reg_type, 10),
  22589. Status: 1,
  22590. Number: chrg_bchno,
  22591. Infcode: res.Infcode,
  22592. WarnMsg: res.WarnMsg,
  22593. Cainfo: res.Cainfo,
  22594. ErrMsg: res.ErrMsg,
  22595. RespondTime: res.RefmsgTime,
  22596. InfRefmsgid: res.InfRefmsgid,
  22597. OrderStatus: 1,
  22598. IsMedicineInsurance: 1,
  22599. SettleType: settle_accounts_type,
  22600. SettleStartTime: start_time,
  22601. SettleEndTime: end_time,
  22602. Creator: roles.AdminUserId,
  22603. Modify: roles.AdminUserId,
  22604. PType: 2,
  22605. Diagnosis: diagnosis_id,
  22606. }
  22607. err = service.CreateOrder(order)
  22608. if err != nil {
  22609. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  22610. return
  22611. }
  22612. for _, item := range res.Output.Result {
  22613. temp := strings.Split(item.FeedetlSn, "-")
  22614. var advice_id int64 = 0
  22615. var project_id int64 = 0
  22616. var types int64 = 0
  22617. id, _ := strconv.ParseInt(temp[2], 10, 64)
  22618. types, _ = strconv.ParseInt(temp[1], 10, 64)
  22619. if temp[1] == "1" {
  22620. advice_id = id
  22621. project_id = 0
  22622. } else if temp[1] == "2" {
  22623. advice_id = 0
  22624. project_id = id
  22625. }
  22626. total_two = total_two + item.DetItemFeeSumamt
  22627. info := &models.HisOrderInfo{
  22628. OrderNumber: order.Number,
  22629. FeedetlSn: item.FeedetlSn,
  22630. UploadDate: time.Now().Unix(),
  22631. AdviceId: advice_id,
  22632. DetItemFeeSumamt: item.DetItemFeeSumamt,
  22633. Cnt: item.Cnt,
  22634. Pric: float64(item.Pric),
  22635. PatientId: his.PatientId,
  22636. PricUplmtAmt: item.PricUplmtAmt,
  22637. SelfpayProp: item.SelfpayProp,
  22638. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  22639. OverlmtAmt: item.OverlmtAmt,
  22640. PreselfpayAmt: item.PreselfpayAmt,
  22641. BasMednFlag: item.BasMednFlag,
  22642. MedChrgitmType: item.MedChrgitmType,
  22643. HiNegoDrugFlag: item.HiNegoDrugFlag,
  22644. Status: 1,
  22645. Memo: item.Memo,
  22646. Mtime: time.Now().Unix(),
  22647. InscpScpAmt: item.InscpScpAmt,
  22648. DrtReimFlag: item.DrtReimFlag,
  22649. Ctime: time.Now().Unix(),
  22650. ListSpItemFlag: item.ListSpItemFlag,
  22651. ChldMedcFlag: item.ChldMedcFlag,
  22652. LmtUsedFlag: item.LmtUsedFlag,
  22653. ChrgitmLv: item.ChrgitmLv,
  22654. UserOrgId: adminUser.CurrentOrgId,
  22655. HisPatientId: his.ID,
  22656. OrderId: order.ID,
  22657. ProjectId: project_id,
  22658. Type: types,
  22659. }
  22660. service.CreateOrderInfo(info)
  22661. }
  22662. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  22663. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  22664. var total float64
  22665. for _, item := range prescriptions {
  22666. if item.Type == 1 { //药品
  22667. for _, subItem := range item.HisDoctorAdviceInfo {
  22668. price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  22669. total_one := price * subItem.PrescribingNumber
  22670. fmt.Println("subItem")
  22671. fmt.Println(subItem.Price)
  22672. fmt.Println("price")
  22673. fmt.Println(price)
  22674. fmt.Println("total_one")
  22675. fmt.Println(total_one)
  22676. total = total + total_one
  22677. fmt.Println(total)
  22678. }
  22679. }
  22680. if item.Type == 2 { //项目
  22681. for _, subItem := range item.HisPrescriptionProject {
  22682. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  22683. price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  22684. total_one := price * cnt
  22685. total = total + total_one
  22686. }
  22687. }
  22688. }
  22689. allTotal := fmt.Sprintf("%.2f", total)
  22690. if res.Infcode == 0 {
  22691. var rf []*ResultFive
  22692. json.Unmarshal([]byte(his.Iinfo), &rf)
  22693. chrg_bchno := chrg_bchno
  22694. cert_no := his.Certno
  22695. var insutypes []string
  22696. var insutype string
  22697. var is390 int = 0
  22698. var is310 int = 0
  22699. for _, item := range rf {
  22700. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  22701. insutypes = append(insutypes, item.Insutype)
  22702. }
  22703. }
  22704. if len(insutypes) == 1 {
  22705. insutype = insutypes[0]
  22706. } else {
  22707. for _, i := range insutypes {
  22708. if i == "390" {
  22709. is390 = 1
  22710. }
  22711. if i == "310" {
  22712. is310 = 1
  22713. }
  22714. }
  22715. }
  22716. if is390 == 1 {
  22717. insutype = "390"
  22718. }
  22719. if is310 == 1 {
  22720. insutype = "310"
  22721. }
  22722. if len(insutypes) == 0 {
  22723. insutype = "390"
  22724. }
  22725. if len(insutypes) == 2 {
  22726. insutype = strconv.FormatInt(his.SocialType, 10)
  22727. }
  22728. //insutype = "390"
  22729. if his.IdCardType == 1 {
  22730. cert_no = his.MedicalInsuranceNumber
  22731. } else {
  22732. cert_no = his.Certno
  22733. }
  22734. var res ResultSeven
  22735. var ahres ResultSevenAH
  22736. var resSeven10265 ResultSeven10265
  22737. var resSeven10265Two ResultSeven10265Two
  22738. var gzresSeven10265Two GZResultSeven10265Two
  22739. if miConfig.MdtrtareaAdmvs == "421300" {
  22740. formattedString := strconv.FormatFloat(total, 'f', 2, 64)
  22741. api := "http://192.168.124.4:9532/" + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  22742. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  22743. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  22744. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  22745. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  22746. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  22747. "&insutype=" + insutype + "&total=" + formattedString + "&med_type=" + strconv.FormatInt(reg_type, 10)
  22748. resp, requestErr := http.Get(api)
  22749. if requestErr != nil {
  22750. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22751. return
  22752. }
  22753. body, ioErr := ioutil.ReadAll(resp.Body)
  22754. if ioErr != nil {
  22755. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  22756. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22757. return
  22758. }
  22759. var respJSON map[string]interface{}
  22760. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  22761. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22762. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22763. return
  22764. }
  22765. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22766. result, _ := json.Marshal(respJSON)
  22767. fmt.Println("log")
  22768. fmt.Println(string(result))
  22769. if err := json.Unmarshal([]byte(result), &res); err != nil {
  22770. utils.ErrorLog("解析失败:%v", err)
  22771. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22772. return
  22773. }
  22774. } else if miConfig.MdtrtareaAdmvs == "420200" {
  22775. if reg_type == 11 && his.Insutype == "390" {
  22776. reg_type = 110104
  22777. }
  22778. api := "http://192.168.0.197:9532/" + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  22779. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  22780. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  22781. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  22782. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  22783. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  22784. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  22785. resp, requestErr := http.Get(api)
  22786. if requestErr != nil {
  22787. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22788. return
  22789. }
  22790. body, ioErr := ioutil.ReadAll(resp.Body)
  22791. if ioErr != nil {
  22792. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  22793. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22794. return
  22795. }
  22796. var respJSON map[string]interface{}
  22797. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  22798. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22799. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22800. return
  22801. }
  22802. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22803. result, _ := json.Marshal(respJSON)
  22804. fmt.Println("log")
  22805. fmt.Println(string(result))
  22806. if err := json.Unmarshal([]byte(result), &res); err != nil {
  22807. utils.ErrorLog("解析失败:%v", err)
  22808. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22809. return
  22810. }
  22811. } else if miConfig.MdtrtareaAdmvs == "420902" {
  22812. if reg_type == 11 && his.Insutype == "390" {
  22813. reg_type = 110104
  22814. }
  22815. api := miConfig.Url + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  22816. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  22817. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  22818. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  22819. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  22820. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  22821. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  22822. resp, requestErr := http.Get(api)
  22823. if requestErr != nil {
  22824. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22825. return
  22826. }
  22827. body, ioErr := ioutil.ReadAll(resp.Body)
  22828. if ioErr != nil {
  22829. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  22830. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22831. return
  22832. }
  22833. var respJSON map[string]interface{}
  22834. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  22835. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22836. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22837. return
  22838. }
  22839. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22840. result, _ := json.Marshal(respJSON)
  22841. fmt.Println("log")
  22842. fmt.Println(string(result))
  22843. if err := json.Unmarshal([]byte(result), &res); err != nil {
  22844. utils.ErrorLog("解析失败:%v", err)
  22845. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22846. return
  22847. }
  22848. } else if miConfig.MdtrtareaAdmvs == "421182" {
  22849. if reg_type == 11 && his.Insutype == "390" {
  22850. reg_type = 110104
  22851. }
  22852. api := miConfig.Url + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  22853. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  22854. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  22855. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  22856. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  22857. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  22858. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  22859. resp, requestErr := http.Get(api)
  22860. if requestErr != nil {
  22861. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22862. return
  22863. }
  22864. body, ioErr := ioutil.ReadAll(resp.Body)
  22865. if ioErr != nil {
  22866. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  22867. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22868. return
  22869. }
  22870. var respJSON map[string]interface{}
  22871. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  22872. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22873. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22874. return
  22875. }
  22876. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22877. result, _ := json.Marshal(respJSON)
  22878. fmt.Println("log")
  22879. fmt.Println(string(result))
  22880. if err := json.Unmarshal([]byte(result), &res); err != nil {
  22881. utils.ErrorLog("解析失败:%v", err)
  22882. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22883. return
  22884. }
  22885. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  22886. result3101 := Check3102(c, id, his_patient_id, admin_user_id, "6", order.ID)
  22887. if result3101.Infcode == "0" {
  22888. if len(result3101.Output.Result) > 0 {
  22889. var errMsgs []string
  22890. for _, item := range result3101.Output.Result {
  22891. errMsgs = append(errMsgs, item.VolaCont)
  22892. }
  22893. c.ServeSuccessJSON(map[string]interface{}{
  22894. "failed_code": -10,
  22895. "msg": errMsgs,
  22896. })
  22897. return
  22898. } else {
  22899. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  22900. if his.IdCardType != 4 {
  22901. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  22902. bas := strings.Split(psn_info.CardInfo, "|")
  22903. if his.IdCardType == 1 {
  22904. cert_no = bas[2]
  22905. } else {
  22906. cert_no = bas[1]
  22907. }
  22908. } else {
  22909. cert_no = his.Certno
  22910. }
  22911. //江苏地区国家医保医疗类别
  22912. //职工透析:医疗类别选特殊情况门诊9933
  22913. //居民血透门慢: 医疗类别选门诊慢病1402
  22914. //var med_type string
  22915. //if his.Insutype == "310" {
  22916. // if reg_type == 14 {
  22917. // med_type = "9933"
  22918. // } else if reg_type == 11 {
  22919. // med_type = "11"
  22920. //
  22921. // }
  22922. //} else if his.Insutype == "390" {
  22923. // if reg_type == 14 {
  22924. // med_type = "1402"
  22925. // } else if reg_type == 11 {
  22926. // med_type = "11"
  22927. // }
  22928. //}
  22929. var api string
  22930. if miConfig.MdtrtareaAdmvs == "320921" {
  22931. api = "http://192.168.2.3:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  22932. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  22933. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  22934. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  22935. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  22936. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  22937. "&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
  22938. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  22939. } else {
  22940. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  22941. api = "http://192.168.5.251:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  22942. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  22943. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  22944. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  22945. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  22946. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  22947. "&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
  22948. }
  22949. resp, requestErr := http.Get(api)
  22950. if requestErr != nil {
  22951. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22952. return
  22953. }
  22954. body, ioErr := ioutil.ReadAll(resp.Body)
  22955. if ioErr != nil {
  22956. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  22957. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22958. return
  22959. }
  22960. var respJSON map[string]interface{}
  22961. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  22962. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22963. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22964. return
  22965. }
  22966. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22967. result, _ := json.Marshal(respJSON)
  22968. fmt.Println("log")
  22969. fmt.Println(string(result))
  22970. if strings.Contains(miConfig.MdtrtareaAdmvs, "3209") {
  22971. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  22972. utils.ErrorLog("解析失败:%v", err)
  22973. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22974. return
  22975. }
  22976. res.InfRefmsgid = resSeven10265.InfRefmsgid
  22977. res.Output = resSeven10265.Output
  22978. res.ErrMsg = resSeven10265.ErrMsg
  22979. res.Cainfo = resSeven10265.Cainfo
  22980. res.WarnMsg = resSeven10265.WarnMsg
  22981. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  22982. res.Infcode = infocode
  22983. } else {
  22984. if err := json.Unmarshal([]byte(result), &resSeven10265Two); err != nil {
  22985. utils.ErrorLog("解析失败:%v", err)
  22986. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22987. return
  22988. }
  22989. res.InfRefmsgid = resSeven10265Two.InfRefmsgid
  22990. //AcctMulaidPay, _ := strconv.ParseFloat(resSeven10265Two.Output.Setlinfo.AcctMulaidPay, 64)
  22991. //res.Output.Setlinfo.AcctMulaidPay = AcctMulaidPay
  22992. res.Output.Setlinfo.AcctPay = resSeven10265Two.Output.Setlinfo.AcctPay
  22993. res.Output.Setlinfo.CvlservPay = resSeven10265Two.Output.Setlinfo.CvlservPay
  22994. res.Output.Setlinfo.ActPayDedc = resSeven10265Two.Output.Setlinfo.ActPayDedc
  22995. res.Output.Setlinfo.Age = resSeven10265Two.Output.Setlinfo.Age
  22996. res.Output.Setlinfo.Balc = resSeven10265Two.Output.Setlinfo.Balc
  22997. //res.Output.Setlinfo.Brdy = resSeven10265Two.Output.Setlinfo.Brdy
  22998. res.Output.Setlinfo.Certno = resSeven10265Two.Output.Setlinfo.Certno
  22999. res.Output.Setlinfo.ClrOptins = resSeven10265Two.Output.Setlinfo.ClrOptins
  23000. res.Output.Setlinfo.ClrType = resSeven10265Two.Output.Setlinfo.ClrOptins
  23001. res.Output.Setlinfo.ClrWay = resSeven10265Two.Output.Setlinfo.ClrOptins
  23002. res.Output.Setlinfo.CvlservFlag = resSeven10265Two.Output.Setlinfo.ClrOptins
  23003. res.Output.Setlinfo.CvlservPay = resSeven10265Two.Output.Setlinfo.CvlservPay
  23004. res.Output.Setlinfo.FulamtOwnpayAmt = resSeven10265Two.Output.Setlinfo.FulamtOwnpayAmt
  23005. res.Output.Setlinfo.FundPaySumamt = resSeven10265Two.Output.Setlinfo.FundPaySumamt
  23006. res.Output.Setlinfo.Gend = resSeven10265Two.Output.Setlinfo.Gend
  23007. res.Output.Setlinfo.HifesPay = resSeven10265Two.Output.Setlinfo.HifesPay
  23008. res.Output.Setlinfo.HifmiPay = resSeven10265Two.Output.Setlinfo.HifmiPay
  23009. res.Output.Setlinfo.HifpPay = resSeven10265Two.Output.Setlinfo.HifpPay
  23010. HospPartAmt, _ := strconv.ParseFloat(resSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  23011. res.Output.Setlinfo.HospPartAmt = HospPartAmt
  23012. res.Output.Setlinfo.InscpScpAmt = resSeven10265Two.Output.Setlinfo.InscpScpAmt
  23013. res.Output.Setlinfo.Insutype = resSeven10265Two.Output.Setlinfo.Insutype
  23014. res.Output.Setlinfo.MafPay = resSeven10265Two.Output.Setlinfo.MafPay
  23015. res.Output.Setlinfo.MdtrtCertType = resSeven10265Two.Output.Setlinfo.MdtrtCertType
  23016. res.Output.Setlinfo.HifobPay = resSeven10265Two.Output.Setlinfo.HifobPay
  23017. res.Output.Setlinfo.MdtrtID = resSeven10265Two.Output.Setlinfo.MdtrtID
  23018. res.Output.Setlinfo.MedType = resSeven10265Two.Output.Setlinfo.MedType
  23019. res.Output.Setlinfo.MedfeeSumamt = resSeven10265Two.Output.Setlinfo.MedfeeSumamt
  23020. res.Output.Setlinfo.MedinsSetlID = resSeven10265Two.Output.Setlinfo.MedinsSetlID
  23021. res.Output.Setlinfo.Naty = resSeven10265Two.Output.Setlinfo.Naty
  23022. res.Output.Setlinfo.OthPay = resSeven10265Two.Output.Setlinfo.OthPay
  23023. res.Output.Setlinfo.OverlmtSelfpay = resSeven10265Two.Output.Setlinfo.OverlmtSelfpay
  23024. PoolPropSelfpay, _ := strconv.ParseFloat(resSeven10265Two.Output.Setlinfo.PoolPropSelfpay, 64)
  23025. res.Output.Setlinfo.PoolPropSelfpay = PoolPropSelfpay
  23026. res.Output.Setlinfo.PreselfpayAmt = resSeven10265Two.Output.Setlinfo.PreselfpayAmt
  23027. res.Output.Setlinfo.PsnCashPay = resSeven10265Two.Output.Setlinfo.PsnCashPay
  23028. res.Output.Setlinfo.PsnCertType = resSeven10265Two.Output.Setlinfo.ClrOptins
  23029. res.Output.Setlinfo.PsnName = resSeven10265Two.Output.Setlinfo.PsnName
  23030. res.Output.Setlinfo.PsnNo = resSeven10265Two.Output.Setlinfo.PsnNo
  23031. res.Output.Setlinfo.PsnPartAmt = resSeven10265Two.Output.Setlinfo.PsnPartAmt
  23032. res.Output.Setlinfo.PsnType = resSeven10265Two.Output.Setlinfo.PsnType
  23033. res.Output.Setlinfo.SetlID = resSeven10265Two.Output.Setlinfo.SetlID
  23034. res.Output.Setlinfo.SetlTime = resSeven10265Two.Output.Setlinfo.SetlTime
  23035. //res.Output.Setldetail = resSeven10265Two.Output.Setldetail
  23036. res.ErrMsg = resSeven10265Two.ErrMsg
  23037. res.Cainfo = resSeven10265Two.Cainfo
  23038. res.WarnMsg = resSeven10265Two.WarnMsg
  23039. infocode, _ := strconv.ParseInt(resSeven10265Two.Infcode, 10, 64)
  23040. res.Infcode = infocode
  23041. }
  23042. }
  23043. }
  23044. } else if miConfig.MdtrtareaAdmvs == "150499" {
  23045. psn_info, _ := service.GetPsnByPatientId(id)
  23046. var verify_number string
  23047. if psn_info.IdCardType == 4 {
  23048. verify_number = psn_info.VerifyNumber
  23049. } else if psn_info.IdCardType == 1 {
  23050. bas := strings.Split(psn_info.CardInfo, "|")
  23051. cardNumber := bas[2]
  23052. verify_number = cardNumber
  23053. } else {
  23054. psn_info.IdCardType = 2
  23055. verify_number = psn_info.Certno
  23056. }
  23057. var api string
  23058. api = "http://172.16.13.254:9532/" + "nmyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  23059. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  23060. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  23061. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  23062. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(psn_info.IdCardType, 10) +
  23063. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  23064. "&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
  23065. resp, requestErr := http.Get(api)
  23066. if requestErr != nil {
  23067. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23068. return
  23069. }
  23070. body, ioErr := ioutil.ReadAll(resp.Body)
  23071. if ioErr != nil {
  23072. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  23073. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23074. return
  23075. }
  23076. var respJSON map[string]interface{}
  23077. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  23078. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23079. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23080. return
  23081. }
  23082. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23083. result, _ := json.Marshal(respJSON)
  23084. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  23085. utils.ErrorLog("解析失败:%v", err)
  23086. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23087. return
  23088. }
  23089. res.InfRefmsgid = resSeven10265.InfRefmsgid
  23090. res.Output.Setlinfo.AcctMulaidPay = resSeven10265.Output.Setlinfo.AcctMulaidPay
  23091. res.Output.Setlinfo.AcctPay = resSeven10265.Output.Setlinfo.AcctPay
  23092. res.Output.Setlinfo.CvlservPay = resSeven10265.Output.Setlinfo.CvlservPay
  23093. res.Output.Setlinfo.ActPayDedc = resSeven10265.Output.Setlinfo.ActPayDedc
  23094. res.Output.Setlinfo.Age = resSeven10265.Output.Setlinfo.Age
  23095. res.Output.Setlinfo.Balc = resSeven10265.Output.Setlinfo.Balc
  23096. //res.Output.Setlinfo.Brdy = resSeven10265.Output.Setlinfo.Brdy
  23097. res.Output.Setlinfo.Certno = resSeven10265.Output.Setlinfo.Certno
  23098. res.Output.Setlinfo.ClrOptins = resSeven10265.Output.Setlinfo.ClrOptins
  23099. res.Output.Setlinfo.ClrType = resSeven10265.Output.Setlinfo.ClrOptins
  23100. res.Output.Setlinfo.ClrWay = resSeven10265.Output.Setlinfo.ClrOptins
  23101. res.Output.Setlinfo.CvlservFlag = resSeven10265.Output.Setlinfo.ClrOptins
  23102. res.Output.Setlinfo.CvlservPay = resSeven10265.Output.Setlinfo.CvlservPay
  23103. res.Output.Setlinfo.FulamtOwnpayAmt = resSeven10265.Output.Setlinfo.FulamtOwnpayAmt
  23104. res.Output.Setlinfo.FundPaySumamt = resSeven10265.Output.Setlinfo.FundPaySumamt
  23105. res.Output.Setlinfo.Gend = resSeven10265.Output.Setlinfo.Gend
  23106. res.Output.Setlinfo.HifesPay = resSeven10265.Output.Setlinfo.HifesPay
  23107. res.Output.Setlinfo.HifmiPay = resSeven10265.Output.Setlinfo.HifmiPay
  23108. res.Output.Setlinfo.HifpPay = resSeven10265.Output.Setlinfo.HifpPay
  23109. //HospPartAmt, _ := strconv.ParseFloat(resSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  23110. res.Output.Setlinfo.HospPartAmt = resSeven10265.Output.Setlinfo.HospPartAmt
  23111. res.Output.Setlinfo.InscpScpAmt = resSeven10265.Output.Setlinfo.InscpScpAmt
  23112. res.Output.Setlinfo.Insutype = resSeven10265.Output.Setlinfo.Insutype
  23113. res.Output.Setlinfo.MafPay = resSeven10265.Output.Setlinfo.MafPay
  23114. res.Output.Setlinfo.MdtrtCertType = resSeven10265.Output.Setlinfo.MdtrtCertType
  23115. res.Output.Setlinfo.HifobPay = resSeven10265.Output.Setlinfo.HifobPay
  23116. res.Output.Setlinfo.MdtrtID = resSeven10265.Output.Setlinfo.MdtrtID
  23117. res.Output.Setlinfo.MedType = resSeven10265.Output.Setlinfo.MedType
  23118. res.Output.Setlinfo.MedfeeSumamt = resSeven10265.Output.Setlinfo.MedfeeSumamt
  23119. res.Output.Setlinfo.MedinsSetlID = resSeven10265.Output.Setlinfo.MedinsSetlID
  23120. res.Output.Setlinfo.Naty = resSeven10265.Output.Setlinfo.Naty
  23121. res.Output.Setlinfo.OthPay = resSeven10265.Output.Setlinfo.OthPay
  23122. res.Output.Setlinfo.OverlmtSelfpay = resSeven10265.Output.Setlinfo.OverlmtSelfpay
  23123. //PoolPropSelfpay, _ := strconv.ParseFloat(resSeven10265Two.Output.Setlinfo.PoolPropSelfpay, 64)
  23124. res.Output.Setlinfo.PoolPropSelfpay = resSeven10265.Output.Setlinfo.PoolPropSelfpay
  23125. res.Output.Setlinfo.PreselfpayAmt = resSeven10265.Output.Setlinfo.PreselfpayAmt
  23126. res.Output.Setlinfo.PsnCashPay = resSeven10265.Output.Setlinfo.PsnCashPay
  23127. res.Output.Setlinfo.PsnCertType = resSeven10265.Output.Setlinfo.ClrOptins
  23128. res.Output.Setlinfo.PsnName = resSeven10265.Output.Setlinfo.PsnName
  23129. res.Output.Setlinfo.PsnNo = resSeven10265.Output.Setlinfo.PsnNo
  23130. res.Output.Setlinfo.PsnPartAmt = resSeven10265.Output.Setlinfo.PsnPartAmt
  23131. res.Output.Setlinfo.PsnType = resSeven10265.Output.Setlinfo.PsnType
  23132. res.Output.Setlinfo.SetlID = resSeven10265.Output.Setlinfo.SetlID
  23133. res.Output.Setlinfo.SetlTime = resSeven10265.Output.Setlinfo.SetlTime
  23134. //res.Output.Setldetail = resSeven10265.Output.Setldetail
  23135. res.ErrMsg = resSeven10265.ErrMsg
  23136. res.Cainfo = resSeven10265.Cainfo
  23137. res.WarnMsg = resSeven10265.WarnMsg
  23138. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  23139. res.Infcode = infocode
  23140. } else if miConfig.MdtrtareaAdmvs == "350500" {
  23141. acct_used_flag := "1"
  23142. psn_info, _ := service.GetPsnByPatientIdTwo(his.PatientId)
  23143. var result string
  23144. var request_log string
  23145. if his.IdCardType == 4 && len(psn_info.VerifyNumber) > 0 {
  23146. 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)
  23147. } else {
  23148. 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)
  23149. }
  23150. var dat map[string]interface{}
  23151. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  23152. fmt.Println(dat)
  23153. } else {
  23154. fmt.Println(err)
  23155. }
  23156. saveLog(result, request_log, "2206", "预结算")
  23157. userJSONBytes, _ := json.Marshal(dat)
  23158. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  23159. utils.ErrorLog("解析失败:%v", err)
  23160. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23161. return
  23162. }
  23163. } else if miConfig.MdtrtareaAdmvs == "360302" {
  23164. var result string
  23165. var request_log string
  23166. if his.IdCardType == 2 {
  23167. 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, "")
  23168. } else if his.IdCardType == 1 {
  23169. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  23170. bas := strings.Split(psn_info.CardInfo, "|")
  23171. basNumber := bas[2]
  23172. card_sn := bas[3]
  23173. var rf []*ResultFive
  23174. json.Unmarshal([]byte(his.Iinfo), &rf)
  23175. var psn_type string
  23176. for _, item := range rf {
  23177. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  23178. psn_type = item.PsnType
  23179. }
  23180. }
  23181. 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)
  23182. } else {
  23183. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  23184. 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, "")
  23185. }
  23186. var dat map[string]interface{}
  23187. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  23188. fmt.Println(dat)
  23189. } else {
  23190. fmt.Println(err)
  23191. }
  23192. saveLog(result, request_log, "2206", "预结算")
  23193. userJSONBytes, _ := json.Marshal(dat)
  23194. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  23195. utils.ErrorLog("解析失败:%v", err)
  23196. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23197. return
  23198. }
  23199. } else if miConfig.MdtrtareaAdmvs == "341203" {
  23200. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  23201. if his.IdCardType == 4 {
  23202. psn_info.VerifyNumber = psn_info.VerifyNumber
  23203. cert_no = psn_info.Certno
  23204. } else if his.IdCardType == 2 {
  23205. cert_no = psn_info.Certno
  23206. psn_info.VerifyNumber = psn_info.Certno
  23207. } else {
  23208. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  23209. bas := strings.Split(psn_info.CardInfo, "|")
  23210. if his.IdCardType == 1 {
  23211. cert_no = bas[2]
  23212. } else {
  23213. cert_no = bas[1]
  23214. }
  23215. }
  23216. var api string
  23217. var med_type string
  23218. if his.Insutype == "390" {
  23219. if reg_type == 992102 {
  23220. med_type = "992102"
  23221. }
  23222. if reg_type == 140104 {
  23223. med_type = "140104"
  23224. }
  23225. if reg_type == 14 {
  23226. med_type = "140104"
  23227. }
  23228. } else if his.Insutype == "310" {
  23229. if reg_type == 992102 {
  23230. med_type = "992102"
  23231. }
  23232. if reg_type == 14 {
  23233. med_type = "14"
  23234. }
  23235. }
  23236. api = miConfig.SecretKey + "ahyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  23237. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  23238. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  23239. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  23240. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  23241. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  23242. "&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
  23243. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  23244. resp, requestErr := http.Get(api)
  23245. if requestErr != nil {
  23246. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23247. return
  23248. }
  23249. body, ioErr := ioutil.ReadAll(resp.Body)
  23250. if ioErr != nil {
  23251. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  23252. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23253. return
  23254. }
  23255. var respJSON map[string]interface{}
  23256. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  23257. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23258. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23259. return
  23260. }
  23261. status := respJSON["data"].(map[string]interface{})["status"].(string)
  23262. if status == "0" {
  23263. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  23264. c.ServeSuccessJSON(map[string]interface{}{
  23265. "failed_code": -10,
  23266. "msg": err_msg,
  23267. })
  23268. return
  23269. }
  23270. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23271. result, _ := json.Marshal(respJSON)
  23272. fmt.Println("log")
  23273. fmt.Println(string(result))
  23274. if err := json.Unmarshal([]byte(result), &ahres); err != nil {
  23275. utils.ErrorLog("解析失败:%v", err)
  23276. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23277. return
  23278. }
  23279. res.InfRefmsgid = ahres.InfRefmsgid
  23280. timestamp := int64(ahres.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  23281. // 创建对应的Time类型
  23282. t := time.UnixMilli(timestamp)
  23283. // 格式化成指定的日期字符串
  23284. str := t.Format("2006-01-02 15:04:05")
  23285. res.Output.Setlinfo.SetlTime = str
  23286. res.Output.Setlinfo.AcctMulaidPay = ahres.Output.Setlinfo.AcctMulaidPay
  23287. res.Output.Setlinfo.AcctPay = ahres.Output.Setlinfo.AcctPay
  23288. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  23289. res.Output.Setlinfo.ActPayDedc = ahres.Output.Setlinfo.ActPayDedc
  23290. res.Output.Setlinfo.Age = ahres.Output.Setlinfo.Age
  23291. res.Output.Setlinfo.Balc = ahres.Output.Setlinfo.Balc
  23292. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  23293. res.Output.Setlinfo.Certno = ahres.Output.Setlinfo.Certno
  23294. res.Output.Setlinfo.ClrOptins = ahres.Output.Setlinfo.ClrOptins
  23295. res.Output.Setlinfo.ClrType = ahres.Output.Setlinfo.ClrOptins
  23296. res.Output.Setlinfo.ClrWay = ahres.Output.Setlinfo.ClrOptins
  23297. res.Output.Setlinfo.CvlservFlag = ahres.Output.Setlinfo.ClrOptins
  23298. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  23299. res.Output.Setlinfo.FulamtOwnpayAmt = ahres.Output.Setlinfo.FulamtOwnpayAmt
  23300. res.Output.Setlinfo.FundPaySumamt = ahres.Output.Setlinfo.FundPaySumamt
  23301. res.Output.Setlinfo.Gend = ahres.Output.Setlinfo.Gend
  23302. res.Output.Setlinfo.HifesPay = ahres.Output.Setlinfo.HifesPay
  23303. res.Output.Setlinfo.HifmiPay = ahres.Output.Setlinfo.HifmiPay
  23304. res.Output.Setlinfo.HifpPay = ahres.Output.Setlinfo.HifpPay
  23305. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  23306. res.Output.Setlinfo.HospPartAmt = ahres.Output.Setlinfo.HospPartAmt
  23307. res.Output.Setlinfo.InscpScpAmt = ahres.Output.Setlinfo.InscpScpAmt
  23308. res.Output.Setlinfo.Insutype = ahres.Output.Setlinfo.Insutype
  23309. res.Output.Setlinfo.MafPay = ahres.Output.Setlinfo.MafPay
  23310. res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  23311. res.Output.Setlinfo.HifobPay = ahres.Output.Setlinfo.HifobPay
  23312. res.Output.Setlinfo.MdtrtID = ahres.Output.Setlinfo.MdtrtID
  23313. res.Output.Setlinfo.MedType = ahres.Output.Setlinfo.MedType
  23314. res.Output.Setlinfo.MedfeeSumamt = ahres.Output.Setlinfo.MedfeeSumamt
  23315. res.Output.Setlinfo.MedinsSetlID = ahres.Output.Setlinfo.MedinsSetlID
  23316. res.Output.Setlinfo.Naty = ahres.Output.Setlinfo.Naty
  23317. res.Output.Setlinfo.OthPay = ahres.Output.Setlinfo.OthPay
  23318. res.Output.Setlinfo.OverlmtSelfpay = ahres.Output.Setlinfo.OverlmtSelfpay
  23319. res.Output.Setlinfo.PoolPropSelfpay = ahres.Output.Setlinfo.PoolPropSelfpay
  23320. res.Output.Setlinfo.PreselfpayAmt = ahres.Output.Setlinfo.PreselfpayAmt
  23321. res.Output.Setlinfo.PsnCashPay = ahres.Output.Setlinfo.PsnCashPay
  23322. res.Output.Setlinfo.PsnCertType = ahres.Output.Setlinfo.ClrOptins
  23323. res.Output.Setlinfo.PsnName = ahres.Output.Setlinfo.PsnName
  23324. res.Output.Setlinfo.PsnNo = ahres.Output.Setlinfo.PsnNo
  23325. res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  23326. res.Output.Setlinfo.PsnType = ahres.Output.Setlinfo.PsnType
  23327. res.Output.Setlinfo.SetlID = ahres.Output.Setlinfo.SetlID
  23328. //res.Output.Setldetail = ahres.Output.Setldetail
  23329. res.ErrMsg = ahres.ErrMsg
  23330. res.Cainfo = ahres.Cainfo
  23331. res.WarnMsg = ahres.WarnMsg
  23332. res.Infcode = ahres.Infcode
  23333. } else if miConfig.MdtrtareaAdmvs == "430800" {
  23334. var result string
  23335. var request_log string
  23336. if his.IdCardType == 2 {
  23337. 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")
  23338. } else if his.IdCardType == 1 {
  23339. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  23340. bas := strings.Split(psn_info.CardInfo, "|")
  23341. basNumber := bas[2]
  23342. card_sn := bas[3]
  23343. 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")
  23344. } else {
  23345. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  23346. 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")
  23347. }
  23348. var dat map[string]interface{}
  23349. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  23350. fmt.Println(dat)
  23351. } else {
  23352. fmt.Println(err)
  23353. }
  23354. saveLog(result, request_log, "2206", "预结算")
  23355. userJSONBytes, _ := json.Marshal(dat)
  23356. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  23357. utils.ErrorLog("解析失败:%v", err)
  23358. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23359. return
  23360. }
  23361. } else if miConfig.MdtrtareaAdmvs == "441799" {
  23362. api := miConfig.Url + "gdyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  23363. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  23364. "&operator=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  23365. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  23366. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  23367. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  23368. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  23369. resp, requestErr := http.Get(api)
  23370. if requestErr != nil {
  23371. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23372. return
  23373. }
  23374. body, ioErr := ioutil.ReadAll(resp.Body)
  23375. if ioErr != nil {
  23376. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  23377. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23378. return
  23379. }
  23380. var respJSON map[string]interface{}
  23381. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  23382. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23383. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23384. return
  23385. }
  23386. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23387. result, _ := json.Marshal(respJSON)
  23388. fmt.Println("log")
  23389. fmt.Println(string(result))
  23390. if err := json.Unmarshal([]byte(result), &res); err != nil {
  23391. utils.ErrorLog("解析失败:%v", err)
  23392. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23393. return
  23394. }
  23395. } else {
  23396. if miConfig.MdtrtareaAdmvs == "441202" {
  23397. result3101 := Checkgd3102(c, id, his_patient_id, admin_user_id, "6", order.ID)
  23398. if result3101.Infcode == 0 {
  23399. if len(result3101.Output.Result) > 0 {
  23400. var errMsgs []string
  23401. for _, item := range result3101.Output.Result {
  23402. errMsgs = append(errMsgs, item.VolaCont)
  23403. }
  23404. c.ServeSuccessJSON(map[string]interface{}{
  23405. "failed_code": -10,
  23406. "msg": errMsgs,
  23407. })
  23408. return
  23409. } else {
  23410. var result string
  23411. var request_log string
  23412. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  23413. allTotal = fmt.Sprintf("%.2f", total_two)
  23414. if his.IdCardType == 4 {
  23415. 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)
  23416. } else {
  23417. 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)
  23418. }
  23419. var dat map[string]interface{}
  23420. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  23421. fmt.Println(dat)
  23422. } else {
  23423. fmt.Println(err)
  23424. }
  23425. saveLog(result, request_log, "2206", "预结算")
  23426. //userJSONBytes, _ := json.Marshal(dat)
  23427. //
  23428. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  23429. // utils.ErrorLog("解析失败:%v", err)
  23430. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23431. // return
  23432. //}
  23433. userJSONBytes, _ := json.Marshal(dat)
  23434. if miConfig.Code == "H15049901371" {
  23435. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  23436. utils.ErrorLog("解析失败:%v", err)
  23437. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23438. return
  23439. }
  23440. res.InfRefmsgid = resSeven10265.InfRefmsgid
  23441. res.Output = resSeven10265.Output
  23442. res.ErrMsg = resSeven10265.ErrMsg
  23443. res.Cainfo = resSeven10265.Cainfo
  23444. res.WarnMsg = resSeven10265.WarnMsg
  23445. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  23446. res.Infcode = infocode
  23447. } else {
  23448. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  23449. utils.ErrorLog("解析失败:%v", err)
  23450. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23451. return
  23452. }
  23453. }
  23454. }
  23455. } else {
  23456. c.ServeSuccessJSON(map[string]interface{}{
  23457. "failed_code": -10,
  23458. "msg": result3101.ErrMsg,
  23459. })
  23460. return
  23461. }
  23462. } else {
  23463. var result string
  23464. var request_log string
  23465. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  23466. allTotal = fmt.Sprintf("%.2f", total_two)
  23467. if his.IdCardType == 4 {
  23468. 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)
  23469. } else {
  23470. 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)
  23471. }
  23472. var dat map[string]interface{}
  23473. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  23474. fmt.Println(dat)
  23475. } else {
  23476. fmt.Println(err)
  23477. }
  23478. saveLog(result, request_log, "2206", "预结算")
  23479. //userJSONBytes, _ := json.Marshal(dat)
  23480. //
  23481. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  23482. // utils.ErrorLog("解析失败:%v", err)
  23483. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23484. // return
  23485. //}
  23486. userJSONBytes, _ := json.Marshal(dat)
  23487. if miConfig.Code == "H15049901371" {
  23488. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  23489. utils.ErrorLog("解析失败:%v", err)
  23490. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23491. return
  23492. }
  23493. res.InfRefmsgid = resSeven10265.InfRefmsgid
  23494. res.Output = resSeven10265.Output
  23495. res.ErrMsg = resSeven10265.ErrMsg
  23496. res.Cainfo = resSeven10265.Cainfo
  23497. res.WarnMsg = resSeven10265.WarnMsg
  23498. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  23499. res.Infcode = infocode
  23500. } else {
  23501. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  23502. if err := json.Unmarshal(userJSONBytes, &gzresSeven10265Two); err != nil {
  23503. utils.ErrorLog("解析失败:%v", err)
  23504. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23505. return
  23506. }
  23507. res.InfRefmsgid = gzresSeven10265Two.InfRefmsgid
  23508. res.Output.Setlinfo.AcctMulaidPay = gzresSeven10265Two.Output.Setlinfo.AcctMulaidPay
  23509. res.Output.Setlinfo.AcctPay = gzresSeven10265Two.Output.Setlinfo.AcctPay
  23510. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  23511. res.Output.Setlinfo.ActPayDedc = gzresSeven10265Two.Output.Setlinfo.ActPayDedc
  23512. res.Output.Setlinfo.Age = gzresSeven10265Two.Output.Setlinfo.Age
  23513. res.Output.Setlinfo.Balc = gzresSeven10265Two.Output.Setlinfo.Balc
  23514. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  23515. res.Output.Setlinfo.Certno = gzresSeven10265Two.Output.Setlinfo.Certno
  23516. res.Output.Setlinfo.ClrOptins = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  23517. res.Output.Setlinfo.ClrType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  23518. res.Output.Setlinfo.ClrWay = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  23519. res.Output.Setlinfo.CvlservFlag = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  23520. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  23521. res.Output.Setlinfo.FulamtOwnpayAmt = gzresSeven10265Two.Output.Setlinfo.FulamtOwnpayAmt
  23522. res.Output.Setlinfo.FundPaySumamt = gzresSeven10265Two.Output.Setlinfo.FundPaySumamt
  23523. res.Output.Setlinfo.Gend = gzresSeven10265Two.Output.Setlinfo.Gend
  23524. res.Output.Setlinfo.HifesPay = gzresSeven10265Two.Output.Setlinfo.HifesPay
  23525. res.Output.Setlinfo.HifmiPay = gzresSeven10265Two.Output.Setlinfo.HifmiPay
  23526. res.Output.Setlinfo.HifpPay = gzresSeven10265Two.Output.Setlinfo.HifpPay
  23527. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  23528. res.Output.Setlinfo.HospPartAmt = gzresSeven10265Two.Output.Setlinfo.HospPartAmt
  23529. res.Output.Setlinfo.InscpScpAmt = gzresSeven10265Two.Output.Setlinfo.InscpScpAmt
  23530. res.Output.Setlinfo.Insutype = gzresSeven10265Two.Output.Setlinfo.Insutype
  23531. res.Output.Setlinfo.MafPay = gzresSeven10265Two.Output.Setlinfo.MafPay
  23532. res.Output.Setlinfo.MdtrtCertType = gzresSeven10265Two.Output.Setlinfo.MdtrtCertType
  23533. res.Output.Setlinfo.HifobPay = gzresSeven10265Two.Output.Setlinfo.HifobPay
  23534. res.Output.Setlinfo.MdtrtID = gzresSeven10265Two.Output.Setlinfo.MdtrtID
  23535. res.Output.Setlinfo.MedType = gzresSeven10265Two.Output.Setlinfo.MedType
  23536. res.Output.Setlinfo.MedfeeSumamt = gzresSeven10265Two.Output.Setlinfo.MedfeeSumamt
  23537. res.Output.Setlinfo.MedinsSetlID = gzresSeven10265Two.Output.Setlinfo.MedinsSetlID
  23538. res.Output.Setlinfo.Naty = gzresSeven10265Two.Output.Setlinfo.Naty
  23539. res.Output.Setlinfo.OthPay = gzresSeven10265Two.Output.Setlinfo.OthPay
  23540. res.Output.Setlinfo.OverlmtSelfpay = gzresSeven10265Two.Output.Setlinfo.OverlmtSelfpay
  23541. PoolPropSelfpay, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.PoolPropSelfpay, 64)
  23542. res.Output.Setlinfo.PoolPropSelfpay = PoolPropSelfpay
  23543. res.Output.Setlinfo.PreselfpayAmt = gzresSeven10265Two.Output.Setlinfo.PreselfpayAmt
  23544. res.Output.Setlinfo.PsnCashPay = gzresSeven10265Two.Output.Setlinfo.PsnCashPay
  23545. res.Output.Setlinfo.PsnCertType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  23546. res.Output.Setlinfo.PsnName = gzresSeven10265Two.Output.Setlinfo.PsnName
  23547. res.Output.Setlinfo.PsnNo = gzresSeven10265Two.Output.Setlinfo.PsnNo
  23548. res.Output.Setlinfo.PsnPartAmt = gzresSeven10265Two.Output.Setlinfo.PsnPartAmt
  23549. res.Output.Setlinfo.PsnType = gzresSeven10265Two.Output.Setlinfo.PsnType
  23550. res.Output.Setlinfo.SetlID = gzresSeven10265Two.Output.Setlinfo.SetlID
  23551. res.Output.Setlinfo.SetlTime = gzresSeven10265Two.Output.Setlinfo.SetlTime
  23552. //res.Output.Setldetail = gzresSeven10265Two.Output.Setldetail
  23553. res.ErrMsg = gzresSeven10265Two.ErrMsg
  23554. res.Cainfo = gzresSeven10265Two.Cainfo
  23555. res.WarnMsg = gzresSeven10265Two.WarnMsg
  23556. //infocode, _ := strconv.ParseInt(resSeven10265Two.Infcode, 10, 64)
  23557. //res.Infcode = infocode
  23558. } else {
  23559. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  23560. utils.ErrorLog("解析失败:%v", err)
  23561. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23562. return
  23563. }
  23564. }
  23565. }
  23566. }
  23567. }
  23568. utils.ErrorLog("解析失败:%v", res.Infcode)
  23569. if res.Infcode == -1 {
  23570. errlog := &models.HisOrderError{
  23571. UserOrgId: adminUser.CurrentOrgId,
  23572. Ctime: time.Now().Unix(),
  23573. Mtime: time.Now().Unix(),
  23574. Number: chrg_bchno,
  23575. ErrMsg: res.ErrMsg,
  23576. Status: 1,
  23577. PatientId: id,
  23578. RecordTime: recordDateTime,
  23579. Stage: 20,
  23580. }
  23581. service.CreateErrMsgLog(errlog)
  23582. c.ServeSuccessJSON(map[string]interface{}{
  23583. "failed_code": -10,
  23584. "msg": res.ErrMsg,
  23585. })
  23586. return
  23587. }
  23588. if res.Infcode != 0 {
  23589. errlog := &models.HisOrderError{
  23590. UserOrgId: adminUser.CurrentOrgId,
  23591. Ctime: time.Now().Unix(),
  23592. Mtime: time.Now().Unix(),
  23593. Number: chrg_bchno,
  23594. ErrMsg: res.ErrMsg,
  23595. Status: 1,
  23596. PatientId: id,
  23597. RecordTime: recordDateTime,
  23598. Stage: 20,
  23599. }
  23600. service.CreateErrMsgLog(errlog)
  23601. c.ServeSuccessJSON(map[string]interface{}{
  23602. "failed_code": -10,
  23603. "msg": res.ErrMsg,
  23604. })
  23605. return
  23606. } else {
  23607. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  23608. order.OrderStatus = 1
  23609. order.IsPre = 1
  23610. order.Status = 1
  23611. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  23612. order.SetlId = res.Output.Setlinfo.SetlID
  23613. order.PsnNo = res.Output.Setlinfo.PsnNo
  23614. order.PsnName = res.Output.Setlinfo.PsnName
  23615. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  23616. order.Certno = res.Output.Setlinfo.Certno
  23617. order.Gend = res.Output.Setlinfo.Gend
  23618. order.Naty = res.Output.Setlinfo.Naty
  23619. order.Age = res.Output.Setlinfo.Age
  23620. order.Insutype = res.Output.Setlinfo.Insutype
  23621. order.PsnType = res.Output.Setlinfo.PsnType
  23622. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  23623. order.SetlTime = res.Output.Setlinfo.SetlTime
  23624. order.AcctUsedFlag = acct_used_flag
  23625. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  23626. if res.Output.Setlinfo.MedType == "140101" {
  23627. order.MedType = "14"
  23628. } else {
  23629. if res.Output.Setlinfo.MedType == "110104" {
  23630. order.MedType = "11"
  23631. } else {
  23632. order.MedType = res.Output.Setlinfo.MedType
  23633. }
  23634. }
  23635. if res.Output.Setlinfo.MedType == "992102" {
  23636. order.MedType = "992102"
  23637. }
  23638. if res.Output.Setlinfo.MedType == "140104" {
  23639. order.MedType = "140104"
  23640. }
  23641. if res.Output.Setlinfo.MedType == "14" {
  23642. order.MedType = "14"
  23643. }
  23644. if reg_type == 1112 {
  23645. order.MedType = "1112"
  23646. }
  23647. if reg_type == 1111 {
  23648. order.MedType = "1111"
  23649. }
  23650. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  23651. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  23652. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  23653. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  23654. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  23655. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  23656. order.HifpPay = res.Output.Setlinfo.HifpPay
  23657. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  23658. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  23659. order.HifesPay = res.Output.Setlinfo.HifesPay
  23660. order.HifobPay = res.Output.Setlinfo.HifobPay
  23661. order.MafPay = res.Output.Setlinfo.MafPay
  23662. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  23663. order.OthPay = res.Output.Setlinfo.OthPay
  23664. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  23665. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  23666. order.AcctPay = res.Output.Setlinfo.AcctPay
  23667. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  23668. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  23669. order.Balc = res.Output.Setlinfo.Balc
  23670. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  23671. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  23672. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  23673. order.ClrWay = res.Output.Setlinfo.ClrWay
  23674. order.Creator = order.Creator
  23675. order.Modify = roles.AdminUserId
  23676. //setlDetail, _ := json.Marshal(res.Output.Setldetail)
  23677. //detailStr := string(setlDetail)
  23678. //order.SetlDetail = detailStr
  23679. //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  23680. err = service.UpDateOrder(order)
  23681. if err == nil {
  23682. c.ServeSuccessJSON(map[string]interface{}{
  23683. "msg": "预结算成功",
  23684. })
  23685. } else {
  23686. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  23687. return
  23688. }
  23689. }
  23690. } else {
  23691. adminUser := c.GetAdminUserInfo()
  23692. errlog := &models.HisOrderError{
  23693. UserOrgId: adminUser.CurrentOrgId,
  23694. Ctime: time.Now().Unix(),
  23695. Mtime: time.Now().Unix(),
  23696. ErrMsg: res.ErrMsg,
  23697. Status: 1,
  23698. PatientId: id,
  23699. RecordTime: recordDateTime,
  23700. Stage: 4,
  23701. }
  23702. service.CreateErrMsgLog(errlog)
  23703. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  23704. return
  23705. }
  23706. } else {
  23707. if miConfig.MdtrtareaAdmvs == "150499" {
  23708. order := &models.HisOrder{
  23709. UserOrgId: adminUser.CurrentOrgId,
  23710. HisPatientId: his.ID,
  23711. PatientId: his.PatientId,
  23712. SettleAccountsDate: recordDateTime,
  23713. Ctime: time.Now().Unix(),
  23714. Mtime: time.Now().Unix(),
  23715. MdtrtId: his.Number,
  23716. PsnNo: his.PsnNo,
  23717. MedType: strconv.FormatInt(reg_type, 10),
  23718. Status: 1,
  23719. Number: chrg_bchno,
  23720. Infcode: res.Infcode,
  23721. WarnMsg: res.WarnMsg,
  23722. Cainfo: res.Cainfo,
  23723. ErrMsg: res.ErrMsg,
  23724. RespondTime: res.RefmsgTime,
  23725. InfRefmsgid: res.InfRefmsgid,
  23726. OrderStatus: 1,
  23727. IsMedicineInsurance: 1,
  23728. SettleType: settle_accounts_type,
  23729. SettleStartTime: start_time,
  23730. SettleEndTime: end_time,
  23731. Creator: roles.AdminUserId,
  23732. Modify: roles.AdminUserId,
  23733. PType: 2,
  23734. Diagnosis: diagnosis_id,
  23735. }
  23736. err = service.CreateOrder(order)
  23737. if err != nil {
  23738. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  23739. return
  23740. }
  23741. }
  23742. adminUser := c.GetAdminUserInfo()
  23743. errlog := &models.HisOrderError{
  23744. UserOrgId: adminUser.CurrentOrgId,
  23745. Ctime: time.Now().Unix(),
  23746. Mtime: time.Now().Unix(),
  23747. ErrMsg: res.ErrMsg,
  23748. Status: 1,
  23749. PatientId: id,
  23750. RecordTime: recordDateTime,
  23751. Stage: 4,
  23752. }
  23753. service.CreateErrMsgLog(errlog)
  23754. c.ServeSuccessJSON(map[string]interface{}{
  23755. "failed_code": -10,
  23756. "msg": res.ErrMsg,
  23757. })
  23758. return
  23759. }
  23760. }
  23761. }
  23762. }
  23763. // 退款
  23764. func (c *HisApiController) Refund() {
  23765. order_id, _ := c.GetInt64("order_id")
  23766. admin_user_id, _ := c.GetInt64("admin_user_id")
  23767. adminUser := c.GetAdminUserInfo()
  23768. var order models.HisOrder
  23769. order, _ = service.GetHisOrderByID(order_id)
  23770. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  23771. if order.ID == 0 {
  23772. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  23773. return
  23774. }
  23775. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  23776. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  23777. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  23778. if config.IsOpen == 1 { //对接了医保,走医保流程
  23779. var res ResultSixteen
  23780. var ahres ResultSevenAH
  23781. var resSixteen10265 ResultSixteen10265
  23782. var resSixteen10265Two ResultSixteen10265Two
  23783. var gz ResultgzSixteen10265Two
  23784. var src_resquest string
  23785. var result string
  23786. if miConfig.MdtrtareaAdmvs == "421300" {
  23787. api3 := "http://192.168.124.4:9532/" + "hbyb/2208?psn_no=" + order.PsnNo +
  23788. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  23789. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  23790. resp3, requestErr3 := http.Get(api3)
  23791. if requestErr3 != nil {
  23792. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23793. return
  23794. }
  23795. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  23796. if ioErr3 != nil {
  23797. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  23798. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23799. return
  23800. }
  23801. var respJSON3 map[string]interface{}
  23802. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  23803. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23804. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23805. return
  23806. }
  23807. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23808. userJSONBytes3, _ := json.Marshal(respJSON3)
  23809. fmt.Println("log")
  23810. fmt.Println(string(userJSONBytes3))
  23811. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  23812. utils.ErrorLog("解析失败:%v", err)
  23813. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23814. return
  23815. }
  23816. } else if miConfig.MdtrtareaAdmvs == "420200" {
  23817. api3 := "http://192.168.0.197:9532/" + "hbyb/2208?psn_no=" + order.PsnNo +
  23818. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  23819. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  23820. resp3, requestErr3 := http.Get(api3)
  23821. if requestErr3 != nil {
  23822. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23823. return
  23824. }
  23825. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  23826. if ioErr3 != nil {
  23827. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  23828. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23829. return
  23830. }
  23831. var respJSON3 map[string]interface{}
  23832. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  23833. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23834. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23835. return
  23836. }
  23837. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23838. userJSONBytes3, _ := json.Marshal(respJSON3)
  23839. fmt.Println("log")
  23840. fmt.Println(string(userJSONBytes3))
  23841. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  23842. utils.ErrorLog("解析失败:%v", err)
  23843. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23844. return
  23845. }
  23846. } else if miConfig.MdtrtareaAdmvs == "420902" {
  23847. api3 := miConfig.Url + "hbyb/2208?psn_no=" + order.PsnNo +
  23848. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  23849. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  23850. resp3, requestErr3 := http.Get(api3)
  23851. if requestErr3 != nil {
  23852. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23853. return
  23854. }
  23855. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  23856. if ioErr3 != nil {
  23857. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  23858. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23859. return
  23860. }
  23861. var respJSON3 map[string]interface{}
  23862. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  23863. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23864. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23865. return
  23866. }
  23867. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23868. userJSONBytes3, _ := json.Marshal(respJSON3)
  23869. fmt.Println("log")
  23870. fmt.Println(string(userJSONBytes3))
  23871. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  23872. utils.ErrorLog("解析失败:%v", err)
  23873. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23874. return
  23875. }
  23876. } else if miConfig.MdtrtareaAdmvs == "421182" {
  23877. api3 := miConfig.Url + "hbyb/2208?psn_no=" + order.PsnNo +
  23878. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  23879. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  23880. resp3, requestErr3 := http.Get(api3)
  23881. if requestErr3 != nil {
  23882. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23883. return
  23884. }
  23885. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  23886. if ioErr3 != nil {
  23887. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  23888. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23889. return
  23890. }
  23891. var respJSON3 map[string]interface{}
  23892. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  23893. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23894. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23895. return
  23896. }
  23897. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23898. userJSONBytes3, _ := json.Marshal(respJSON3)
  23899. fmt.Println("log")
  23900. fmt.Println(string(userJSONBytes3))
  23901. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  23902. utils.ErrorLog("解析失败:%v", err)
  23903. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23904. return
  23905. }
  23906. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  23907. var api3 string
  23908. if miConfig.MdtrtareaAdmvs == "320921" {
  23909. api3 = "http://192.168.2.3:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  23910. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  23911. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  23912. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  23913. } else {
  23914. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  23915. api3 = "http://192.168.5.251:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  23916. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  23917. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  23918. }
  23919. resp3, requestErr3 := http.Get(api3)
  23920. if requestErr3 != nil {
  23921. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23922. return
  23923. }
  23924. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  23925. if ioErr3 != nil {
  23926. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  23927. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23928. return
  23929. }
  23930. var respJSON3 map[string]interface{}
  23931. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  23932. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23933. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23934. return
  23935. }
  23936. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23937. userJSONBytes3, _ := json.Marshal(respJSON3)
  23938. if err := json.Unmarshal(userJSONBytes3, &resSixteen10265Two); err != nil {
  23939. utils.ErrorLog("解析失败:%v", err)
  23940. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23941. return
  23942. }
  23943. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  23944. res.Output = resSixteen10265.Output
  23945. res.ErrMsg = resSixteen10265.ErrMsg
  23946. res.Cainfo = resSixteen10265.Cainfo
  23947. res.WarnMsg = resSixteen10265.WarnMsg
  23948. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  23949. res.Infcode = infocode
  23950. } else if miConfig.MdtrtareaAdmvs == "150499" {
  23951. var api3 string
  23952. api3 = "http://172.16.13.254:9532/" + "nmyb/2208?psn_no=" + order.PsnNo +
  23953. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  23954. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  23955. resp3, requestErr3 := http.Get(api3)
  23956. if requestErr3 != nil {
  23957. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23958. return
  23959. }
  23960. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  23961. if ioErr3 != nil {
  23962. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  23963. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23964. return
  23965. }
  23966. var respJSON3 map[string]interface{}
  23967. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  23968. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23969. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23970. return
  23971. }
  23972. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23973. userJSONBytes3, _ := json.Marshal(respJSON3)
  23974. if err := json.Unmarshal(userJSONBytes3, &resSixteen10265Two); err != nil {
  23975. utils.ErrorLog("解析失败:%v", err)
  23976. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23977. return
  23978. }
  23979. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  23980. res.Output = resSixteen10265.Output
  23981. res.ErrMsg = resSixteen10265.ErrMsg
  23982. res.Cainfo = resSixteen10265.Cainfo
  23983. res.WarnMsg = resSixteen10265.WarnMsg
  23984. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  23985. res.Infcode = infocode
  23986. } else if miConfig.MdtrtareaAdmvs == "350500" {
  23987. 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)
  23988. var dat map[string]interface{}
  23989. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  23990. fmt.Println(dat)
  23991. } else {
  23992. fmt.Println(err)
  23993. }
  23994. saveLog(result, src_resquest, "2208", "退费")
  23995. userJSONBytes, _ := json.Marshal(dat)
  23996. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  23997. utils.ErrorLog("解析失败:%v", err)
  23998. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23999. return
  24000. }
  24001. } else if miConfig.MdtrtareaAdmvs == "360302" {
  24002. 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, "")
  24003. var dat map[string]interface{}
  24004. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  24005. fmt.Println(dat)
  24006. } else {
  24007. fmt.Println(err)
  24008. }
  24009. saveLog(result, src_resquest, "2208", "退费")
  24010. userJSONBytes, _ := json.Marshal(dat)
  24011. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  24012. utils.ErrorLog("解析失败:%v", err)
  24013. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24014. return
  24015. }
  24016. } else if miConfig.MdtrtareaAdmvs == "341203" {
  24017. var api3 string
  24018. api3 = miConfig.SecretKey + "ahyb/2208?psn_no=" + order.PsnNo +
  24019. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  24020. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  24021. resp3, requestErr3 := http.Get(api3)
  24022. if requestErr3 != nil {
  24023. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24024. return
  24025. }
  24026. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  24027. if ioErr3 != nil {
  24028. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  24029. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24030. return
  24031. }
  24032. var respJSON3 map[string]interface{}
  24033. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  24034. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24035. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24036. return
  24037. }
  24038. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  24039. if status == "0" {
  24040. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  24041. c.ServeSuccessJSON(map[string]interface{}{
  24042. "failed_code": -10,
  24043. "msg": err_msg,
  24044. })
  24045. return
  24046. }
  24047. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24048. userJSONBytes3, _ := json.Marshal(respJSON3)
  24049. //if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  24050. // utils.ErrorLog("解析失败:%v", err)
  24051. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24052. // return
  24053. //}
  24054. if err := json.Unmarshal(userJSONBytes3, &ahres); err != nil {
  24055. utils.ErrorLog("解析失败:%v", err)
  24056. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24057. return
  24058. }
  24059. res.InfRefmsgid = ahres.InfRefmsgid
  24060. timestamp := int64(ahres.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  24061. // 创建对应的Time类型
  24062. t := time.UnixMilli(timestamp)
  24063. // 格式化成指定的日期字符串
  24064. str := t.Format("2006-01-02 15:04:05")
  24065. res.Output.Setlinfo.SetlTime = str
  24066. res.Output.Setlinfo.AcctMulaidPay = ahres.Output.Setlinfo.AcctMulaidPay
  24067. res.Output.Setlinfo.AcctPay = ahres.Output.Setlinfo.AcctPay
  24068. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  24069. res.Output.Setlinfo.ActPayDedc = ahres.Output.Setlinfo.ActPayDedc
  24070. //res.Output.Setlinfo.Age = ahres.Output.Setlinfo.Age
  24071. res.Output.Setlinfo.Balc = ahres.Output.Setlinfo.Balc
  24072. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  24073. //res.Output.Setlinfo.Certno = ahres.Output.Setlinfo.Certno
  24074. res.Output.Setlinfo.ClrOptins = ahres.Output.Setlinfo.ClrOptins
  24075. //
  24076. //res.Output.Setlinfo.ClrType = ahres.Output.Setlinfo.ClrOptins
  24077. //res.Output.Setlinfo.ClrWay = ahres.Output.Setlinfo.ClrOptins
  24078. //res.Output.Setlinfo.CvlservFlag = ahres.Output.Setlinfo.ClrOptins
  24079. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  24080. res.Output.Setlinfo.FulamtOwnpayAmt = ahres.Output.Setlinfo.FulamtOwnpayAmt
  24081. res.Output.Setlinfo.FundPaySumamt = ahres.Output.Setlinfo.FundPaySumamt
  24082. //res.Output.Setlinfo.Gend = ahres.Output.Setlinfo.Gend
  24083. res.Output.Setlinfo.HifesPay = ahres.Output.Setlinfo.HifesPay
  24084. res.Output.Setlinfo.HifmiPay = ahres.Output.Setlinfo.HifmiPay
  24085. res.Output.Setlinfo.HifpPay = ahres.Output.Setlinfo.HifpPay
  24086. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  24087. res.Output.Setlinfo.HospPartAmt = ahres.Output.Setlinfo.HospPartAmt
  24088. res.Output.Setlinfo.InscpScpAmt = ahres.Output.Setlinfo.InscpScpAmt
  24089. //res.Output.Setlinfo.Insutype = ahres.Output.Setlinfo.Insutype
  24090. res.Output.Setlinfo.MafPay = ahres.Output.Setlinfo.MafPay
  24091. //res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  24092. res.Output.Setlinfo.HifobPay = ahres.Output.Setlinfo.HifobPay
  24093. res.Output.Setlinfo.MdtrtID = ahres.Output.Setlinfo.MdtrtID
  24094. //res.Output.Setlinfo.MedType = ahres.Output.Setlinfo.MedType
  24095. res.Output.Setlinfo.MedfeeSumamt = ahres.Output.Setlinfo.MedfeeSumamt
  24096. res.Output.Setlinfo.MedinsSetlID = ahres.Output.Setlinfo.MedinsSetlID
  24097. //res.Output.Setlinfo.Naty = ahres.Output.Setlinfo.Naty
  24098. res.Output.Setlinfo.OthPay = ahres.Output.Setlinfo.OthPay
  24099. res.Output.Setlinfo.OverlmtSelfpay = ahres.Output.Setlinfo.OverlmtSelfpay
  24100. res.Output.Setlinfo.PreselfpayAmt = ahres.Output.Setlinfo.PreselfpayAmt
  24101. res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  24102. res.Output.Setlinfo.SetlID = ahres.Output.Setlinfo.SetlID
  24103. //res.Output.Setldetail = ahres.Output.Setldetail
  24104. res.ErrMsg = ahres.ErrMsg
  24105. res.Cainfo = ahres.Cainfo
  24106. res.WarnMsg = ahres.WarnMsg
  24107. res.Infcode = ahres.Infcode
  24108. } else if miConfig.MdtrtareaAdmvs == "430800" {
  24109. 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, "")
  24110. var dat map[string]interface{}
  24111. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  24112. fmt.Println(dat)
  24113. } else {
  24114. fmt.Println(err)
  24115. }
  24116. saveLog(result, src_resquest, "2208", "退费")
  24117. userJSONBytes, _ := json.Marshal(dat)
  24118. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  24119. utils.ErrorLog("解析失败:%v", err)
  24120. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24121. return
  24122. }
  24123. } else if miConfig.MdtrtareaAdmvs == "441799" {
  24124. api3 := miConfig.Url + "gdyb/2208?psn_no=" + order.PsnNo +
  24125. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&operator=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  24126. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  24127. resp3, requestErr3 := http.Get(api3)
  24128. if requestErr3 != nil {
  24129. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24130. return
  24131. }
  24132. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  24133. if ioErr3 != nil {
  24134. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  24135. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24136. return
  24137. }
  24138. var respJSON3 map[string]interface{}
  24139. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  24140. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24141. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24142. return
  24143. }
  24144. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24145. userJSONBytes3, _ := json.Marshal(respJSON3)
  24146. fmt.Println("log")
  24147. fmt.Println(string(userJSONBytes3))
  24148. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  24149. utils.ErrorLog("解析失败:%v", err)
  24150. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24151. return
  24152. }
  24153. } else {
  24154. if miConfig.Code == "H15049901371" {
  24155. 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)
  24156. var dat map[string]interface{}
  24157. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  24158. fmt.Println(dat)
  24159. } else {
  24160. fmt.Println(err)
  24161. }
  24162. saveLog(result, src_resquest, "2208", "退费")
  24163. userJSONBytes, _ := json.Marshal(dat)
  24164. if err := json.Unmarshal(userJSONBytes, &resSixteen10265); err != nil {
  24165. utils.ErrorLog("解析失败:%v", err)
  24166. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24167. return
  24168. }
  24169. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  24170. res.Output = resSixteen10265.Output
  24171. res.ErrMsg = resSixteen10265.ErrMsg
  24172. res.Cainfo = resSixteen10265.Cainfo
  24173. res.WarnMsg = resSixteen10265.WarnMsg
  24174. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  24175. res.Infcode = infocode
  24176. } else {
  24177. 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)
  24178. var dat map[string]interface{}
  24179. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  24180. fmt.Println(dat)
  24181. } else {
  24182. fmt.Println(err)
  24183. }
  24184. saveLog(result, src_resquest, "2208", "退费")
  24185. userJSONBytes, _ := json.Marshal(dat)
  24186. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  24187. if err := json.Unmarshal(userJSONBytes, &gz); err != nil {
  24188. utils.ErrorLog("解析失败:%v", err)
  24189. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24190. return
  24191. }
  24192. res.Infcode = gz.Infcode
  24193. } else {
  24194. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  24195. utils.ErrorLog("解析失败:%v", err)
  24196. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24197. return
  24198. }
  24199. }
  24200. }
  24201. }
  24202. if res.Infcode == 0 {
  24203. var res2 ResultSix
  24204. var resSix10265 ResultSix10265
  24205. if miConfig.MdtrtareaAdmvs == "421300" {
  24206. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  24207. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  24208. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  24209. resp3, requestErr3 := http.Get(api3)
  24210. if requestErr3 != nil {
  24211. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24212. return
  24213. }
  24214. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  24215. if ioErr3 != nil {
  24216. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  24217. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24218. return
  24219. }
  24220. var respJSON3 map[string]interface{}
  24221. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  24222. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24223. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24224. return
  24225. }
  24226. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24227. userJSONBytes3, _ := json.Marshal(respJSON3)
  24228. fmt.Println("log")
  24229. fmt.Println(string(userJSONBytes3))
  24230. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  24231. utils.ErrorLog("解析失败:%v", err)
  24232. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24233. return
  24234. }
  24235. } else if miConfig.MdtrtareaAdmvs == "420200" {
  24236. api3 := "http://192.168.0.197:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  24237. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  24238. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  24239. resp3, requestErr3 := http.Get(api3)
  24240. if requestErr3 != nil {
  24241. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24242. return
  24243. }
  24244. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  24245. if ioErr3 != nil {
  24246. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  24247. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24248. return
  24249. }
  24250. var respJSON3 map[string]interface{}
  24251. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  24252. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24253. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24254. return
  24255. }
  24256. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24257. userJSONBytes3, _ := json.Marshal(respJSON3)
  24258. fmt.Println("log")
  24259. fmt.Println(string(userJSONBytes3))
  24260. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  24261. utils.ErrorLog("解析失败:%v", err)
  24262. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24263. return
  24264. }
  24265. } else if miConfig.MdtrtareaAdmvs == "420902" {
  24266. api3 := miConfig.Url + "hbyb/2205?psn_no=" + order.PsnNo +
  24267. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  24268. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  24269. resp3, requestErr3 := http.Get(api3)
  24270. if requestErr3 != nil {
  24271. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24272. return
  24273. }
  24274. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  24275. if ioErr3 != nil {
  24276. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  24277. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24278. return
  24279. }
  24280. var respJSON3 map[string]interface{}
  24281. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  24282. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24283. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24284. return
  24285. }
  24286. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24287. userJSONBytes3, _ := json.Marshal(respJSON3)
  24288. fmt.Println("log")
  24289. fmt.Println(string(userJSONBytes3))
  24290. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  24291. utils.ErrorLog("解析失败:%v", err)
  24292. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24293. return
  24294. }
  24295. } else if miConfig.MdtrtareaAdmvs == "421182" {
  24296. api3 := miConfig.Url + "hbyb/2205?psn_no=" + order.PsnNo +
  24297. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  24298. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  24299. resp3, requestErr3 := http.Get(api3)
  24300. if requestErr3 != nil {
  24301. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24302. return
  24303. }
  24304. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  24305. if ioErr3 != nil {
  24306. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  24307. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24308. return
  24309. }
  24310. var respJSON3 map[string]interface{}
  24311. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  24312. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24313. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24314. return
  24315. }
  24316. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24317. userJSONBytes3, _ := json.Marshal(respJSON3)
  24318. fmt.Println("log")
  24319. fmt.Println(string(userJSONBytes3))
  24320. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  24321. utils.ErrorLog("解析失败:%v", err)
  24322. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24323. return
  24324. }
  24325. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  24326. var api3 string
  24327. if miConfig.MdtrtareaAdmvs == "320921" {
  24328. api3 = "http://192.168.2.3:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  24329. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  24330. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  24331. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  24332. } else {
  24333. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  24334. api3 = "http://192.168.5.251:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  24335. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  24336. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  24337. }
  24338. resp3, requestErr3 := http.Get(api3)
  24339. if requestErr3 != nil {
  24340. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24341. return
  24342. }
  24343. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  24344. if ioErr3 != nil {
  24345. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  24346. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24347. return
  24348. }
  24349. var respJSON3 map[string]interface{}
  24350. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  24351. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24352. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24353. return
  24354. }
  24355. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24356. userJSONBytes3, _ := json.Marshal(respJSON3)
  24357. fmt.Println("log")
  24358. fmt.Println(string(userJSONBytes3))
  24359. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  24360. utils.ErrorLog("解析失败:%v", err)
  24361. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24362. return
  24363. }
  24364. res2.InfRefmsgid = resSix10265.InfRefmsgid
  24365. res2.Output = resSix10265.Output
  24366. res2.ErrMsg = resSix10265.ErrMsg
  24367. res2.Cainfo = resSix10265.Cainfo
  24368. res2.WarnMsg = resSix10265.WarnMsg
  24369. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  24370. res2.Infcode = infocode
  24371. } else if miConfig.MdtrtareaAdmvs == "150499" {
  24372. var api3 string
  24373. api3 = "http://172.16.13.254:9532/" + "nmyb/2205?psn_no=" + order.PsnNo +
  24374. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  24375. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  24376. resp3, requestErr3 := http.Get(api3)
  24377. if requestErr3 != nil {
  24378. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24379. return
  24380. }
  24381. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  24382. if ioErr3 != nil {
  24383. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  24384. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24385. return
  24386. }
  24387. var respJSON3 map[string]interface{}
  24388. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  24389. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24390. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24391. return
  24392. }
  24393. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24394. userJSONBytes3, _ := json.Marshal(respJSON3)
  24395. fmt.Println("log")
  24396. fmt.Println(string(userJSONBytes3))
  24397. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  24398. utils.ErrorLog("解析失败:%v", err)
  24399. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24400. return
  24401. }
  24402. res2.InfRefmsgid = resSix10265.InfRefmsgid
  24403. res2.Output = resSix10265.Output
  24404. res2.ErrMsg = resSix10265.ErrMsg
  24405. res2.Cainfo = resSix10265.Cainfo
  24406. res2.WarnMsg = resSix10265.WarnMsg
  24407. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  24408. res2.Infcode = infocode
  24409. } else if miConfig.MdtrtareaAdmvs == "350500" {
  24410. 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)
  24411. var dat map[string]interface{}
  24412. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  24413. fmt.Println(dat)
  24414. } else {
  24415. fmt.Println(err)
  24416. }
  24417. saveLog(result2, src_request, "2205", "撤销明细")
  24418. userJSONBytes, _ := json.Marshal(dat)
  24419. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  24420. utils.ErrorLog("解析失败:%v", err)
  24421. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24422. return
  24423. }
  24424. } else if miConfig.MdtrtareaAdmvs == "360302" {
  24425. 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, "")
  24426. var dat map[string]interface{}
  24427. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  24428. fmt.Println(dat)
  24429. } else {
  24430. fmt.Println(err)
  24431. }
  24432. saveLog(result2, src_request, "2205", "撤销明细")
  24433. userJSONBytes, _ := json.Marshal(dat)
  24434. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  24435. utils.ErrorLog("解析失败:%v", err)
  24436. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24437. return
  24438. }
  24439. } else if miConfig.MdtrtareaAdmvs == "341203" {
  24440. var api3 string
  24441. api3 = miConfig.SecretKey + "ahyb/2205?psn_no=" + order.PsnNo +
  24442. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  24443. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  24444. resp3, requestErr3 := http.Get(api3)
  24445. if requestErr3 != nil {
  24446. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24447. return
  24448. }
  24449. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  24450. if ioErr3 != nil {
  24451. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  24452. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24453. return
  24454. }
  24455. var respJSON3 map[string]interface{}
  24456. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  24457. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24458. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24459. return
  24460. }
  24461. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  24462. if status == "0" {
  24463. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  24464. c.ServeSuccessJSON(map[string]interface{}{
  24465. "failed_code": -10,
  24466. "msg": err_msg,
  24467. })
  24468. return
  24469. }
  24470. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24471. userJSONBytes3, _ := json.Marshal(respJSON3)
  24472. fmt.Println("log")
  24473. fmt.Println(string(userJSONBytes3))
  24474. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  24475. utils.ErrorLog("解析失败:%v", err)
  24476. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24477. return
  24478. }
  24479. } else if miConfig.MdtrtareaAdmvs == "430800" {
  24480. 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, "")
  24481. var dat map[string]interface{}
  24482. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  24483. fmt.Println(dat)
  24484. } else {
  24485. fmt.Println(err)
  24486. }
  24487. saveLog(result2, src_request, "2205", "撤销明细")
  24488. userJSONBytes, _ := json.Marshal(dat)
  24489. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  24490. utils.ErrorLog("解析失败:%v", err)
  24491. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24492. return
  24493. }
  24494. } else if miConfig.MdtrtareaAdmvs == "441799" {
  24495. api3 := miConfig.Url + "gdyb/six?psn_no=" + order.PsnNo +
  24496. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  24497. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  24498. resp3, requestErr3 := http.Get(api3)
  24499. if requestErr3 != nil {
  24500. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24501. return
  24502. }
  24503. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  24504. if ioErr3 != nil {
  24505. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  24506. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24507. return
  24508. }
  24509. var respJSON3 map[string]interface{}
  24510. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  24511. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24512. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24513. return
  24514. }
  24515. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24516. userJSONBytes3, _ := json.Marshal(respJSON3)
  24517. fmt.Println("log")
  24518. fmt.Println(string(userJSONBytes3))
  24519. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  24520. utils.ErrorLog("解析失败:%v", err)
  24521. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24522. return
  24523. }
  24524. } else {
  24525. if miConfig.Code == "H15049901371" {
  24526. 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)
  24527. var dat map[string]interface{}
  24528. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  24529. fmt.Println(dat)
  24530. } else {
  24531. fmt.Println(err)
  24532. }
  24533. saveLog(result2, src_request, "2205", "撤销明细")
  24534. userJSONBytes, _ := json.Marshal(dat)
  24535. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  24536. utils.ErrorLog("解析失败:%v", err)
  24537. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24538. return
  24539. }
  24540. res2.InfRefmsgid = resSix10265.InfRefmsgid
  24541. res2.Output = resSix10265.Output
  24542. res2.ErrMsg = resSix10265.ErrMsg
  24543. res2.Cainfo = resSix10265.Cainfo
  24544. res2.WarnMsg = resSix10265.WarnMsg
  24545. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  24546. res2.Infcode = infocode
  24547. } else {
  24548. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  24549. res2.Infcode = 0
  24550. } else {
  24551. 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)
  24552. var dat map[string]interface{}
  24553. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  24554. fmt.Println(dat)
  24555. } else {
  24556. fmt.Println(err)
  24557. }
  24558. saveLog(result2, src_request, "2205", "撤销明细")
  24559. userJSONBytes, _ := json.Marshal(dat)
  24560. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  24561. utils.ErrorLog("解析失败:%v", err)
  24562. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24563. return
  24564. }
  24565. }
  24566. }
  24567. }
  24568. if res2.Infcode == -1 {
  24569. c.ServeSuccessJSON(map[string]interface{}{
  24570. "failed_code": -10,
  24571. "msg": res2.ErrMsg,
  24572. })
  24573. return
  24574. }
  24575. if res2.Infcode == 0 {
  24576. err := service.UpdataOrderStatus(order_id, order.Number, adminUser.CurrentOrgId, src_resquest, result)
  24577. if err == nil {
  24578. //当押金不为零时产生退费记录
  24579. if order.Decimal != 0 {
  24580. tmp := strconv.FormatInt(order.ID, 10)
  24581. err = service.MoneyIncrease(adminUser.CurrentOrgId, order.PatientId, tmp, order.Decimal)
  24582. if err != nil {
  24583. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24584. return
  24585. }
  24586. }
  24587. c.ServeSuccessJSON(map[string]interface{}{
  24588. "msg": "退费成功",
  24589. })
  24590. } else {
  24591. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24592. return
  24593. }
  24594. } else {
  24595. c.ServeSuccessJSON(map[string]interface{}{
  24596. "failed_code": -10,
  24597. "msg": res2.ErrMsg,
  24598. })
  24599. }
  24600. } else {
  24601. c.ServeSuccessJSON(map[string]interface{}{
  24602. "failed_code": -10,
  24603. "msg": res.ErrMsg,
  24604. })
  24605. }
  24606. }
  24607. }
  24608. func (c *HisApiController) RefundNumber() {
  24609. record_time := c.GetString("record_time")
  24610. //patient_id, _ := c.GetInt64("patient_id")
  24611. admin_user_id, _ := c.GetInt64("admin_user_id")
  24612. his_patient_id, _ := c.GetInt64("id")
  24613. timeLayout := "2006-01-02"
  24614. loc, _ := time.LoadLocation("Local")
  24615. adminUser := c.GetAdminUserInfo()
  24616. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  24617. fmt.Println(err)
  24618. if err != nil {
  24619. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  24620. return
  24621. }
  24622. recordDateTime := theTime.Unix()
  24623. //his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  24624. his, _ := service.GetHisPatientRecord(adminUser.CurrentOrgId, his_patient_id)
  24625. //patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  24626. //order, _ := service.GetHisOrderByID(order_id)
  24627. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  24628. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  24629. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  24630. count, _ := service.GetOrderCountByNumber(adminUser.CurrentOrgId, his.PatientId, recordDateTime, his.Number)
  24631. if count > 0 {
  24632. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeOrderParamWrong)
  24633. return
  24634. }
  24635. if config.IsOpen == 1 { //对接了医保,走医保流程
  24636. var res2 ResultSix
  24637. var res3 GZResultSix
  24638. var resSix10265 ResultSix10265
  24639. if miConfig.MdtrtareaAdmvs == "421300" {
  24640. api3 := "http://192.168.124.4:9532/" + "hbyb/2202?psn_no=" + his.PsnNo +
  24641. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  24642. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  24643. resp3, requestErr3 := http.Get(api3)
  24644. if requestErr3 != nil {
  24645. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24646. return
  24647. }
  24648. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  24649. if ioErr3 != nil {
  24650. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  24651. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24652. return
  24653. }
  24654. var respJSON3 map[string]interface{}
  24655. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  24656. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24657. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24658. return
  24659. }
  24660. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24661. userJSONBytes3, _ := json.Marshal(respJSON3)
  24662. fmt.Println("log")
  24663. fmt.Println(string(userJSONBytes3))
  24664. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  24665. utils.ErrorLog("解析失败:%v", err)
  24666. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24667. return
  24668. }
  24669. } else if miConfig.MdtrtareaAdmvs == "420200" {
  24670. api3 := "http://192.168.0.197:9532/" + "hbyb/2202?psn_no=" + his.PsnNo +
  24671. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  24672. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  24673. resp3, requestErr3 := http.Get(api3)
  24674. if requestErr3 != nil {
  24675. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24676. return
  24677. }
  24678. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  24679. if ioErr3 != nil {
  24680. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  24681. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24682. return
  24683. }
  24684. var respJSON3 map[string]interface{}
  24685. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  24686. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24687. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24688. return
  24689. }
  24690. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24691. userJSONBytes3, _ := json.Marshal(respJSON3)
  24692. fmt.Println("log")
  24693. fmt.Println(string(userJSONBytes3))
  24694. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  24695. utils.ErrorLog("解析失败:%v", err)
  24696. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24697. return
  24698. }
  24699. } else if miConfig.MdtrtareaAdmvs == "420902" {
  24700. api3 := miConfig.Url + "hbyb/2202?psn_no=" + his.PsnNo +
  24701. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  24702. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  24703. resp3, requestErr3 := http.Get(api3)
  24704. if requestErr3 != nil {
  24705. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24706. return
  24707. }
  24708. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  24709. if ioErr3 != nil {
  24710. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  24711. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24712. return
  24713. }
  24714. var respJSON3 map[string]interface{}
  24715. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  24716. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24717. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24718. return
  24719. }
  24720. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24721. userJSONBytes3, _ := json.Marshal(respJSON3)
  24722. fmt.Println("log")
  24723. fmt.Println(string(userJSONBytes3))
  24724. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  24725. utils.ErrorLog("解析失败:%v", err)
  24726. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24727. return
  24728. }
  24729. } else if miConfig.MdtrtareaAdmvs == "421182" {
  24730. api3 := miConfig.Url + "hbyb/2202?psn_no=" + his.PsnNo +
  24731. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  24732. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  24733. resp3, requestErr3 := http.Get(api3)
  24734. if requestErr3 != nil {
  24735. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24736. return
  24737. }
  24738. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  24739. if ioErr3 != nil {
  24740. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  24741. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24742. return
  24743. }
  24744. var respJSON3 map[string]interface{}
  24745. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  24746. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24747. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24748. return
  24749. }
  24750. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24751. userJSONBytes3, _ := json.Marshal(respJSON3)
  24752. fmt.Println("log")
  24753. fmt.Println(string(userJSONBytes3))
  24754. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  24755. utils.ErrorLog("解析失败:%v", err)
  24756. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24757. return
  24758. }
  24759. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  24760. var api3 string
  24761. if miConfig.MdtrtareaAdmvs == "320921" {
  24762. api3 = "http://192.168.2.3:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  24763. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  24764. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  24765. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  24766. } else {
  24767. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  24768. api3 = "http://192.168.5.251:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  24769. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  24770. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  24771. }
  24772. resp3, requestErr3 := http.Get(api3)
  24773. if requestErr3 != nil {
  24774. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24775. return
  24776. }
  24777. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  24778. if ioErr3 != nil {
  24779. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  24780. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24781. return
  24782. }
  24783. var respJSON3 map[string]interface{}
  24784. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  24785. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24786. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24787. return
  24788. }
  24789. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24790. userJSONBytes3, _ := json.Marshal(respJSON3)
  24791. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  24792. utils.ErrorLog("解析失败:%v", err)
  24793. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24794. return
  24795. }
  24796. res2.InfRefmsgid = resSix10265.InfRefmsgid
  24797. res2.Output = resSix10265.Output
  24798. res2.ErrMsg = resSix10265.ErrMsg
  24799. res2.Cainfo = resSix10265.Cainfo
  24800. res2.WarnMsg = resSix10265.WarnMsg
  24801. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  24802. res2.Infcode = infocode
  24803. } else if miConfig.MdtrtareaAdmvs == "150499" {
  24804. var api3 string
  24805. api3 = "http://172.16.13.254:9532/" + "nmyb/2202?psn_no=" + his.PsnNo +
  24806. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  24807. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  24808. resp3, requestErr3 := http.Get(api3)
  24809. if requestErr3 != nil {
  24810. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24811. return
  24812. }
  24813. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  24814. if ioErr3 != nil {
  24815. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  24816. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24817. return
  24818. }
  24819. var respJSON3 map[string]interface{}
  24820. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  24821. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24822. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24823. return
  24824. }
  24825. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24826. userJSONBytes3, _ := json.Marshal(respJSON3)
  24827. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  24828. utils.ErrorLog("解析失败:%v", err)
  24829. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24830. return
  24831. }
  24832. res2.InfRefmsgid = resSix10265.InfRefmsgid
  24833. res2.Output = resSix10265.Output
  24834. res2.ErrMsg = resSix10265.ErrMsg
  24835. res2.Cainfo = resSix10265.Cainfo
  24836. res2.WarnMsg = resSix10265.WarnMsg
  24837. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  24838. res2.Infcode = infocode
  24839. } else if miConfig.MdtrtareaAdmvs == "350500" {
  24840. 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)
  24841. var dat map[string]interface{}
  24842. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  24843. fmt.Println(dat)
  24844. } else {
  24845. fmt.Println(err)
  24846. }
  24847. saveLog(result, request, "2202", "退号")
  24848. userJSONBytes, _ := json.Marshal(dat)
  24849. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  24850. utils.ErrorLog("解析失败:%v", err)
  24851. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24852. return
  24853. }
  24854. } else if miConfig.MdtrtareaAdmvs == "360302" {
  24855. 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, "")
  24856. var dat map[string]interface{}
  24857. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  24858. fmt.Println(dat)
  24859. } else {
  24860. fmt.Println(err)
  24861. }
  24862. saveLog(result, request, "2202", "退号")
  24863. userJSONBytes, _ := json.Marshal(dat)
  24864. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  24865. utils.ErrorLog("解析失败:%v", err)
  24866. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24867. return
  24868. }
  24869. } else if miConfig.MdtrtareaAdmvs == "341203" {
  24870. var api3 string
  24871. api3 = miConfig.SecretKey + "ahyb/2202?psn_no=" + his.PsnNo +
  24872. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  24873. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  24874. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  24875. resp3, requestErr3 := http.Get(api3)
  24876. if requestErr3 != nil {
  24877. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24878. return
  24879. }
  24880. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  24881. if ioErr3 != nil {
  24882. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  24883. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24884. return
  24885. }
  24886. var respJSON3 map[string]interface{}
  24887. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  24888. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24889. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24890. return
  24891. }
  24892. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  24893. if status == "0" {
  24894. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  24895. c.ServeSuccessJSON(map[string]interface{}{
  24896. "failed_code": -10,
  24897. "msg": err_msg,
  24898. })
  24899. return
  24900. }
  24901. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24902. userJSONBytes3, _ := json.Marshal(respJSON3)
  24903. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  24904. utils.ErrorLog("解析失败:%v", err)
  24905. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24906. return
  24907. }
  24908. utils.ErrorLog("接口返回数据解析JSON失败: %v", res2.Infcode)
  24909. } else if miConfig.MdtrtareaAdmvs == "430800" {
  24910. 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, "")
  24911. var dat map[string]interface{}
  24912. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  24913. fmt.Println(dat)
  24914. } else {
  24915. fmt.Println(err)
  24916. }
  24917. saveLog(result, request, "2202", "退号")
  24918. userJSONBytes, _ := json.Marshal(dat)
  24919. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  24920. utils.ErrorLog("解析失败:%v", err)
  24921. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24922. return
  24923. }
  24924. } else if miConfig.MdtrtareaAdmvs == "441799" {
  24925. api3 := miConfig.Url + "gdyb/2202?psn_no=" + his.PsnNo +
  24926. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&operator=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  24927. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&admin_user_id=" + strconv.FormatInt(admin_user_id, 10)
  24928. resp3, requestErr3 := http.Get(api3)
  24929. if requestErr3 != nil {
  24930. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24931. return
  24932. }
  24933. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  24934. if ioErr3 != nil {
  24935. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  24936. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24937. return
  24938. }
  24939. var respJSON3 map[string]interface{}
  24940. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  24941. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24942. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24943. return
  24944. }
  24945. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24946. userJSONBytes3, _ := json.Marshal(respJSON3)
  24947. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  24948. utils.ErrorLog("解析失败:%v", err)
  24949. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24950. return
  24951. }
  24952. } else {
  24953. var api3 string
  24954. if miConfig.Code == "H15049901371" {
  24955. api3 = "http://127.0.0.1:9532/" + "gdyb/three?psn_no=" + his.PsnNo +
  24956. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  24957. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  24958. } else {
  24959. api3 = "http://127.0.0.1:9532/" + "gdyb/2202?psn_no=" + his.PsnNo +
  24960. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&operator=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  24961. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&admin_user_id=" + strconv.FormatInt(admin_user_id, 10)
  24962. }
  24963. resp3, requestErr3 := http.Get(api3)
  24964. if requestErr3 != nil {
  24965. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24966. return
  24967. }
  24968. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  24969. if ioErr3 != nil {
  24970. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  24971. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24972. return
  24973. }
  24974. var respJSON3 map[string]interface{}
  24975. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  24976. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24977. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24978. return
  24979. }
  24980. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24981. userJSONBytes3, _ := json.Marshal(respJSON3)
  24982. if miConfig.Code == "H15049901371" {
  24983. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  24984. utils.ErrorLog("解析失败:%v", err)
  24985. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24986. return
  24987. }
  24988. res2.InfRefmsgid = resSix10265.InfRefmsgid
  24989. res2.Output = resSix10265.Output
  24990. res2.ErrMsg = resSix10265.ErrMsg
  24991. res2.Cainfo = resSix10265.Cainfo
  24992. res2.WarnMsg = resSix10265.WarnMsg
  24993. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  24994. res2.Infcode = infocode
  24995. } else {
  24996. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  24997. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  24998. utils.ErrorLog("解析失败:%v", err)
  24999. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25000. return
  25001. }
  25002. res2.Infcode = res3.Infcode
  25003. } else {
  25004. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  25005. utils.ErrorLog("解析失败:%v", err)
  25006. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25007. return
  25008. }
  25009. }
  25010. }
  25011. }
  25012. if res2.Infcode == -1 {
  25013. utils.ErrorLog("解析失败:%v", res2.Infcode)
  25014. c.ServeSuccessJSON(map[string]interface{}{
  25015. "failed_code": -10,
  25016. "msg": res2.ErrMsg,
  25017. })
  25018. return
  25019. }
  25020. if res2.Infcode == 0 {
  25021. if err == nil {
  25022. c.ServeSuccessJSON(map[string]interface{}{
  25023. "msg": "退号成功",
  25024. })
  25025. service.UpdataRegStatusTwo(his_patient_id, recordDateTime, adminUser.CurrentOrgId)
  25026. } else {
  25027. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25028. return
  25029. }
  25030. }
  25031. } else {
  25032. //err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId)
  25033. //if err == nil {
  25034. // c.ServeSuccessJSON(map[string]interface{}{
  25035. // "msg": "退费成功",
  25036. // })
  25037. //} else {
  25038. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25039. // return
  25040. //}
  25041. }
  25042. }
  25043. func (c *HisApiController) RefundDetail() {
  25044. order_id, _ := c.GetInt64("order_id")
  25045. admin_user_id, _ := c.GetInt64("admin_user_id")
  25046. //his_patient_id, _ := c.GetInt64("his_patient_id")
  25047. number := c.GetString("number")
  25048. record_time := c.GetString("record_time")
  25049. patient_id, _ := c.GetInt64("patient_id")
  25050. //med_type, _ := c.GetInt64("med_type")
  25051. timeLayout := "2006-01-02"
  25052. loc, _ := time.LoadLocation("Local")
  25053. adminUser := c.GetAdminUserInfo()
  25054. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  25055. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  25056. fmt.Println(err)
  25057. if err != nil {
  25058. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  25059. return
  25060. }
  25061. recordDateTime := theTime.Unix()
  25062. //his, _ := service.GetNewVMHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  25063. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  25064. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  25065. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  25066. var order models.HisOrder
  25067. order, _ = service.GetHisOrderByID(order_id)
  25068. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  25069. if config.IsOpen == 1 { //对接了医保,走医保流程
  25070. var res2 ResultSix
  25071. if miConfig.MdtrtareaAdmvs == "421300" {
  25072. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  25073. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  25074. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  25075. resp3, requestErr3 := http.Get(api3)
  25076. if requestErr3 != nil {
  25077. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25078. return
  25079. }
  25080. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  25081. if ioErr3 != nil {
  25082. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  25083. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25084. return
  25085. }
  25086. var respJSON3 map[string]interface{}
  25087. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  25088. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25089. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25090. return
  25091. }
  25092. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25093. userJSONBytes3, _ := json.Marshal(respJSON3)
  25094. fmt.Println("log")
  25095. fmt.Println(string(userJSONBytes3))
  25096. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  25097. utils.ErrorLog("解析失败:%v", err)
  25098. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25099. return
  25100. }
  25101. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  25102. if err == nil {
  25103. c.ServeSuccessJSON(map[string]interface{}{
  25104. "msg": "撤销明细成功",
  25105. })
  25106. return
  25107. } else {
  25108. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25109. return
  25110. }
  25111. } else if miConfig.MdtrtareaAdmvs == "420200" {
  25112. api3 := "http://192.168.0.197:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  25113. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  25114. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  25115. resp3, requestErr3 := http.Get(api3)
  25116. if requestErr3 != nil {
  25117. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25118. return
  25119. }
  25120. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  25121. if ioErr3 != nil {
  25122. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  25123. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25124. return
  25125. }
  25126. var respJSON3 map[string]interface{}
  25127. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  25128. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25129. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25130. return
  25131. }
  25132. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25133. userJSONBytes3, _ := json.Marshal(respJSON3)
  25134. fmt.Println("log")
  25135. fmt.Println(string(userJSONBytes3))
  25136. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  25137. utils.ErrorLog("解析失败:%v", err)
  25138. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25139. return
  25140. }
  25141. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  25142. if err == nil {
  25143. c.ServeSuccessJSON(map[string]interface{}{
  25144. "msg": "撤销明细成功",
  25145. })
  25146. return
  25147. } else {
  25148. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25149. return
  25150. }
  25151. } else if miConfig.MdtrtareaAdmvs == "420902" {
  25152. api3 := miConfig.Url + "hbyb/2205?psn_no=" + order.PsnNo +
  25153. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  25154. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  25155. resp3, requestErr3 := http.Get(api3)
  25156. if requestErr3 != nil {
  25157. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25158. return
  25159. }
  25160. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  25161. if ioErr3 != nil {
  25162. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  25163. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25164. return
  25165. }
  25166. var respJSON3 map[string]interface{}
  25167. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  25168. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25169. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25170. return
  25171. }
  25172. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25173. userJSONBytes3, _ := json.Marshal(respJSON3)
  25174. fmt.Println("log")
  25175. fmt.Println(string(userJSONBytes3))
  25176. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  25177. utils.ErrorLog("解析失败:%v", err)
  25178. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25179. return
  25180. }
  25181. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  25182. if err == nil {
  25183. c.ServeSuccessJSON(map[string]interface{}{
  25184. "msg": "撤销明细成功",
  25185. })
  25186. return
  25187. } else {
  25188. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25189. return
  25190. }
  25191. } else if miConfig.MdtrtareaAdmvs == "421182" {
  25192. api3 := miConfig.Url + "hbyb/2205?psn_no=" + order.PsnNo +
  25193. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  25194. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  25195. resp3, requestErr3 := http.Get(api3)
  25196. if requestErr3 != nil {
  25197. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25198. return
  25199. }
  25200. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  25201. if ioErr3 != nil {
  25202. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  25203. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25204. return
  25205. }
  25206. var respJSON3 map[string]interface{}
  25207. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  25208. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25209. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25210. return
  25211. }
  25212. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25213. userJSONBytes3, _ := json.Marshal(respJSON3)
  25214. fmt.Println("log")
  25215. fmt.Println(string(userJSONBytes3))
  25216. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  25217. utils.ErrorLog("解析失败:%v", err)
  25218. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25219. return
  25220. }
  25221. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  25222. if err == nil {
  25223. c.ServeSuccessJSON(map[string]interface{}{
  25224. "msg": "撤销明细成功",
  25225. })
  25226. return
  25227. } else {
  25228. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25229. return
  25230. }
  25231. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  25232. var resSix10265 ResultSix10265
  25233. var api3 string
  25234. if miConfig.MdtrtareaAdmvs == "320921" {
  25235. api3 = "http://192.168.2.3:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  25236. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  25237. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  25238. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  25239. } else {
  25240. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  25241. api3 = "http://192.168.5.251:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  25242. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  25243. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  25244. }
  25245. resp3, requestErr3 := http.Get(api3)
  25246. utils.ErrorLog("接口: %v", requestErr3)
  25247. if requestErr3 != nil {
  25248. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25249. return
  25250. }
  25251. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  25252. if ioErr3 != nil {
  25253. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  25254. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25255. return
  25256. }
  25257. var respJSON3 map[string]interface{}
  25258. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  25259. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25260. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25261. return
  25262. }
  25263. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25264. userJSONBytes3, _ := json.Marshal(respJSON3)
  25265. fmt.Println("log")
  25266. fmt.Println(string(userJSONBytes3))
  25267. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  25268. utils.ErrorLog("解析失败:%v", err)
  25269. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25270. return
  25271. }
  25272. res2.InfRefmsgid = resSix10265.InfRefmsgid
  25273. res2.Output = resSix10265.Output
  25274. res2.ErrMsg = resSix10265.ErrMsg
  25275. res2.Cainfo = resSix10265.Cainfo
  25276. res2.WarnMsg = resSix10265.WarnMsg
  25277. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  25278. res2.Infcode = infocode
  25279. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  25280. if err == nil {
  25281. c.ServeSuccessJSON(map[string]interface{}{
  25282. "msg": "撤销明细成功",
  25283. })
  25284. return
  25285. } else {
  25286. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25287. return
  25288. }
  25289. } else if miConfig.MdtrtareaAdmvs == "341203" {
  25290. var api3 string
  25291. api3 = miConfig.SecretKey + "ahyb/2205?psn_no=" + order.PsnNo +
  25292. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  25293. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  25294. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  25295. resp3, requestErr3 := http.Get(api3)
  25296. utils.ErrorLog("接口: %v", requestErr3)
  25297. if requestErr3 != nil {
  25298. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25299. return
  25300. }
  25301. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  25302. if ioErr3 != nil {
  25303. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  25304. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25305. return
  25306. }
  25307. var respJSON3 map[string]interface{}
  25308. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  25309. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25310. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25311. return
  25312. }
  25313. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  25314. if status == "0" {
  25315. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  25316. c.ServeSuccessJSON(map[string]interface{}{
  25317. "failed_code": -10,
  25318. "msg": err_msg,
  25319. })
  25320. return
  25321. }
  25322. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25323. userJSONBytes3, _ := json.Marshal(respJSON3)
  25324. fmt.Println("log")
  25325. fmt.Println(string(userJSONBytes3))
  25326. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  25327. utils.ErrorLog("解析失败:%v", err)
  25328. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25329. return
  25330. }
  25331. fmt.Println(res2.Infcode)
  25332. if res2.Infcode == -1 {
  25333. c.ServeSuccessJSON(map[string]interface{}{
  25334. "failed_code": -10,
  25335. "msg": res2.ErrMsg,
  25336. })
  25337. return
  25338. }
  25339. if res2.Infcode == 0 {
  25340. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  25341. if err == nil {
  25342. c.ServeSuccessJSON(map[string]interface{}{
  25343. "msg": "撤销明细成功",
  25344. })
  25345. return
  25346. } else {
  25347. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25348. return
  25349. }
  25350. } else {
  25351. c.ServeSuccessJSON(map[string]interface{}{
  25352. "failed_code": -10,
  25353. "msg": res2.ErrMsg,
  25354. })
  25355. }
  25356. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  25357. if err == nil {
  25358. c.ServeSuccessJSON(map[string]interface{}{
  25359. "msg": "撤销明细成功",
  25360. })
  25361. return
  25362. } else {
  25363. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25364. return
  25365. }
  25366. } else if miConfig.MdtrtareaAdmvs == "150499" {
  25367. var resSix10265 ResultSix10265
  25368. var api3 string
  25369. api3 = "http://172.16.13.254:9532/" + "nmyb/2205?psn_no=" + order.PsnNo +
  25370. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  25371. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  25372. resp3, requestErr3 := http.Get(api3)
  25373. if requestErr3 != nil {
  25374. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25375. return
  25376. }
  25377. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  25378. if ioErr3 != nil {
  25379. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  25380. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25381. return
  25382. }
  25383. var respJSON3 map[string]interface{}
  25384. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  25385. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25386. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25387. return
  25388. }
  25389. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25390. userJSONBytes3, _ := json.Marshal(respJSON3)
  25391. fmt.Println("log")
  25392. fmt.Println(string(userJSONBytes3))
  25393. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  25394. utils.ErrorLog("解析失败:%v", err)
  25395. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25396. return
  25397. }
  25398. res2.InfRefmsgid = resSix10265.InfRefmsgid
  25399. res2.Output = resSix10265.Output
  25400. res2.ErrMsg = resSix10265.ErrMsg
  25401. res2.Cainfo = resSix10265.Cainfo
  25402. res2.WarnMsg = resSix10265.WarnMsg
  25403. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  25404. res2.Infcode = infocode
  25405. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  25406. if err == nil {
  25407. c.ServeSuccessJSON(map[string]interface{}{
  25408. "msg": "撤销明细成功",
  25409. })
  25410. return
  25411. } else {
  25412. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25413. return
  25414. }
  25415. } else if miConfig.MdtrtareaAdmvs == "350500" {
  25416. 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)
  25417. var dat map[string]interface{}
  25418. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  25419. fmt.Println(dat)
  25420. } else {
  25421. fmt.Println(err)
  25422. }
  25423. saveLog(result2, src_request, "2205", "撤销明细")
  25424. userJSONBytes, _ := json.Marshal(dat)
  25425. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  25426. utils.ErrorLog("解析失败:%v", err)
  25427. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25428. return
  25429. }
  25430. if res2.Infcode == 0 {
  25431. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  25432. if err == nil {
  25433. c.ServeSuccessJSON(map[string]interface{}{
  25434. "msg": "撤销明细成功",
  25435. })
  25436. return
  25437. } else {
  25438. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25439. return
  25440. }
  25441. } else {
  25442. c.ServeSuccessJSON(map[string]interface{}{
  25443. "failed_code": -10,
  25444. "msg": res2.ErrMsg,
  25445. })
  25446. }
  25447. } else if miConfig.MdtrtareaAdmvs == "360302" {
  25448. 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, "")
  25449. var dat map[string]interface{}
  25450. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  25451. fmt.Println(dat)
  25452. } else {
  25453. fmt.Println(err)
  25454. }
  25455. saveLog(result2, src_request, "2205", "撤销明细")
  25456. userJSONBytes, _ := json.Marshal(dat)
  25457. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  25458. utils.ErrorLog("解析失败:%v", err)
  25459. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25460. return
  25461. }
  25462. if res2.Infcode == 0 {
  25463. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  25464. if err == nil {
  25465. c.ServeSuccessJSON(map[string]interface{}{
  25466. "msg": "撤销明细成功",
  25467. })
  25468. return
  25469. } else {
  25470. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25471. return
  25472. }
  25473. } else {
  25474. c.ServeSuccessJSON(map[string]interface{}{
  25475. "failed_code": -10,
  25476. "msg": res2.ErrMsg,
  25477. })
  25478. }
  25479. } else if miConfig.MdtrtareaAdmvs == "430800" {
  25480. 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, "")
  25481. var dat map[string]interface{}
  25482. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  25483. fmt.Println(dat)
  25484. } else {
  25485. fmt.Println(err)
  25486. }
  25487. saveLog(result2, src_request, "2205", "撤销明细")
  25488. userJSONBytes, _ := json.Marshal(dat)
  25489. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  25490. utils.ErrorLog("解析失败:%v", err)
  25491. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25492. return
  25493. }
  25494. if res2.Infcode == 0 {
  25495. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  25496. if err == nil {
  25497. c.ServeSuccessJSON(map[string]interface{}{
  25498. "msg": "撤销明细成功",
  25499. })
  25500. return
  25501. } else {
  25502. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25503. return
  25504. }
  25505. } else {
  25506. c.ServeSuccessJSON(map[string]interface{}{
  25507. "failed_code": -10,
  25508. "msg": res2.ErrMsg,
  25509. })
  25510. }
  25511. } else if miConfig.MdtrtareaAdmvs == "441799" {
  25512. api2 := miConfig.Url + "gdyb/six?psn_no=" + his.PsnNo +
  25513. "&mdtrt_id=" + his.Number + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  25514. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  25515. resp2, requestErr2 := http.Get(api2)
  25516. if requestErr2 != nil {
  25517. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25518. return
  25519. }
  25520. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  25521. if ioErr2 != nil {
  25522. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  25523. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25524. return
  25525. }
  25526. var respJSON2 map[string]interface{}
  25527. if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  25528. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25529. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25530. return
  25531. }
  25532. respJSON2 = respJSON2["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25533. userJSONBytes3, _ := json.Marshal(respJSON2)
  25534. fmt.Println("log")
  25535. fmt.Println(string(userJSONBytes3))
  25536. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  25537. utils.ErrorLog("解析失败:%v", err)
  25538. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25539. return
  25540. }
  25541. if res2.Infcode == 0 {
  25542. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  25543. if err == nil {
  25544. c.ServeSuccessJSON(map[string]interface{}{
  25545. "msg": "撤销明细成功",
  25546. })
  25547. return
  25548. } else {
  25549. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25550. return
  25551. }
  25552. } else {
  25553. c.ServeSuccessJSON(map[string]interface{}{
  25554. "failed_code": -10,
  25555. "msg": res2.ErrMsg,
  25556. })
  25557. }
  25558. } else {
  25559. api2 := "http://127.0.0.1:9532/" + "gdyb/six?psn_no=" + his.PsnNo +
  25560. "&mdtrt_id=" + his.Number + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  25561. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&admin_user_id=" + strconv.FormatInt(admin_user_id, 10)
  25562. resp2, requestErr2 := http.Get(api2)
  25563. if requestErr2 != nil {
  25564. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25565. return
  25566. }
  25567. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  25568. if ioErr2 != nil {
  25569. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  25570. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25571. return
  25572. }
  25573. var respJSON2 map[string]interface{}
  25574. if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  25575. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25576. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25577. return
  25578. }
  25579. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  25580. if err == nil {
  25581. c.ServeSuccessJSON(map[string]interface{}{
  25582. "msg": "撤销明细成功",
  25583. })
  25584. return
  25585. } else {
  25586. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25587. return
  25588. }
  25589. }
  25590. } else {
  25591. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  25592. if err == nil {
  25593. c.ServeSuccessJSON(map[string]interface{}{
  25594. "msg": "退费成功",
  25595. })
  25596. } else {
  25597. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25598. return
  25599. }
  25600. }
  25601. }
  25602. // 对账
  25603. func (c *HisApiController) GetCheckAccount() {
  25604. start_time := c.GetString("start_time")
  25605. end_time := c.GetString("end_time")
  25606. insutype := c.GetString("insutype")
  25607. clr_type := c.GetString("clr_type")
  25608. clr_org := c.GetString("clr_optins")
  25609. admin_user_id, _ := c.GetInt64("admin_user_id")
  25610. adminUser := c.GetAdminUserInfo()
  25611. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  25612. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  25613. if len(clr_org) == 0 {
  25614. clr_org = miConfig.InsuplcAdmdvs
  25615. }
  25616. timeLayout := "2006-01-02"
  25617. loc, _ := time.LoadLocation("Local")
  25618. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  25619. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  25620. orders, _ := service.GetOrderByTime(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type, miConfig.MdtrtareaAdmvs)
  25621. orders_two, _ := service.GetOrderByTimeFive(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type, miConfig.MdtrtareaAdmvs)
  25622. fixmedins_setl_cnt := int64(len(orders))
  25623. var medfee_sumamt float64
  25624. var acct_pay float64
  25625. var fund_pay_sumamt float64
  25626. for _, item := range orders {
  25627. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  25628. acct_pay = acct_pay + item.AcctPay
  25629. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  25630. }
  25631. var user_name string
  25632. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  25633. if role.ID == 0 {
  25634. user_name = "xxx"
  25635. } else {
  25636. user_name = role.UserName
  25637. }
  25638. var res ResultEight
  25639. var res10188 ResultEightFor10188
  25640. if config.IsOpen == 1 {
  25641. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  25642. api := "http://192.168.2.3:9532/" + "jsyb/3201?" +
  25643. "insutype=" + insutype +
  25644. "&clr_type=" + clr_type +
  25645. "&setl_optins=" + clr_org +
  25646. "&stmt_begndate=" + start_time +
  25647. "&stm_enddate=" + end_time +
  25648. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  25649. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  25650. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  25651. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt+int64(len(orders_two)*2), 10) +
  25652. "&fixmedins_code=" + miConfig.Code +
  25653. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  25654. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  25655. "&secret_key=" + miConfig.SecretKey +
  25656. "&org_name=" + miConfig.OrgName +
  25657. "&doctor=" + user_name +
  25658. "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  25659. fmt.Println(api)
  25660. resp, requestErr := http.Get(api)
  25661. if requestErr != nil {
  25662. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25663. return
  25664. }
  25665. body, ioErr := ioutil.ReadAll(resp.Body)
  25666. fmt.Println(body)
  25667. if ioErr != nil {
  25668. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25669. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25670. return
  25671. }
  25672. var respJSON map[string]interface{}
  25673. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  25674. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25675. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25676. return
  25677. }
  25678. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25679. userJSONBytes, _ := json.Marshal(respJSON)
  25680. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  25681. utils.ErrorLog("解析失败:%v", err)
  25682. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25683. return
  25684. }
  25685. res.InfRefmsgid = res10188.InfRefmsgid
  25686. res.Output = res10188.Output
  25687. res.ErrMsg = res10188.ErrMsg
  25688. res.Cainfo = res10188.Cainfo
  25689. res.WarnMsg = res10188.WarnMsg
  25690. infocode, _ := strconv.ParseInt(res10188.Infcode, 10, 64)
  25691. res.Infcode = infocode
  25692. } else if miConfig.MdtrtareaAdmvs == "150499" {
  25693. if clr_type != "9903" {
  25694. clr_type = "99" // 就诊 ID(来自2201接口返回)
  25695. }
  25696. api := "http://172.16.13.254:9532/" + "nmyb/3201?" +
  25697. "insutype=" + insutype +
  25698. "&clr_type=" + clr_type +
  25699. "&setl_optins=" + clr_org +
  25700. "&stmt_begndate=" + start_time +
  25701. "&stm_enddate=" + end_time +
  25702. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  25703. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  25704. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  25705. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt+int64(len(orders_two)*2), 10) +
  25706. "&fixmedins_code=" + miConfig.Code +
  25707. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  25708. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  25709. "&secret_key=" + miConfig.SecretKey +
  25710. "&org_name=" + miConfig.OrgName +
  25711. "&doctor=" + user_name
  25712. resp, requestErr := http.Get(api)
  25713. if requestErr != nil {
  25714. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25715. return
  25716. }
  25717. body, ioErr := ioutil.ReadAll(resp.Body)
  25718. if ioErr != nil {
  25719. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25720. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25721. return
  25722. }
  25723. var respJSON map[string]interface{}
  25724. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  25725. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25726. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25727. return
  25728. }
  25729. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25730. result, _ := json.Marshal(respJSON)
  25731. fmt.Println("log")
  25732. fmt.Println(string(result))
  25733. if err := json.Unmarshal([]byte(result), &res10188); err != nil {
  25734. utils.ErrorLog("解析失败:%v", err)
  25735. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25736. return
  25737. }
  25738. res.InfRefmsgid = res10188.InfRefmsgid
  25739. res.Output = res10188.Output
  25740. res.ErrMsg = res10188.ErrMsg
  25741. res.Cainfo = res10188.Cainfo
  25742. res.WarnMsg = res10188.WarnMsg
  25743. infocode, _ := strconv.ParseInt(res10188.Infcode, 10, 64)
  25744. res.Infcode = infocode
  25745. } else if miConfig.MdtrtareaAdmvs == "350500" {
  25746. var baseParams models.BaseParams
  25747. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  25748. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  25749. baseParams.SecretKey = miConfig.SecretKey
  25750. baseParams.OrgName = miConfig.OrgName
  25751. baseParams.FixmedinsCode = miConfig.Code
  25752. baseParams.EncKey = miConfig.EncKey
  25753. baseParams.AppSecret = miConfig.AppSecret
  25754. baseParams.SignKey = miConfig.SignKey
  25755. baseParams.AppID = miConfig.Code
  25756. baseParams.Doctor = role.UserName
  25757. baseParams.RequestUrl = miConfig.Url
  25758. businessParams := models.BusinessParams{
  25759. Insutype: insutype,
  25760. ClrType: clr_type,
  25761. SetlOptins: clr_org,
  25762. StmtBegndate: start_time,
  25763. StmtEnddate: end_time,
  25764. MedfeeSumamt: medfee_sumamt,
  25765. FundPaySumamt: fund_pay_sumamt,
  25766. AcctPay: acct_pay,
  25767. FixmedinsSetlCnt: fixmedins_setl_cnt,
  25768. }
  25769. result, requestLog, err_msg := service.FJyb3201(baseParams, businessParams, fmt.Sprintf("%.4f", medfee_sumamt), fmt.Sprintf("%.4f", fund_pay_sumamt), fmt.Sprintf("%.4f", acct_pay))
  25770. fmt.Println(requestLog)
  25771. fmt.Println(result)
  25772. fmt.Println(err_msg)
  25773. var dat map[string]interface{}
  25774. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  25775. fmt.Println(dat)
  25776. } else {
  25777. fmt.Println(err)
  25778. }
  25779. userJSONBytes, _ := json.Marshal(dat)
  25780. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  25781. utils.ErrorLog("解析失败:%v", err)
  25782. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25783. return
  25784. }
  25785. } else if miConfig.MdtrtareaAdmvs == "430800" {
  25786. var baseParams models.BaseParams
  25787. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  25788. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  25789. baseParams.SecretKey = miConfig.SecretKey
  25790. baseParams.OrgName = miConfig.OrgName
  25791. baseParams.FixmedinsCode = miConfig.Code
  25792. baseParams.EncKey = miConfig.EncKey
  25793. baseParams.AppSecret = miConfig.AppSecret
  25794. baseParams.SignKey = miConfig.SignKey
  25795. baseParams.AppID = miConfig.Code
  25796. baseParams.Doctor = role.UserName
  25797. baseParams.RequestUrl = miConfig.Url
  25798. baseParams.AccessKey = miConfig.AccessKey
  25799. businessParams := models.BusinessParams{
  25800. Insutype: insutype,
  25801. ClrType: clr_type,
  25802. SetlOptins: "430822",
  25803. StmtBegndate: start_time,
  25804. StmtEnddate: end_time,
  25805. MedfeeSumamt: medfee_sumamt,
  25806. FundPaySumamt: fund_pay_sumamt,
  25807. AcctPay: acct_pay,
  25808. FixmedinsSetlCnt: fixmedins_setl_cnt,
  25809. }
  25810. 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)
  25811. fmt.Println(requestLog)
  25812. fmt.Println(result)
  25813. var dat map[string]interface{}
  25814. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  25815. fmt.Println(dat)
  25816. } else {
  25817. fmt.Println(err)
  25818. }
  25819. userJSONBytes, _ := json.Marshal(dat)
  25820. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  25821. utils.ErrorLog("解析失败:%v", err)
  25822. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25823. return
  25824. }
  25825. } else if miConfig.MdtrtareaAdmvs == "350500" {
  25826. var baseParams models.BaseParams
  25827. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  25828. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  25829. baseParams.SecretKey = miConfig.SecretKey
  25830. baseParams.OrgName = miConfig.OrgName
  25831. baseParams.FixmedinsCode = miConfig.Code
  25832. baseParams.EncKey = miConfig.EncKey
  25833. baseParams.AppSecret = miConfig.AppSecret
  25834. baseParams.SignKey = miConfig.SignKey
  25835. baseParams.AppID = miConfig.Code
  25836. baseParams.Doctor = role.UserName
  25837. baseParams.RequestUrl = miConfig.Url
  25838. businessParams := models.BusinessParams{
  25839. Insutype: insutype,
  25840. ClrType: clr_type,
  25841. SetlOptins: clr_org,
  25842. StmtBegndate: start_time,
  25843. StmtEnddate: end_time,
  25844. MedfeeSumamt: medfee_sumamt,
  25845. FundPaySumamt: fund_pay_sumamt,
  25846. AcctPay: acct_pay,
  25847. FixmedinsSetlCnt: fixmedins_setl_cnt,
  25848. }
  25849. result, requestLog, err_msg := service.FJyb3201(baseParams, businessParams, fmt.Sprintf("%.4f", medfee_sumamt), fmt.Sprintf("%.4f", fund_pay_sumamt), fmt.Sprintf("%.4f", acct_pay))
  25850. fmt.Println(requestLog)
  25851. fmt.Println(result)
  25852. fmt.Println(err_msg)
  25853. var dat map[string]interface{}
  25854. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  25855. fmt.Println(dat)
  25856. } else {
  25857. fmt.Println(err)
  25858. }
  25859. userJSONBytes, _ := json.Marshal(dat)
  25860. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  25861. utils.ErrorLog("解析失败:%v", err)
  25862. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25863. return
  25864. }
  25865. } else if miConfig.MdtrtareaAdmvs == "441799" {
  25866. if len(clr_type) == 0 {
  25867. clr_type = "11"
  25868. }
  25869. api := miConfig.Url + "gdyb/ten?" +
  25870. "insutype=" + insutype +
  25871. "&clr_type=" + clr_type +
  25872. "&setl_optins=" + clr_org +
  25873. "&stmt_begndate=" + start_time +
  25874. "&stm_enddate=" + end_time +
  25875. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  25876. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  25877. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  25878. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  25879. "&fixmedins_code=" + miConfig.Code +
  25880. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  25881. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  25882. "&secret_key=" + miConfig.SecretKey +
  25883. "&org_name=" + miConfig.OrgName +
  25884. "&doctor=" + user_name
  25885. fmt.Println(api)
  25886. resp, requestErr := http.Get(api)
  25887. if requestErr != nil {
  25888. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25889. return
  25890. }
  25891. body, ioErr := ioutil.ReadAll(resp.Body)
  25892. fmt.Println(body)
  25893. if ioErr != nil {
  25894. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25895. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25896. return
  25897. }
  25898. var respJSON map[string]interface{}
  25899. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  25900. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25901. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25902. return
  25903. }
  25904. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25905. userJSONBytes, _ := json.Marshal(respJSON)
  25906. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  25907. utils.ErrorLog("解析失败:%v", err)
  25908. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25909. return
  25910. }
  25911. } else if miConfig.MdtrtareaAdmvs == "360302" {
  25912. var baseParams models.BaseParams
  25913. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  25914. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  25915. baseParams.SecretKey = miConfig.SecretKey
  25916. baseParams.OrgName = miConfig.OrgName
  25917. baseParams.FixmedinsCode = miConfig.Code
  25918. baseParams.EncKey = miConfig.EncKey
  25919. baseParams.AppSecret = miConfig.AppSecret
  25920. baseParams.SignKey = miConfig.SignKey
  25921. baseParams.AppID = miConfig.Code
  25922. baseParams.Doctor = role.UserName
  25923. baseParams.RequestUrl = miConfig.Url
  25924. if clr_type == "9903" {
  25925. clr_type = "9901"
  25926. }
  25927. businessParams := models.BusinessParams{
  25928. Insutype: insutype,
  25929. ClrType: clr_type,
  25930. SetlOptins: "360302",
  25931. StmtBegndate: start_time,
  25932. StmtEnddate: end_time,
  25933. MedfeeSumamt: 0,
  25934. FundPaySumamt: 0,
  25935. AcctPay: 0,
  25936. FixmedinsSetlCnt: fixmedins_setl_cnt,
  25937. }
  25938. 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))
  25939. fmt.Println(requestLog)
  25940. fmt.Println(result)
  25941. var dat map[string]interface{}
  25942. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  25943. fmt.Println(dat)
  25944. } else {
  25945. fmt.Println(err)
  25946. }
  25947. userJSONBytes, _ := json.Marshal(dat)
  25948. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  25949. utils.ErrorLog("解析失败:%v", err)
  25950. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25951. return
  25952. }
  25953. } else if miConfig.MdtrtareaAdmvs == "341203" {
  25954. var api string
  25955. api = miConfig.SecretKey + "ahyb/3201?insutype=" + insutype +
  25956. "&clr_type=" + clr_type +
  25957. "&setl_optins=" + clr_org +
  25958. "&stmt_begndate=" + start_time +
  25959. "&stm_enddate=" + end_time +
  25960. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  25961. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  25962. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  25963. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt+int64(len(orders_two)*2), 10) +
  25964. "&fixmedins_code=" + miConfig.Code +
  25965. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  25966. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  25967. "&secret_key=" + miConfig.SecretKey +
  25968. "&org_name=" + miConfig.OrgName +
  25969. "&doctor=" + user_name + "&url=" + miConfig.Url
  25970. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  25971. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  25972. resp, requestErr := http.Get(api)
  25973. if requestErr != nil {
  25974. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25975. return
  25976. }
  25977. body, ioErr := ioutil.ReadAll(resp.Body)
  25978. if ioErr != nil {
  25979. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25980. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25981. return
  25982. }
  25983. var respJSON map[string]interface{}
  25984. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  25985. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25986. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25987. return
  25988. }
  25989. status := respJSON["data"].(map[string]interface{})["status"].(string)
  25990. if status == "0" {
  25991. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  25992. c.ServeSuccessJSON(map[string]interface{}{
  25993. "failed_code": -10,
  25994. "msg": err_msg,
  25995. })
  25996. return
  25997. }
  25998. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25999. userJSONBytes, _ := json.Marshal(respJSON)
  26000. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  26001. utils.ErrorLog("解析失败:%v", err)
  26002. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26003. return
  26004. }
  26005. } else {
  26006. if len(clr_type) == 0 {
  26007. clr_type = "11"
  26008. }
  26009. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  26010. "insutype=" + insutype +
  26011. "&clr_type=" + clr_type +
  26012. "&setl_optins=" + clr_org +
  26013. "&stmt_begndate=" + start_time +
  26014. "&stm_enddate=" + end_time +
  26015. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  26016. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  26017. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  26018. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  26019. "&fixmedins_code=" + miConfig.Code +
  26020. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  26021. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  26022. "&secret_key=" + miConfig.SecretKey +
  26023. "&org_name=" + miConfig.OrgName +
  26024. "&doctor=" + user_name + "&admin_user_id=" + strconv.FormatInt(admin_user_id, 10)
  26025. fmt.Println(api)
  26026. resp, requestErr := http.Get(api)
  26027. if requestErr != nil {
  26028. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26029. return
  26030. }
  26031. body, ioErr := ioutil.ReadAll(resp.Body)
  26032. fmt.Println(body)
  26033. if ioErr != nil {
  26034. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26035. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26036. return
  26037. }
  26038. var respJSON map[string]interface{}
  26039. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  26040. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26041. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26042. return
  26043. }
  26044. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26045. userJSONBytes, _ := json.Marshal(respJSON)
  26046. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  26047. utils.ErrorLog("解析失败:%v", err)
  26048. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26049. return
  26050. }
  26051. }
  26052. if res.Infcode == 0 {
  26053. if res.Output.Stmtinfo.StmtRslt == "0" {
  26054. micc := &models.MedicalInsuranceCostCompare{
  26055. StartTime: startime.Unix(),
  26056. EndTime: endtime.Unix(),
  26057. Insutype: insutype,
  26058. CheckType: 1,
  26059. Num: fixmedins_setl_cnt,
  26060. Mtime: time.Now().Unix(),
  26061. Status: 1,
  26062. UserOrgId: adminUser.CurrentOrgId,
  26063. CostTotal: medfee_sumamt,
  26064. FuncTotal: fund_pay_sumamt,
  26065. PsnPay: acct_pay,
  26066. Creator: admin_user_id,
  26067. Ctime: time.Now().Unix(),
  26068. ClrType: clr_type,
  26069. }
  26070. err := service.CreateMedicalInsuranceCostCompareRecord(micc)
  26071. if err == nil {
  26072. c.ServeSuccessJSON(map[string]interface{}{
  26073. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  26074. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  26075. })
  26076. } else {
  26077. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26078. }
  26079. } else {
  26080. c.ServeSuccessJSON(map[string]interface{}{
  26081. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  26082. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  26083. })
  26084. }
  26085. } else {
  26086. c.ServeSuccessJSON(map[string]interface{}{
  26087. "failed_code": -10,
  26088. "msg": res.ErrMsg,
  26089. })
  26090. }
  26091. }
  26092. }
  26093. func (c *HisApiController) Check310() {
  26094. adminUser := c.GetAdminUserInfo()
  26095. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  26096. var user_name string
  26097. user_name = "高慧裕"
  26098. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  26099. "insutype=" + "310" +
  26100. "&clr_type=" + "" +
  26101. "&setl_optins=" + "441202" +
  26102. "&stmt_begndate=" + "2022-03-01" +
  26103. "&stm_enddate=" + "2022-03-31" +
  26104. "&medfee_sumamt=" + "194930.12" +
  26105. "&fund_pay_sumamt=" + "188741.46" +
  26106. "&acct_pay=" + "0" +
  26107. "&fixmedins_setl_cnt=" + "452" +
  26108. "&fixmedins_code=" + miConfig.Code +
  26109. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  26110. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  26111. "&secret_key=" + miConfig.SecretKey +
  26112. "&org_name=" + miConfig.OrgName +
  26113. "&doctor=" + user_name
  26114. fmt.Println(api)
  26115. resp, requestErr := http.Get(api)
  26116. if requestErr != nil {
  26117. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26118. return
  26119. }
  26120. body, ioErr := ioutil.ReadAll(resp.Body)
  26121. fmt.Println(body)
  26122. if ioErr != nil {
  26123. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26124. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26125. return
  26126. }
  26127. var respJSON map[string]interface{}
  26128. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  26129. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26130. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26131. return
  26132. }
  26133. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26134. userJSONBytes, _ := json.Marshal(respJSON)
  26135. var res ResultEight
  26136. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  26137. utils.ErrorLog("解析失败:%v", err)
  26138. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26139. return
  26140. }
  26141. }
  26142. func (c *HisApiController) Check390() {
  26143. adminUser := c.GetAdminUserInfo()
  26144. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  26145. var user_name string
  26146. user_name = "高慧裕"
  26147. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  26148. "insutype=" + "390" +
  26149. "&clr_type=" + "" +
  26150. "&setl_optins=" + "441202" +
  26151. "&stmt_begndate=" + "2022-03-01" +
  26152. "&stm_enddate=" + "2022-03-31" +
  26153. "&medfee_sumamt=" + "1068448.89" +
  26154. "&fund_pay_sumamt=" + "1014677.62" +
  26155. "&acct_pay=" + "0" +
  26156. "&fixmedins_setl_cnt=" + "1950" +
  26157. "&fixmedins_code=" + miConfig.Code +
  26158. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  26159. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  26160. "&secret_key=" + miConfig.SecretKey +
  26161. "&org_name=" + miConfig.OrgName +
  26162. "&doctor=" + user_name
  26163. fmt.Println(api)
  26164. resp, requestErr := http.Get(api)
  26165. if requestErr != nil {
  26166. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26167. return
  26168. }
  26169. body, ioErr := ioutil.ReadAll(resp.Body)
  26170. fmt.Println(body)
  26171. if ioErr != nil {
  26172. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26173. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26174. return
  26175. }
  26176. var respJSON map[string]interface{}
  26177. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  26178. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26179. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26180. return
  26181. }
  26182. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26183. userJSONBytes, _ := json.Marshal(respJSON)
  26184. var res ResultEight
  26185. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  26186. utils.ErrorLog("解析失败:%v", err)
  26187. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26188. return
  26189. }
  26190. }
  26191. // 对账明细
  26192. func (c *HisApiController) GetCheckDetailAccount() {
  26193. start_time := c.GetString("start_time")
  26194. end_time := c.GetString("end_time")
  26195. admin_user_id, _ := c.GetInt64("admin_user_id")
  26196. adminUser := c.GetAdminUserInfo()
  26197. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  26198. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  26199. timeLayout := "2006-01-02"
  26200. loc, _ := time.LoadLocation("Local")
  26201. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  26202. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  26203. orders, _ := service.GetOrderByTimeTwo(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  26204. rand.Seed(time.Now().UnixNano())
  26205. num := rand.Intn(30000)
  26206. Mkdir(miConfig.OrgName)
  26207. file := strconv.FormatInt(int64(num), 10)
  26208. file_name := file + ".txt"
  26209. zip_name := file + ".zip"
  26210. zip_path := miConfig.OrgName + "/" + zip_name
  26211. file_path := miConfig.OrgName + "/" + file_name
  26212. decimal.DivisionPrecision = 2
  26213. var medfee_sumamt float64
  26214. var psn_cash_pay float64
  26215. var fund_pay_sumamt float64
  26216. fixmedins_setl_cnt := int64(len(orders))
  26217. for _, item := range orders {
  26218. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  26219. psn_cash_pay = psn_cash_pay + item.PsnCashPay
  26220. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  26221. }
  26222. f, err := os.Create(miConfig.OrgName + "/" + file_name)
  26223. defer f.Close()
  26224. if err != nil {
  26225. fmt.Println(err.Error())
  26226. } else {
  26227. for _, item := range orders {
  26228. var refd_setl_flag string
  26229. if item.OrderStatus == 2 {
  26230. refd_setl_flag = "0"
  26231. var str string
  26232. str = item.SetlId + " " +
  26233. item.MdtrtId + " " +
  26234. item.PsnNo + " " +
  26235. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  26236. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  26237. fmt.Sprintf("%.4f", item.AcctPay) + " " + refd_setl_flag + "\r\n"
  26238. _, err = f.Write([]byte(str))
  26239. }
  26240. if item.OrderStatus == 3 {
  26241. var str string
  26242. str = item.SetlId + " " +
  26243. item.MdtrtId + " " +
  26244. item.PsnNo + " " +
  26245. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  26246. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  26247. fmt.Sprintf("%.4f", item.AcctPay) + " " + "1" + "\r\n"
  26248. _, err = f.Write([]byte(str))
  26249. var str2 string
  26250. str2 = item.SetlId + " " +
  26251. item.MdtrtId + " " +
  26252. item.PsnNo + " " +
  26253. fmt.Sprintf("%.4f", 0-item.MedfeeSumamt) + " " +
  26254. fmt.Sprintf("%.4f", 0-item.FundPaySumamt) + " " +
  26255. fmt.Sprintf("%.4f", 0-item.AcctPay) + " " + "1" + "\r\n"
  26256. _, err = f.Write([]byte(str2))
  26257. }
  26258. }
  26259. }
  26260. Zip(file_path, zip_path)
  26261. fmt.Println(ReadFile(zip_path))
  26262. fmt.Println(string(ReadFile(zip_path)))
  26263. if config.IsOpen == 1 {
  26264. var user_name string
  26265. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  26266. if role.ID == 0 {
  26267. user_name = "管理员"
  26268. } else {
  26269. user_name = role.UserName
  26270. }
  26271. baseParams := models.BaseParams{
  26272. SecretKey: miConfig.SecretKey,
  26273. FixmedinsCode: miConfig.Code,
  26274. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  26275. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  26276. OrgName: miConfig.OrgName,
  26277. Doctor: user_name,
  26278. }
  26279. result := service.Gdyb9101(baseParams, file_name, ReadFile(file_path))
  26280. var dat map[string]interface{}
  26281. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  26282. fmt.Println(dat)
  26283. } else {
  26284. fmt.Println(err)
  26285. }
  26286. userJSONBytes, _ := json.Marshal(dat)
  26287. var res ResultNine
  26288. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  26289. utils.ErrorLog("解析失败:%v", err)
  26290. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26291. return
  26292. }
  26293. if res.Infcode == 0 {
  26294. fileNo := res.Output.FileQuryNo
  26295. api := "http://127.0.0.1:9532/" + "gdyb/twelve?" +
  26296. "file_qury_no=" + fileNo +
  26297. "&setl_optins=" + "定点医保中心" +
  26298. "&stmt_begndate=" + start_time +
  26299. "&stm_enddate=" + end_time +
  26300. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  26301. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  26302. "&cash_payamt=" + fmt.Sprintf("%.4f", psn_cash_pay) +
  26303. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  26304. "&fixmedins_code=" + miConfig.Code +
  26305. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  26306. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  26307. "&secret_key=" + miConfig.SecretKey +
  26308. "&org_name=" + miConfig.OrgName +
  26309. "&doctor=" + user_name
  26310. resp, requestErr := http.Get(api)
  26311. if requestErr != nil {
  26312. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26313. return
  26314. }
  26315. body, ioErr := ioutil.ReadAll(resp.Body)
  26316. if ioErr != nil {
  26317. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26318. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26319. return
  26320. }
  26321. var respJSON map[string]interface{}
  26322. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  26323. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26324. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26325. return
  26326. }
  26327. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26328. userJSONBytes, _ := json.Marshal(respJSON)
  26329. var res ResultTen
  26330. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  26331. utils.ErrorLog("解析失败:%v", err)
  26332. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26333. return
  26334. }
  26335. if res.Infcode == 0 {
  26336. service.Gdyb9102(baseParams, res.Output.Fileinfo.Filename, res.Output.Fileinfo.FileQuryNo)
  26337. micc := &models.MedicalInsuranceCostCompare{
  26338. StartTime: startime.Unix(),
  26339. EndTime: endtime.Unix(),
  26340. Insutype: "0",
  26341. CheckType: 2,
  26342. Num: fixmedins_setl_cnt,
  26343. Mtime: time.Now().Unix(),
  26344. Status: 1,
  26345. UserOrgId: adminUser.CurrentOrgId,
  26346. CostTotal: medfee_sumamt,
  26347. FuncTotal: fund_pay_sumamt,
  26348. PsnPay: psn_cash_pay,
  26349. Creator: admin_user_id,
  26350. Ctime: time.Now().Unix(),
  26351. }
  26352. service.CreateMedicalInsuranceCostCompareRecord(micc)
  26353. c.ServeSuccessJSON(map[string]interface{}{
  26354. "msg": "明细对账成功",
  26355. })
  26356. }
  26357. } else {
  26358. }
  26359. }
  26360. }
  26361. type CustomOrderInfo struct {
  26362. Name string
  26363. Spec string
  26364. Unit string
  26365. Count float64
  26366. Price float64
  26367. Total float64
  26368. }
  26369. func (c *HisApiController) GetBatchSettleAccounts() {
  26370. admin_user_id, _ := c.GetInt64("admin_user_id")
  26371. order_ids := c.GetString("order_ids")
  26372. order_ids_arr := strings.Split(order_ids, ",")
  26373. data3 := []map[string]interface{}{}
  26374. for _, item := range order_ids_arr {
  26375. id, _ := strconv.ParseInt(item, 10, 64)
  26376. order_id := id
  26377. adminUser := c.GetAdminUserInfo()
  26378. order, _ := service.GetHisOrderByID(order_id)
  26379. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  26380. orderInfos, _ := service.GetHisOrderInfoByNumber(order.Number)
  26381. orderInfos_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  26382. orderInfos = append(orderInfos, orderInfos_two...)
  26383. his_hospital, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  26384. //diagnosisConfig, _ := service.FindDiagnoseById(his.Diagnosis)
  26385. var diagnosis_ids []string
  26386. if his.ID > 0 {
  26387. diagnosis_ids = strings.Split(his.Diagnosis, ",")
  26388. } else {
  26389. diagnosis_ids = strings.Split(his_hospital.Diagnosis, ",")
  26390. }
  26391. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, order.PatientId)
  26392. var dia_config []*models.HisXtDiagnoseConfig
  26393. var name string
  26394. for _, item := range diagnosis_ids {
  26395. id, _ := strconv.ParseInt(item, 10, 64)
  26396. diagnosisConfig, _ := service.FindDiagnoseById(id)
  26397. dia_config = append(dia_config, &diagnosisConfig)
  26398. if len(name) == 0 {
  26399. name = diagnosisConfig.ClassName
  26400. }
  26401. //} else {
  26402. // name = name + "," + diagnosisConfig.ClassName
  26403. //}
  26404. }
  26405. var bedCostTotal float64 = 0 //床位总费
  26406. var bedCostSelfTotal float64 = 0 //床位自费
  26407. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  26408. var bedSelfTotal float64 = 0 //床位部分项目自费
  26409. var bedInscpTotal float64 = 0 //床位部分项目自费
  26410. var operationCostTotal float64 = 0 //手术费
  26411. var operationCostSelfTotal float64 = 0 //手术费
  26412. var operationCostPartSelfTotal float64 = 0 //手术费
  26413. var operationSelfTotal float64 = 0 //床位部分项目自费
  26414. var operationInscpTotal float64 = 0 //床位部分项目自费
  26415. var otherCostTotal float64 = 0 //其他费用
  26416. var otherCostSelfTotal float64 = 0 //其他费用
  26417. var otherCostPartSelfTotal float64 = 0 //其他费用
  26418. var otherSelfTotal float64 = 0 //床位部分项目自费
  26419. var otherInscpTotal float64 = 0 //床位部分项目自费
  26420. var materialCostTotal float64 = 0 //材料费
  26421. var materialCostSelfTotal float64 = 0 //材料费
  26422. var materialCostPartSelfTotal float64 = 0 //材料费
  26423. var materialSelfTotal float64 = 0 //床位部分项目自费
  26424. var materialInscpTotal float64 = 0 //床位部分项目自费
  26425. var westernMedicineCostTotal float64 = 0 //西药费
  26426. var westernMedicineCostSelfTotal float64 = 0 //西药费
  26427. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  26428. var westernMedicineSelfTotal float64 = 0 //床位部分项目自费
  26429. var westernMedicineInscpTotal float64 = 0 //床位部分项目自费
  26430. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  26431. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  26432. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  26433. var chineseTraditionalSelfTotal float64 = 0 //床位部分项目自费
  26434. var chineseTraditionalInscpTotal float64 = 0 //床位部分项目自费
  26435. var checkCostTotal float64 = 0 //检查费
  26436. var checkCostSelfTotal float64 = 0 //检查费
  26437. var checkCostPartSelfTotal float64 = 0 //检查费
  26438. var checkSelfTotal float64 = 0 //床位部分项目自费
  26439. var checkInscpTotal float64 = 0 //床位部分项目自费
  26440. var laboratoryCostTotal float64 = 0 //化验费
  26441. var laboratoryCostSelfTotal float64 = 0 //化验费
  26442. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  26443. var laboratorySelfTotal float64 = 0 //床位部分项目自费
  26444. var laboratoryInscpTotal float64 = 0 //床位部分项目自费
  26445. var treatCostTotal float64 = 0 //治疗费用
  26446. var treatCostSelfTotal float64 = 0 //治疗费用
  26447. var treatCostPartSelfTotal float64 = 0 //治疗费用
  26448. var treatSelfTotal float64 = 0 //床位部分项目自费
  26449. var treatInscpTotal float64 = 0 //床位部分项目自费
  26450. decimal.DivisionPrecision = 2
  26451. for _, item := range orderInfos {
  26452. if item.MedChrgitmType == "01" { //床位费
  26453. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  26454. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  26455. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  26456. bedSelfTotal, _ = decimal.NewFromFloat(bedSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  26457. bedInscpTotal, _ = decimal.NewFromFloat(bedInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  26458. }
  26459. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  26460. if item.MedChrgitmType == "03" { //检查费
  26461. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  26462. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  26463. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  26464. laboratorySelfTotal, _ = decimal.NewFromFloat(laboratorySelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  26465. laboratoryInscpTotal, _ = decimal.NewFromFloat(laboratoryInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  26466. }
  26467. } else {
  26468. if item.MedChrgitmType == "03" && adminUser.CurrentOrgId == 9504 { //手术费
  26469. fmt.Println("------------")
  26470. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  26471. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  26472. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  26473. }
  26474. if item.MedChrgitmType == "03" && adminUser.CurrentOrgId != 9504 { //手术费
  26475. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  26476. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  26477. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  26478. checkSelfTotal, _ = decimal.NewFromFloat(checkSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  26479. checkInscpTotal, _ = decimal.NewFromFloat(checkInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  26480. }
  26481. }
  26482. if item.MedChrgitmType == "04" { //化验费
  26483. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  26484. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  26485. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  26486. laboratorySelfTotal, _ = decimal.NewFromFloat(laboratorySelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  26487. laboratoryInscpTotal, _ = decimal.NewFromFloat(laboratoryInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  26488. }
  26489. if item.MedChrgitmType == "05" { //治疗费
  26490. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  26491. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  26492. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  26493. treatSelfTotal, _ = decimal.NewFromFloat(treatSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  26494. treatInscpTotal, _ = decimal.NewFromFloat(treatInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  26495. }
  26496. if item.MedChrgitmType == "06" && adminUser.CurrentOrgId == 9504 { //手术费
  26497. fmt.Println("------------")
  26498. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  26499. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  26500. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  26501. }
  26502. if item.MedChrgitmType == "06" && adminUser.CurrentOrgId != 9504 { //手术费
  26503. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  26504. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  26505. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  26506. }
  26507. //if item.MedChrgitmType == "06" { //手术费
  26508. // operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  26509. // operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  26510. // operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  26511. // operationSelfTotal, _ = decimal.NewFromFloat(operationSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  26512. // operationInscpTotal, _ = decimal.NewFromFloat(operationInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  26513. //
  26514. //}
  26515. if item.MedChrgitmType == "08" || item.MedChrgitmType == "1402" || item.MedChrgitmType == "1403" { //材料费
  26516. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  26517. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  26518. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  26519. materialSelfTotal, _ = decimal.NewFromFloat(materialSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  26520. materialInscpTotal, _ = decimal.NewFromFloat(materialInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  26521. }
  26522. if item.MedChrgitmType == "09" { //西药费
  26523. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  26524. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  26525. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  26526. westernMedicineSelfTotal, _ = decimal.NewFromFloat(westernMedicineSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  26527. westernMedicineInscpTotal, _ = decimal.NewFromFloat(westernMedicineInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  26528. }
  26529. if item.MedChrgitmType == "11" { //中成费
  26530. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  26531. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  26532. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  26533. chineseTraditionalSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  26534. chineseTraditionalInscpTotal, _ = decimal.NewFromFloat(chineseTraditionalInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  26535. }
  26536. if item.MedChrgitmType == "14" || item.MedChrgitmType == "0" || item.MedChrgitmType == "12" || item.MedChrgitmType == "02" { //其他费
  26537. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  26538. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  26539. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  26540. otherSelfTotal, _ = decimal.NewFromFloat(otherSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  26541. otherInscpTotal, _ = decimal.NewFromFloat(otherInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  26542. }
  26543. }
  26544. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  26545. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  26546. var user_name string
  26547. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  26548. if role.ID == 0 {
  26549. user_name = "管理员"
  26550. } else {
  26551. user_name = role.UserName
  26552. }
  26553. baseParams := models.BaseParams{
  26554. SecretKey: miConfig.SecretKey,
  26555. FixmedinsCode: miConfig.Code,
  26556. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  26557. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  26558. OrgName: miConfig.OrgName,
  26559. Doctor: user_name,
  26560. RequestUrl: miConfig.Url,
  26561. AccessKey: miConfig.AccessKey,
  26562. }
  26563. businessParams := models.BusinessParams{
  26564. PsnNo: order.PsnNo,
  26565. MdtrtId: order.MdtrtId,
  26566. SetlId: order.SetlId,
  26567. }
  26568. var res ResultEleven
  26569. var resEleven10265 ResultEleven10265
  26570. if config.IsOpen == 1 {
  26571. baseParams.InsuplcAdmdvs = his.InsuplcAdmdvs
  26572. result := service.Gdyb5203(baseParams, businessParams)
  26573. service.Gdyb5204(baseParams, businessParams)
  26574. //service.Gdyb5302(businessParams.PsnNo, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs, baseParams.SecretKey)
  26575. var dat map[string]interface{}
  26576. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  26577. fmt.Println(dat)
  26578. } else {
  26579. fmt.Println(err)
  26580. }
  26581. userJSONBytes, _ := json.Marshal(dat)
  26582. if miConfig.Code == "H15049901371" {
  26583. if err := json.Unmarshal(userJSONBytes, &resEleven10265); err != nil {
  26584. utils.ErrorLog("解析失败:%v", err)
  26585. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26586. return
  26587. }
  26588. res.InfRefmsgid = resEleven10265.InfRefmsgid
  26589. res.Output = resEleven10265.Output
  26590. res.ErrMsg = resEleven10265.ErrMsg
  26591. res.Cainfo = resEleven10265.Cainfo
  26592. res.WarnMsg = resEleven10265.WarnMsg
  26593. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  26594. res.Infcode = infocode
  26595. } else {
  26596. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  26597. utils.ErrorLog("解析失败:%v", err)
  26598. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26599. return
  26600. }
  26601. }
  26602. printor_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  26603. charge_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, order.Creator)
  26604. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, order.PatientId, order.SettleAccountsDate)
  26605. adminRole_two, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  26606. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, his_hospital.Doctor)
  26607. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  26608. var doctor_name string
  26609. if roles.ID == 0 {
  26610. doctor_name = "管理员"
  26611. } else {
  26612. doctor_name = roles.UserName
  26613. }
  26614. yiliao_leibie := ""
  26615. switch order.MedType {
  26616. case "11":
  26617. yiliao_leibie = "普通门诊"
  26618. break
  26619. case "12":
  26620. yiliao_leibie = "门诊挂号"
  26621. break
  26622. case "13":
  26623. yiliao_leibie = "急诊"
  26624. break
  26625. case "14":
  26626. yiliao_leibie = "门诊特殊病"
  26627. break
  26628. case "15":
  26629. yiliao_leibie = "门诊统筹"
  26630. break
  26631. case "16":
  26632. yiliao_leibie = "门诊慢性病"
  26633. break
  26634. case "21":
  26635. yiliao_leibie = "普通住院"
  26636. break
  26637. }
  26638. departments, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  26639. res.Output.Setlinfo.PsnCashPay = res.Output.Setlinfo.CashPayamt
  26640. if res.Infcode == 0 {
  26641. data2 := map[string]interface{}{
  26642. "diagnosis": name,
  26643. "order_infos": orderInfos,
  26644. "number": order.MdtrtId,
  26645. "date": order.SettleAccountsDate,
  26646. "charge_admin": charge_admin,
  26647. "printor_admin": printor_admin,
  26648. "info": res.Output.Setlinfo,
  26649. "order": order,
  26650. "bedCostTotal": bedCostTotal,
  26651. "bedCostSelfTotal": bedCostSelfTotal,
  26652. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  26653. "bedSelfTotal": bedSelfTotal,
  26654. "bedInscpTotal": bedInscpTotal,
  26655. "operationCostTotal": operationCostTotal,
  26656. "operationCostSelfTotal": operationCostSelfTotal,
  26657. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  26658. "operationSelfTotal": operationSelfTotal,
  26659. "operationInscpTotal": operationInscpTotal,
  26660. "otherCostTotal": otherCostTotal,
  26661. "otherCostSelfTotal": otherCostSelfTotal,
  26662. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  26663. "otherSelfTotal": otherSelfTotal,
  26664. "otherInscpTotal": otherInscpTotal,
  26665. "materialCostTotal": materialCostTotal,
  26666. "materialCostSelfTotal": materialCostSelfTotal,
  26667. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  26668. "materialSelfTotal": materialSelfTotal,
  26669. "materialInscpTotal": materialInscpTotal,
  26670. "westernMedicineCostTotal": westernMedicineCostTotal,
  26671. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  26672. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  26673. "westernMedicineSelfTotal": westernMedicineSelfTotal,
  26674. "westernMedicineInscpTotal": westernMedicineInscpTotal,
  26675. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  26676. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  26677. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  26678. "chineseTraditionalSelfTotal": chineseTraditionalSelfTotal,
  26679. "chineseTraditionalInscpTotal": chineseTraditionalInscpTotal,
  26680. "checkCostTotal": checkCostTotal,
  26681. "checkCostSelfTotal": checkCostSelfTotal,
  26682. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  26683. "checkSelfTotal": checkSelfTotal,
  26684. "checkInscpTotal": checkInscpTotal,
  26685. "laboratoryCostTotal": laboratoryCostTotal,
  26686. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  26687. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  26688. "laboratorySelfTotal": laboratorySelfTotal,
  26689. "laboratoryInscpTotal": laboratoryInscpTotal,
  26690. "treatCostTotal": treatCostTotal,
  26691. "treatCostSelfTotal": treatCostSelfTotal,
  26692. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  26693. "treatSelfTotal": treatSelfTotal,
  26694. "treatInscpTotal": treatInscpTotal,
  26695. "doctor_info": doctor_info,
  26696. "doctor_code": adminRole_two.DoctorCode,
  26697. "doctor_name": doctor_name,
  26698. "health_card_no": order.PsnNo,
  26699. "department": departments.Name,
  26700. "yiliao_leibie": yiliao_leibie,
  26701. "after_money": order.AccountPrice,
  26702. "patient": patient,
  26703. "org_name": miConfig.OrgName,
  26704. "org_code": miConfig.Code,
  26705. "order_number": order.Number,
  26706. "his_hospital": his_hospital,
  26707. "his": his,
  26708. "dia_config": dia_config,
  26709. "psn_cash_pay": order.PsnCashPay,
  26710. //"check_order_info": cus_slice,
  26711. }
  26712. data3 = append(data3, data2)
  26713. }
  26714. }
  26715. }
  26716. c.ServeSuccessJSON(map[string]interface{}{
  26717. "infos": data3,
  26718. })
  26719. }
  26720. func (c *HisApiController) GetSettleAccounts() {
  26721. //id, _ := c.GetInt64("id")
  26722. //record_time := c.GetString("record_time")
  26723. order_id, _ := c.GetInt64("order_id")
  26724. admin_user_id, _ := c.GetInt64("admin_user_id")
  26725. //timeLayout := "2006-01-02"
  26726. //loc, _ := time.LoadLocation("Local")
  26727. //
  26728. //theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  26729. //if err != nil {
  26730. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  26731. // return
  26732. //}Hbyb5203
  26733. //recordDateTime := theTime.Unix()
  26734. adminUser := c.GetAdminUserInfo()
  26735. order, _ := service.GetHisOrderByID(order_id)
  26736. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  26737. orderInfos, _ := service.GetHisOrderInfoByNumber(order.Number)
  26738. orderInfos_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  26739. orderInfos = append(orderInfos, orderInfos_two...)
  26740. his_hospital, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  26741. //diagnosisConfig, _ := service.FindDiagnoseById(his.Diagnosis)
  26742. var diagnosis_ids []string
  26743. if his.ID > 0 {
  26744. diagnosis_ids = strings.Split(his.Diagnosis, ",")
  26745. } else {
  26746. diagnosis_ids = strings.Split(his_hospital.Diagnosis, ",")
  26747. }
  26748. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, order.PatientId)
  26749. var dia_config []*models.HisXtDiagnoseConfig
  26750. var name string
  26751. for _, item := range diagnosis_ids {
  26752. id, _ := strconv.ParseInt(item, 10, 64)
  26753. diagnosisConfig, _ := service.FindDiagnoseById(id)
  26754. dia_config = append(dia_config, &diagnosisConfig)
  26755. if len(name) == 0 {
  26756. name = diagnosisConfig.ClassName
  26757. } else {
  26758. name = name + "," + diagnosisConfig.ClassName
  26759. }
  26760. }
  26761. if patient.UserOrgId == 10215 {
  26762. name = "慢性肾功能不全(血透治疗)"
  26763. }
  26764. var bedCostTotal float64 = 0 //床位总费
  26765. var bedCostSelfTotal float64 = 0 //床位自费
  26766. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  26767. var bedSelfTotal float64 = 0 //床位部分项目自费
  26768. var bedInscpTotal float64 = 0 //床位部分项目自费
  26769. var operationCostTotal float64 = 0 //手术费
  26770. var operationCostSelfTotal float64 = 0 //手术费
  26771. var operationCostPartSelfTotal float64 = 0 //手术费
  26772. var operationSelfTotal float64 = 0 //床位部分项目自费
  26773. var operationInscpTotal float64 = 0 //床位部分项目自费
  26774. var otherCostTotal float64 = 0 //其他费用
  26775. var otherCostSelfTotal float64 = 0 //其他费用
  26776. var otherCostPartSelfTotal float64 = 0 //其他费用
  26777. var otherSelfTotal float64 = 0 //床位部分项目自费
  26778. var otherInscpTotal float64 = 0 //床位部分项目自费
  26779. var materialCostTotal float64 = 0 //材料费
  26780. var materialCostSelfTotal float64 = 0 //材料费
  26781. var materialCostPartSelfTotal float64 = 0 //材料费
  26782. var materialSelfTotal float64 = 0 //床位部分项目自费
  26783. var materialInscpTotal float64 = 0 //床位部分项目自费
  26784. var westernMedicineCostTotal float64 = 0 //西药费
  26785. var westernMedicineCostSelfTotal float64 = 0 //西药费
  26786. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  26787. var westernMedicineSelfTotal float64 = 0 //床位部分项目自费
  26788. var westernMedicineInscpTotal float64 = 0 //床位部分项目自费
  26789. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  26790. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  26791. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  26792. var chineseTraditionalSelfTotal float64 = 0 //床位部分项目自费
  26793. var chineseTraditionalInscpTotal float64 = 0 //床位部分项目自费
  26794. var checkCostTotal float64 = 0 //检查费
  26795. var checkCostSelfTotal float64 = 0 //检查费
  26796. var checkCostPartSelfTotal float64 = 0 //检查费
  26797. var checkSelfTotal float64 = 0 //床位部分项目自费
  26798. var checkInscpTotal float64 = 0 //床位部分项目自费
  26799. var laboratoryCostTotal float64 = 0 //化验费
  26800. var laboratoryCostSelfTotal float64 = 0 //化验费
  26801. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  26802. var laboratorySelfTotal float64 = 0 //床位部分项目自费
  26803. var laboratoryInscpTotal float64 = 0 //床位部分项目自费
  26804. var treatCostTotal float64 = 0 //治疗费用
  26805. var treatCostSelfTotal float64 = 0 //治疗费用
  26806. var treatCostPartSelfTotal float64 = 0 //治疗费用
  26807. var treatSelfTotal float64 = 0 //床位部分项目自费
  26808. var treatInscpTotal float64 = 0 //床位部分项目自费
  26809. decimal.DivisionPrecision = 2
  26810. for _, item := range orderInfos {
  26811. if item.MedChrgitmType == "01" { //床位费
  26812. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  26813. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  26814. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  26815. bedSelfTotal, _ = decimal.NewFromFloat(bedSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  26816. bedInscpTotal, _ = decimal.NewFromFloat(bedInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  26817. }
  26818. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  26819. if item.MedChrgitmType == "03" { //检查费
  26820. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  26821. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  26822. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  26823. laboratorySelfTotal, _ = decimal.NewFromFloat(laboratorySelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  26824. laboratoryInscpTotal, _ = decimal.NewFromFloat(laboratoryInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  26825. }
  26826. } else {
  26827. if item.MedChrgitmType == "03" && adminUser.CurrentOrgId == 9504 { //手术费
  26828. fmt.Println("------------")
  26829. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  26830. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  26831. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  26832. }
  26833. if item.MedChrgitmType == "03" && adminUser.CurrentOrgId != 9504 { //手术费
  26834. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  26835. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  26836. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  26837. checkSelfTotal, _ = decimal.NewFromFloat(checkSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  26838. checkInscpTotal, _ = decimal.NewFromFloat(checkInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  26839. }
  26840. }
  26841. if item.MedChrgitmType == "04" { //化验费
  26842. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  26843. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  26844. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  26845. laboratorySelfTotal, _ = decimal.NewFromFloat(laboratorySelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  26846. laboratoryInscpTotal, _ = decimal.NewFromFloat(laboratoryInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  26847. }
  26848. if item.MedChrgitmType == "05" { //治疗费
  26849. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  26850. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  26851. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  26852. treatSelfTotal, _ = decimal.NewFromFloat(treatSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  26853. treatInscpTotal, _ = decimal.NewFromFloat(treatInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  26854. }
  26855. if item.MedChrgitmType == "06" && adminUser.CurrentOrgId == 9504 { //手术费
  26856. fmt.Println("------------")
  26857. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  26858. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  26859. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  26860. treatSelfTotal, _ = decimal.NewFromFloat(treatSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  26861. treatInscpTotal, _ = decimal.NewFromFloat(treatInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  26862. }
  26863. if item.MedChrgitmType == "06" && adminUser.CurrentOrgId != 9504 { //手术费
  26864. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  26865. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  26866. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  26867. operationSelfTotal, _ = decimal.NewFromFloat(operationSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  26868. operationInscpTotal, _ = decimal.NewFromFloat(operationInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  26869. }
  26870. if item.MedChrgitmType == "08" || item.MedChrgitmType == "1402" || item.MedChrgitmType == "1403" { //材料费
  26871. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  26872. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  26873. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  26874. materialSelfTotal, _ = decimal.NewFromFloat(materialSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  26875. materialInscpTotal, _ = decimal.NewFromFloat(materialInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  26876. }
  26877. if item.MedChrgitmType == "09" { //西药费
  26878. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  26879. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  26880. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  26881. westernMedicineSelfTotal, _ = decimal.NewFromFloat(westernMedicineSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  26882. westernMedicineInscpTotal, _ = decimal.NewFromFloat(westernMedicineInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  26883. }
  26884. if item.MedChrgitmType == "11" { //中成费
  26885. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  26886. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  26887. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  26888. chineseTraditionalSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  26889. chineseTraditionalInscpTotal, _ = decimal.NewFromFloat(chineseTraditionalInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  26890. }
  26891. if item.MedChrgitmType == "14" || item.MedChrgitmType == "0" || item.MedChrgitmType == "12" || item.MedChrgitmType == "02" { //其他费
  26892. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  26893. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  26894. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  26895. otherSelfTotal, _ = decimal.NewFromFloat(otherSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  26896. otherInscpTotal, _ = decimal.NewFromFloat(otherInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  26897. }
  26898. }
  26899. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  26900. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  26901. var user_name string
  26902. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  26903. if role.ID == 0 {
  26904. user_name = "管理员"
  26905. } else {
  26906. user_name = role.UserName
  26907. }
  26908. baseParams := models.BaseParams{
  26909. SecretKey: miConfig.SecretKey,
  26910. FixmedinsCode: miConfig.Code,
  26911. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  26912. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  26913. OrgName: miConfig.OrgName,
  26914. Doctor: user_name,
  26915. RequestUrl: miConfig.Url,
  26916. AccessKey: miConfig.AccessKey,
  26917. }
  26918. businessParams := models.BusinessParams{
  26919. PsnNo: order.PsnNo,
  26920. MdtrtId: order.MdtrtId,
  26921. SetlId: order.SetlId,
  26922. }
  26923. var res ResultEleven
  26924. var resah ResultElevenah
  26925. var resEleven10265 ResultEleven10265
  26926. if config.IsOpen == 1 {
  26927. if miConfig.MdtrtareaAdmvs == "421300" {
  26928. api := "http://192.168.124.4:9532/" + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  26929. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  26930. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  26931. resp, requestErr := http.Get(api)
  26932. if requestErr != nil {
  26933. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26934. return
  26935. }
  26936. body, ioErr := ioutil.ReadAll(resp.Body)
  26937. if ioErr != nil {
  26938. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26939. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26940. return
  26941. }
  26942. var respJSON map[string]interface{}
  26943. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  26944. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26945. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26946. return
  26947. }
  26948. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26949. result, _ := json.Marshal(respJSON)
  26950. fmt.Println("log")
  26951. fmt.Println(string(result))
  26952. if err := json.Unmarshal([]byte(result), &res); err != nil {
  26953. utils.ErrorLog("解析失败:%v", err)
  26954. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26955. return
  26956. }
  26957. } else if miConfig.MdtrtareaAdmvs == "420200" {
  26958. api := "http://192.168.0.197:9532/" + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  26959. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  26960. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  26961. resp, requestErr := http.Get(api)
  26962. if requestErr != nil {
  26963. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26964. return
  26965. }
  26966. body, ioErr := ioutil.ReadAll(resp.Body)
  26967. if ioErr != nil {
  26968. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26969. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26970. return
  26971. }
  26972. var respJSON map[string]interface{}
  26973. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  26974. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26975. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26976. return
  26977. }
  26978. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26979. result, _ := json.Marshal(respJSON)
  26980. fmt.Println("log")
  26981. fmt.Println(string(result))
  26982. if err := json.Unmarshal([]byte(result), &res); err != nil {
  26983. utils.ErrorLog("解析失败:%v", err)
  26984. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26985. return
  26986. }
  26987. } else if miConfig.MdtrtareaAdmvs == "420902" {
  26988. api := miConfig.Url + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  26989. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  26990. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  26991. resp, requestErr := http.Get(api)
  26992. if requestErr != nil {
  26993. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26994. return
  26995. }
  26996. body, ioErr := ioutil.ReadAll(resp.Body)
  26997. if ioErr != nil {
  26998. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26999. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27000. return
  27001. }
  27002. var respJSON map[string]interface{}
  27003. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27004. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27005. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27006. return
  27007. }
  27008. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27009. result, _ := json.Marshal(respJSON)
  27010. fmt.Println("log")
  27011. fmt.Println(string(result))
  27012. if err := json.Unmarshal([]byte(result), &res); err != nil {
  27013. utils.ErrorLog("解析失败:%v", err)
  27014. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27015. return
  27016. }
  27017. } else if miConfig.MdtrtareaAdmvs == "421182" {
  27018. api := miConfig.Url + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  27019. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  27020. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&med_type=" + order.MedType
  27021. resp, requestErr := http.Get(api)
  27022. if requestErr != nil {
  27023. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27024. return
  27025. }
  27026. body, ioErr := ioutil.ReadAll(resp.Body)
  27027. if ioErr != nil {
  27028. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27029. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27030. return
  27031. }
  27032. var respJSON map[string]interface{}
  27033. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27034. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27035. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27036. return
  27037. }
  27038. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27039. result, _ := json.Marshal(respJSON)
  27040. fmt.Println("log")
  27041. fmt.Println(string(result))
  27042. if err := json.Unmarshal([]byte(result), &res); err != nil {
  27043. utils.ErrorLog("解析失败:%v", err)
  27044. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27045. return
  27046. }
  27047. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  27048. var api string
  27049. if miConfig.MdtrtareaAdmvs == "320921" {
  27050. api = "http://192.168.2.3:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  27051. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  27052. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  27053. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  27054. } else {
  27055. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  27056. api = "http://192.168.5.251:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  27057. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  27058. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  27059. }
  27060. resp, requestErr := http.Get(api)
  27061. if requestErr != nil {
  27062. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27063. return
  27064. }
  27065. body, ioErr := ioutil.ReadAll(resp.Body)
  27066. if ioErr != nil {
  27067. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27068. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27069. return
  27070. }
  27071. var respJSON map[string]interface{}
  27072. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27073. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27074. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27075. return
  27076. }
  27077. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27078. result, _ := json.Marshal(respJSON)
  27079. fmt.Println("log")
  27080. fmt.Println(string(result))
  27081. if err := json.Unmarshal([]byte(result), &resEleven10265); err != nil {
  27082. utils.ErrorLog("解析失败:%v", err)
  27083. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27084. return
  27085. }
  27086. res.InfRefmsgid = resEleven10265.InfRefmsgid
  27087. res.Output = resEleven10265.Output
  27088. res.ErrMsg = resEleven10265.ErrMsg
  27089. res.Cainfo = resEleven10265.Cainfo
  27090. res.WarnMsg = resEleven10265.WarnMsg
  27091. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  27092. res.Infcode = infocode
  27093. } else if miConfig.MdtrtareaAdmvs == "350500" {
  27094. result, requestLog, _ := service.FJyb5203(baseParams, businessParams, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  27095. saveLog(result, requestLog, "5203", "结算单")
  27096. var dat map[string]interface{}
  27097. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  27098. fmt.Println(dat)
  27099. } else {
  27100. fmt.Println(err)
  27101. }
  27102. userJSONBytes, _ := json.Marshal(dat)
  27103. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27104. utils.ErrorLog("解析失败:%v", err)
  27105. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27106. return
  27107. }
  27108. } else if miConfig.MdtrtareaAdmvs == "360302" {
  27109. baseParams.InsuplcAdmdvs = his_hospital.InsuplcAdmdvs
  27110. result3, requestLog3 := service.Jxyb5201(baseParams, businessParams)
  27111. fmt.Println(result3)
  27112. fmt.Println(requestLog3)
  27113. result2, requestLog2 := service.Jxyb5202(baseParams, businessParams)
  27114. fmt.Println(result2)
  27115. fmt.Println(requestLog2)
  27116. result, requestLog := service.Jxyb5203(baseParams, businessParams)
  27117. saveLog(result, requestLog, "5203", "结算单")
  27118. var dat map[string]interface{}
  27119. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  27120. fmt.Println(dat)
  27121. } else {
  27122. fmt.Println(err)
  27123. }
  27124. userJSONBytes, _ := json.Marshal(dat)
  27125. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27126. utils.ErrorLog("解析失败:%v", err)
  27127. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27128. return
  27129. }
  27130. } else if miConfig.MdtrtareaAdmvs == "341203" {
  27131. var api string
  27132. api = miConfig.SecretKey + "ahyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  27133. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  27134. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  27135. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  27136. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  27137. resp, requestErr := http.Get(api)
  27138. if requestErr != nil {
  27139. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27140. return
  27141. }
  27142. body, ioErr := ioutil.ReadAll(resp.Body)
  27143. if ioErr != nil {
  27144. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27145. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27146. return
  27147. }
  27148. var respJSON map[string]interface{}
  27149. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27150. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27151. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27152. return
  27153. }
  27154. status := respJSON["data"].(map[string]interface{})["status"].(string)
  27155. if status == "0" {
  27156. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  27157. c.ServeSuccessJSON(map[string]interface{}{
  27158. "failed_code": -10,
  27159. "msg": err_msg,
  27160. })
  27161. return
  27162. }
  27163. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27164. result, _ := json.Marshal(respJSON)
  27165. fmt.Println("log")
  27166. fmt.Println(string(result))
  27167. if err := json.Unmarshal([]byte(result), &resah); err != nil {
  27168. utils.ErrorLog("解析失败:%v", err)
  27169. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27170. return
  27171. }
  27172. res.InfRefmsgid = resah.InfRefmsgid
  27173. timestamp := int64(resah.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  27174. // 创建对应的Time类型
  27175. t := time.UnixMilli(timestamp)
  27176. // 格式化成指定的日期字符串
  27177. str := t.Format("2006-01-02 15:04:05")
  27178. timestamp2 := int64(resah.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  27179. // 创建对应的Time类型
  27180. t3 := time.UnixMilli(timestamp2)
  27181. // 格式化成指定的日期字符串
  27182. str2 := t3.Format("2006-01-02 15:04:05")
  27183. timestamp3 := int64(resah.Output.Setlinfo.Begndate) // 输入要转换的时间戳(这里仅作示例)
  27184. // 创建对应的Time类型
  27185. t4 := time.UnixMilli(timestamp3)
  27186. // 格式化成指定的日期字符串
  27187. str3 := t4.Format("2006-01-02 15:04:05")
  27188. timestamp4 := int64(resah.Output.Setlinfo.Enddate) // 输入要转换的时间戳(这里仅作示例)
  27189. // 创建对应的Time类型
  27190. t5 := time.UnixMilli(timestamp4)
  27191. // 格式化成指定的日期字符串
  27192. str5 := t5.Format("2006-01-02 15:04:05")
  27193. res.Output.Setlinfo.Brdy = str2
  27194. res.Output.Setlinfo.SetlTime = str
  27195. res.Output.Setlinfo.Begndate = str3
  27196. res.Output.Setlinfo.Enddate = str5
  27197. res.Output.Setlinfo.Year = resah.Output.Setlinfo.Year
  27198. res.Output.Setlinfo.PsnPay = resah.Output.Setlinfo.PsnPay
  27199. res.Output.Setlinfo.OpterID = resah.Output.Setlinfo.OpterID
  27200. res.Output.Setlinfo.FlxempeFlag = resah.Output.Setlinfo.FlxempeFlag
  27201. res.Output.Setlinfo.Gend = resah.Output.Setlinfo.Gend
  27202. res.Output.Setlinfo.MdtrtID = resah.Output.Setlinfo.MdtrtID
  27203. res.Output.Setlinfo.AcctMulaidPay = resah.Output.Setlinfo.AcctMulaidPay
  27204. res.Output.Setlinfo.AcctPay = resah.Output.Setlinfo.AcctPay
  27205. res.Output.Setlinfo.CvlservPay = resah.Output.Setlinfo.CvlservPay
  27206. res.Output.Setlinfo.ActPayDedc = resah.Output.Setlinfo.ActPayDedc
  27207. res.Output.Setlinfo.Age = resah.Output.Setlinfo.Age
  27208. res.Output.Setlinfo.Balc = resah.Output.Setlinfo.Balc
  27209. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  27210. res.Output.Setlinfo.Certno = resah.Output.Setlinfo.Certno
  27211. res.Output.Setlinfo.ClrOptins = resah.Output.Setlinfo.ClrOptins
  27212. res.Output.Setlinfo.ClrType = resah.Output.Setlinfo.ClrOptins
  27213. res.Output.Setlinfo.ClrWay = resah.Output.Setlinfo.ClrOptins
  27214. res.Output.Setlinfo.CvlservFlag = resah.Output.Setlinfo.ClrOptins
  27215. res.Output.Setlinfo.CvlservPay = resah.Output.Setlinfo.CvlservPay
  27216. res.Output.Setlinfo.FulamtOwnpayAmt = resah.Output.Setlinfo.FulamtOwnpayAmt
  27217. res.Output.Setlinfo.FundPaySumamt = resah.Output.Setlinfo.FundPaySumamt
  27218. res.Output.Setlinfo.Gend = resah.Output.Setlinfo.Gend
  27219. res.Output.Setlinfo.HifesPay = resah.Output.Setlinfo.HifesPay
  27220. res.Output.Setlinfo.HifmiPay = resah.Output.Setlinfo.HifmiPay
  27221. res.Output.Setlinfo.HifpPay = resah.Output.Setlinfo.HifpPay
  27222. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  27223. //res.Output.Setlinfo.HospPartAmt = resah.Output.Setlinfo.HospPartAmt
  27224. res.Output.Setlinfo.InscpScpAmt = resah.Output.Setlinfo.InscpScpAmt
  27225. res.Output.Setlinfo.Insutype = resah.Output.Setlinfo.Insutype
  27226. res.Output.Setlinfo.MafPay = resah.Output.Setlinfo.MafPay
  27227. //res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  27228. res.Output.Setlinfo.HifobPay = resah.Output.Setlinfo.HifobPay
  27229. res.Output.Setlinfo.MdtrtID = resah.Output.Setlinfo.MdtrtID
  27230. res.Output.Setlinfo.MedType = resah.Output.Setlinfo.MedType
  27231. res.Output.Setlinfo.MedfeeSumamt = resah.Output.Setlinfo.MedfeeSumamt
  27232. res.Output.Setlinfo.MedinsSetlID = resah.Output.Setlinfo.MedinsSetlID
  27233. res.Output.Setlinfo.Naty = resah.Output.Setlinfo.Naty
  27234. res.Output.Setlinfo.OthPay = resah.Output.Setlinfo.OthPay
  27235. res.Output.Setlinfo.OverlmtSelfpay = resah.Output.Setlinfo.OverlmtSelfpay
  27236. res.Output.Setlinfo.PoolPropSelfpay = resah.Output.Setlinfo.PoolPropSelfpay
  27237. res.Output.Setlinfo.PreselfpayAmt = resah.Output.Setlinfo.PreselfpayAmt
  27238. res.Output.Setlinfo.PsnCashPay = resah.Output.Setlinfo.PsnCashPay
  27239. res.Output.Setlinfo.PsnCertType = resah.Output.Setlinfo.ClrOptins
  27240. res.Output.Setlinfo.PsnName = resah.Output.Setlinfo.PsnName
  27241. res.Output.Setlinfo.PsnNo = resah.Output.Setlinfo.PsnNo
  27242. //res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  27243. res.Output.Setlinfo.PsnType = resah.Output.Setlinfo.PsnType
  27244. res.Output.Setlinfo.SetlID = resah.Output.Setlinfo.SetlID
  27245. //res.Output.Setldetail = resah.Output.Setldetail
  27246. res.ErrMsg = resah.ErrMsg
  27247. res.Cainfo = resah.Cainfo
  27248. res.WarnMsg = resah.WarnMsg
  27249. } else if miConfig.MdtrtareaAdmvs == "430800" {
  27250. result, requestLog := service.Hnyb5203(baseParams, businessParams)
  27251. saveLog(result, requestLog, "5203", "结算单")
  27252. var dat map[string]interface{}
  27253. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  27254. fmt.Println(dat)
  27255. } else {
  27256. fmt.Println(err)
  27257. }
  27258. userJSONBytes, _ := json.Marshal(dat)
  27259. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27260. utils.ErrorLog("解析失败:%v", err)
  27261. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27262. return
  27263. }
  27264. } else if miConfig.MdtrtareaAdmvs == "150499" {
  27265. api := "http://172.16.13.254:9532/" + "nmyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  27266. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  27267. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  27268. resp, requestErr := http.Get(api)
  27269. if requestErr != nil {
  27270. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27271. return
  27272. }
  27273. body, ioErr := ioutil.ReadAll(resp.Body)
  27274. if ioErr != nil {
  27275. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27276. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27277. return
  27278. }
  27279. var respJSON map[string]interface{}
  27280. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27281. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27282. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27283. return
  27284. }
  27285. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27286. result, _ := json.Marshal(respJSON)
  27287. fmt.Println("log")
  27288. fmt.Println(string(result))
  27289. if err := json.Unmarshal([]byte(result), &resEleven10265); err != nil {
  27290. utils.ErrorLog("解析失败:%v", err)
  27291. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27292. return
  27293. }
  27294. res.InfRefmsgid = resEleven10265.InfRefmsgid
  27295. res.Output = resEleven10265.Output
  27296. res.ErrMsg = resEleven10265.ErrMsg
  27297. res.Cainfo = resEleven10265.Cainfo
  27298. res.WarnMsg = resEleven10265.WarnMsg
  27299. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  27300. res.Infcode = infocode
  27301. } else if miConfig.MdtrtareaAdmvs == "441799" {
  27302. api := miConfig.Url + "gdyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  27303. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  27304. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  27305. resp, requestErr := http.Get(api)
  27306. if requestErr != nil {
  27307. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27308. return
  27309. }
  27310. body, ioErr := ioutil.ReadAll(resp.Body)
  27311. if ioErr != nil {
  27312. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27313. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27314. return
  27315. }
  27316. var respJSON map[string]interface{}
  27317. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27318. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27319. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27320. return
  27321. }
  27322. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27323. result, _ := json.Marshal(respJSON)
  27324. if err := json.Unmarshal([]byte(result), &res); err != nil {
  27325. utils.ErrorLog("解析失败:%v", err)
  27326. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27327. return
  27328. }
  27329. } else if miConfig.MdtrtareaAdmvs == "450721" {
  27330. service.Gxyb9001(baseParams.OrgName, baseParams.Doctor, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, admin_user_id, order.SetlId, order.MdtrtId, order.PsnNo, order.MedinsSetlId)
  27331. //return
  27332. } else {
  27333. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  27334. if len(his.InsuplcAdmdvs) == 0 {
  27335. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  27336. } else {
  27337. baseParams.InsuplcAdmdvs = his.InsuplcAdmdvs
  27338. }
  27339. result := service.Gdyb5203(baseParams, businessParams)
  27340. //service.Gdyb5204(baseParams, businessParams)
  27341. //service.Gdyb5302(businessParams.PsnNo, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs, baseParams.SecretKey)
  27342. var dat map[string]interface{}
  27343. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  27344. fmt.Println(dat)
  27345. } else {
  27346. fmt.Println(err)
  27347. }
  27348. userJSONBytes, _ := json.Marshal(dat)
  27349. if miConfig.Code == "H15049901371" {
  27350. if err := json.Unmarshal(userJSONBytes, &resEleven10265); err != nil {
  27351. utils.ErrorLog("解析失败:%v", err)
  27352. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27353. return
  27354. }
  27355. res.InfRefmsgid = resEleven10265.InfRefmsgid
  27356. res.Output = resEleven10265.Output
  27357. res.ErrMsg = resEleven10265.ErrMsg
  27358. res.Cainfo = resEleven10265.Cainfo
  27359. res.WarnMsg = resEleven10265.WarnMsg
  27360. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  27361. res.Infcode = infocode
  27362. } else {
  27363. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27364. utils.ErrorLog("解析失败:%v", err)
  27365. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27366. return
  27367. }
  27368. }
  27369. }
  27370. printor_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  27371. charge_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, order.Creator)
  27372. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, order.PatientId, order.SettleAccountsDate)
  27373. adminRole_two, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  27374. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, his_hospital.Doctor)
  27375. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  27376. var doctor_name string
  27377. if roles.ID == 0 {
  27378. doctor_name = "管理员"
  27379. } else {
  27380. doctor_name = roles.UserName
  27381. }
  27382. yiliao_leibie := ""
  27383. switch order.MedType {
  27384. case "11":
  27385. yiliao_leibie = "普通门诊"
  27386. break
  27387. case "12":
  27388. yiliao_leibie = "门诊挂号"
  27389. break
  27390. case "13":
  27391. yiliao_leibie = "急诊"
  27392. break
  27393. case "14":
  27394. yiliao_leibie = "门诊特殊病"
  27395. break
  27396. case "15":
  27397. yiliao_leibie = "门诊统筹"
  27398. break
  27399. case "16":
  27400. yiliao_leibie = "门诊慢性病"
  27401. break
  27402. case "21":
  27403. yiliao_leibie = "普通住院"
  27404. break
  27405. }
  27406. //var rf []CustomFundPay
  27407. //json.Unmarshal([]byte(order.SetlDetail), &rf)
  27408. departments, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  27409. res.Output.Setlinfo.PsnCashPay = order.PsnCashPay
  27410. if res.Infcode == 0 {
  27411. if adminUser.CurrentOrgId == 10215 || adminUser.CurrentOrgId == 10387 || adminUser.CurrentOrgId == 9919 || adminUser.CurrentOrgId == 10088 || adminUser.CurrentOrgId == 10150 || adminUser.CurrentOrgId == 10510 {
  27412. c.ServeSuccessJSON(map[string]interface{}{
  27413. "diagnosis": name,
  27414. "order_infos": orderInfos,
  27415. "number": order.MdtrtId,
  27416. "date": order.SettleAccountsDate,
  27417. "charge_admin": charge_admin,
  27418. "printor_admin": printor_admin,
  27419. "info": res.Output.Setlinfo,
  27420. "order": order,
  27421. "bedCostTotal": bedCostTotal,
  27422. "bedCostSelfTotal": bedCostSelfTotal,
  27423. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  27424. "bedSelfTotal": bedSelfTotal,
  27425. "bedInscpTotal": bedInscpTotal,
  27426. "operationCostTotal": operationCostTotal,
  27427. "operationCostSelfTotal": operationCostSelfTotal,
  27428. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  27429. "operationSelfTotal": operationSelfTotal,
  27430. "operationInscpTotal": operationInscpTotal,
  27431. "otherCostTotal": otherCostTotal,
  27432. "otherCostSelfTotal": otherCostSelfTotal,
  27433. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  27434. "otherSelfTotal": otherSelfTotal,
  27435. "otherInscpTotal": otherInscpTotal,
  27436. "materialCostTotal": materialCostTotal,
  27437. "materialCostSelfTotal": materialCostSelfTotal,
  27438. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  27439. "materialSelfTotal": materialSelfTotal,
  27440. "materialInscpTotal": materialInscpTotal,
  27441. "westernMedicineCostTotal": westernMedicineCostTotal,
  27442. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  27443. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  27444. "westernMedicineSelfTotal": westernMedicineSelfTotal,
  27445. "westernMedicineInscpTotal": westernMedicineInscpTotal,
  27446. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  27447. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  27448. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  27449. "chineseTraditionalSelfTotal": chineseTraditionalSelfTotal,
  27450. "chineseTraditionalInscpTotal": chineseTraditionalInscpTotal,
  27451. "checkCostTotal": checkCostTotal,
  27452. "checkCostSelfTotal": checkCostSelfTotal,
  27453. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  27454. "checkSelfTotal": checkSelfTotal,
  27455. "checkInscpTotal": checkInscpTotal,
  27456. "laboratoryCostTotal": laboratoryCostTotal,
  27457. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  27458. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  27459. "laboratorySelfTotal": laboratorySelfTotal,
  27460. "laboratoryInscpTotal": laboratoryInscpTotal,
  27461. "treatCostTotal": treatCostTotal,
  27462. "treatCostSelfTotal": treatCostSelfTotal,
  27463. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  27464. "treatSelfTotal": treatSelfTotal,
  27465. "treatInscpTotal": treatInscpTotal,
  27466. "doctor_info": doctor_info,
  27467. "doctor_code": adminRole_two.DoctorCode,
  27468. "doctor_name": doctor_name,
  27469. "health_card_no": order.PsnNo,
  27470. "department": departments.Name,
  27471. "yiliao_leibie": yiliao_leibie,
  27472. "after_money": order.AccountPrice,
  27473. "patient": patient,
  27474. "org_name": miConfig.OrgName,
  27475. "org_code": miConfig.Code,
  27476. "order_number": order.Number,
  27477. "his_hospital": his_hospital,
  27478. "his": his,
  27479. "dia_config": dia_config,
  27480. "psn_cash_pay": order.PsnCashPay,
  27481. //"funds": rf,
  27482. //"check_order_info": cus_slice,
  27483. })
  27484. } else {
  27485. c.ServeSuccessJSON(map[string]interface{}{
  27486. "diagnosis": name,
  27487. "order_infos": orderInfos,
  27488. "number": order.MdtrtId,
  27489. "date": order.SettleAccountsDate,
  27490. "charge_admin": charge_admin,
  27491. "printor_admin": printor_admin,
  27492. "info": order,
  27493. "order": order,
  27494. "bedCostTotal": bedCostTotal,
  27495. "bedCostSelfTotal": bedCostSelfTotal,
  27496. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  27497. "bedSelfTotal": bedSelfTotal,
  27498. "bedInscpTotal": bedInscpTotal,
  27499. "operationCostTotal": operationCostTotal,
  27500. "operationCostSelfTotal": operationCostSelfTotal,
  27501. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  27502. "operationSelfTotal": operationSelfTotal,
  27503. "operationInscpTotal": operationInscpTotal,
  27504. "otherCostTotal": otherCostTotal,
  27505. "otherCostSelfTotal": otherCostSelfTotal,
  27506. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  27507. "otherSelfTotal": otherSelfTotal,
  27508. "otherInscpTotal": otherInscpTotal,
  27509. "materialCostTotal": materialCostTotal,
  27510. "materialCostSelfTotal": materialCostSelfTotal,
  27511. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  27512. "materialSelfTotal": materialSelfTotal,
  27513. "materialInscpTotal": materialInscpTotal,
  27514. "westernMedicineCostTotal": westernMedicineCostTotal,
  27515. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  27516. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  27517. "westernMedicineSelfTotal": westernMedicineSelfTotal,
  27518. "westernMedicineInscpTotal": westernMedicineInscpTotal,
  27519. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  27520. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  27521. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  27522. "chineseTraditionalSelfTotal": chineseTraditionalSelfTotal,
  27523. "chineseTraditionalInscpTotal": chineseTraditionalInscpTotal,
  27524. "checkCostTotal": checkCostTotal,
  27525. "checkCostSelfTotal": checkCostSelfTotal,
  27526. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  27527. "checkSelfTotal": checkSelfTotal,
  27528. "checkInscpTotal": checkInscpTotal,
  27529. "laboratoryCostTotal": laboratoryCostTotal,
  27530. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  27531. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  27532. "laboratorySelfTotal": laboratorySelfTotal,
  27533. "laboratoryInscpTotal": laboratoryInscpTotal,
  27534. "treatCostTotal": treatCostTotal,
  27535. "treatCostSelfTotal": treatCostSelfTotal,
  27536. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  27537. "treatSelfTotal": treatSelfTotal,
  27538. "treatInscpTotal": treatInscpTotal,
  27539. "doctor_info": doctor_info,
  27540. "doctor_code": adminRole_two.DoctorCode,
  27541. "doctor_name": doctor_name,
  27542. "health_card_no": order.PsnNo,
  27543. "department": departments.Name,
  27544. "yiliao_leibie": yiliao_leibie,
  27545. "after_money": order.AccountPrice,
  27546. "patient": patient,
  27547. "org_name": miConfig.OrgName,
  27548. "org_code": miConfig.Code,
  27549. "order_number": order.Number,
  27550. "his_hospital": his_hospital,
  27551. "his": his,
  27552. "dia_config": dia_config,
  27553. "psn_cash_pay": order.PsnCashPay,
  27554. //"funds": rf,
  27555. //"check_order_info": cus_slice,
  27556. })
  27557. }
  27558. }
  27559. }
  27560. }
  27561. //func (c *HisApiController) CheckTreatment() {
  27562. // patient_id, _ := c.GetInt64("patient_id")
  27563. // id_card_no := c.GetString("id_card_no")
  27564. // insutype := c.GetString("insutype")
  27565. // med_type := c.GetString("med_type")
  27566. // admin_user_id, _ := c.GetInt64("admin_user_id")
  27567. //
  27568. // adminUser := c.GetAdminUserInfo()
  27569. // patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  27570. //
  27571. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  27572. // config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  27573. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  27574. //
  27575. // if miConfig.MdtrtareaAdmvs == "421300" {
  27576. // var res ResultTwo
  27577. // api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  27578. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  27579. // "&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)
  27580. // resp, requestErr := http.Get(api)
  27581. // if requestErr != nil {
  27582. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27583. // return
  27584. // }
  27585. //
  27586. // body, ioErr := ioutil.ReadAll(resp.Body)
  27587. // if ioErr != nil {
  27588. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27589. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27590. // return
  27591. // }
  27592. // var respJSON map[string]interface{}
  27593. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27594. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27595. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27596. // return
  27597. // }
  27598. //
  27599. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27600. // result, _ := json.Marshal(respJSON)
  27601. //
  27602. // if err := json.Unmarshal([]byte(result), &res); err != nil {
  27603. // utils.ErrorLog("解析失败:%v", err)
  27604. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27605. // return
  27606. // }
  27607. //
  27608. // if res.Infcode == 0 {
  27609. //
  27610. // api := "http://192.168.124.4:9532/" + "hbyb/2001?cert_no=" + "" +
  27611. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  27612. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&psn_no=" + res.Output.Baseinfo.PsnNo + "&insutype=" + insutype + "&med_type=" + med_type
  27613. // resp, requestErr := http.Get(api)
  27614. // if requestErr != nil {
  27615. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27616. // return
  27617. // }
  27618. //
  27619. // body, ioErr := ioutil.ReadAll(resp.Body)
  27620. // if ioErr != nil {
  27621. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27622. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27623. // return
  27624. // }
  27625. // var respJSON map[string]interface{}
  27626. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27627. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27628. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27629. // return
  27630. // }
  27631. // var res Result2001
  27632. //
  27633. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27634. // result2, _ := json.Marshal(respJSON)
  27635. //
  27636. // if err := json.Unmarshal([]byte(result2), &res); err != nil {
  27637. // utils.ErrorLog("解析失败:%v", err)
  27638. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27639. // return
  27640. // }
  27641. //
  27642. // if res.Infcode == 0 {
  27643. // c.ServeSuccessJSON(map[string]interface{}{
  27644. // "msg": res.Output.Trtinfo,
  27645. // })
  27646. // }
  27647. //
  27648. // } else {
  27649. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  27650. // return
  27651. // }
  27652. //
  27653. // } else {
  27654. //
  27655. // result := service.Gdyb1101A(id_card_no, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  27656. // var dat map[string]interface{}
  27657. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  27658. // fmt.Println(dat)
  27659. // } else {
  27660. // fmt.Println(err)
  27661. // }
  27662. // userJSONBytes, _ := json.Marshal(dat)
  27663. // var res ResultTwo
  27664. // var res10265 ResultTwo10265
  27665. // if miConfig.Code == "H15049901371" {
  27666. // if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  27667. // utils.ErrorLog("解析失败:%v", err)
  27668. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27669. // return
  27670. // }
  27671. // res.ErrMsg = res10265.ErrMsg
  27672. // infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  27673. // res.Infcode = infocode
  27674. // res.Output = res10265.Output
  27675. // res.InfRefmsgid = res10265.InfRefmsgid
  27676. // } else {
  27677. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27678. // utils.ErrorLog("解析失败:%v", err)
  27679. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27680. // return
  27681. // }
  27682. // }
  27683. //
  27684. // var user_name string
  27685. // role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, adminUser.AdminUser.Id)
  27686. // if role.ID == 0 {
  27687. // user_name = "xxx"
  27688. // } else {
  27689. // user_name = role.UserName
  27690. // }
  27691. //
  27692. // baseParams := models.BaseParams{
  27693. // SecretKey: miConfig.SecretKey,
  27694. // FixmedinsCode: miConfig.Code,
  27695. // InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  27696. // MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  27697. // OrgName: miConfig.OrgName,
  27698. // Doctor: user_name,
  27699. // }
  27700. //
  27701. // if config.IsOpen == 1 {
  27702. // if miConfig.Code == "H15049901371" {
  27703. // if med_type == "14" {
  27704. // if insutype == "390" {
  27705. // med_type = "9933"
  27706. // } else if insutype == "310" {
  27707. // med_type = "990502"
  27708. // }
  27709. // } else if med_type == "11" {
  27710. // med_type = "11"
  27711. // }
  27712. // }
  27713. // result := service.Gdyb2001(baseParams, res.Output.Baseinfo.PsnNo, insutype, med_type)
  27714. // var dat map[string]interface{}
  27715. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  27716. // fmt.Println(dat)
  27717. // } else {
  27718. // fmt.Println(err)
  27719. // }
  27720. // var res Result2001
  27721. // var res10265 Result2001Org10265
  27722. // if miConfig.Code == "H15049901371" {
  27723. // if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  27724. // utils.ErrorLog("解析失败:%v", err)
  27725. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27726. // return
  27727. // }
  27728. // res.ErrMsg = res10265.ErrMsg
  27729. // res.Output = res10265.Output
  27730. // res.InfRefmsgid = res10265.InfRefmsgid
  27731. // infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  27732. // res.Infcode = infocode
  27733. // } else {
  27734. // if err := json.Unmarshal([]byte(result), &res); err != nil {
  27735. // utils.ErrorLog("解析失败:%v", err)
  27736. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27737. // return
  27738. // }
  27739. // }
  27740. // if res.Infcode == 0 {
  27741. // c.ServeSuccessJSON(map[string]interface{}{
  27742. // "msg": res.Output.Trtinfo,
  27743. // })
  27744. // }
  27745. // }
  27746. // }
  27747. //}
  27748. //func (c *HisApiController) PutRecord() {
  27749. // id, _ := c.GetInt64("id")
  27750. // record_time := c.GetString("record_time")
  27751. // timeLayout := "2006-01-02"
  27752. // loc, _ := time.LoadLocation("Local")
  27753. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  27754. // if err != nil {
  27755. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  27756. // return
  27757. // }
  27758. // recordDateTime := theTime.Unix()
  27759. //
  27760. // adminInfo := c.GetAdminUserInfo()
  27761. // patient, _ := service.GetPatientByID(adminInfo.CurrentOrgId, id)
  27762. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  27763. //
  27764. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  27765. //
  27766. // fmt.Println(miConfig.SecretKey)
  27767. //
  27768. // if patient == nil {
  27769. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  27770. // return
  27771. // }
  27772. // if len(patient.IdCardNo) == 0 {
  27773. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  27774. // return
  27775. // }
  27776. // config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  27777. // if config.IsOpen == 1 {
  27778. // 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
  27779. // resp, requestErr := http.Get(api)
  27780. // if requestErr != nil {
  27781. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27782. // return
  27783. // }
  27784. // defer resp.Body.Close()
  27785. // body, ioErr := ioutil.ReadAll(resp.Body)
  27786. // if ioErr != nil {
  27787. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27788. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27789. // return
  27790. // }
  27791. // var respJSON map[string]interface{}
  27792. //
  27793. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27794. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27795. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27796. // return
  27797. // }
  27798. //
  27799. // userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27800. // userJSONBytes, _ := json.Marshal(userJSON)
  27801. // var res ResultTwo
  27802. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27803. // utils.ErrorLog("解析失败:%v", err)
  27804. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27805. // return
  27806. // }
  27807. // Iinfos, _ := json.Marshal(res.Output.Iinfo)
  27808. // Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  27809. // infoStr := string(Iinfos)
  27810. // idetinfoStr := string(Idetinfos)
  27811. //
  27812. // if res.Infcode == 0 {
  27813. // his := models.VMHisPatient{
  27814. // Status: 1,
  27815. // Ctime: time.Now().Unix(),
  27816. // Mtime: time.Now().Unix(),
  27817. // PsnNo: res.Output.Baseinfo.PsnNo,
  27818. // PsnCertType: res.Output.Baseinfo.PsnCertType,
  27819. // Certno: res.Output.Baseinfo.Certno,
  27820. // PsnName: res.Output.Baseinfo.PsnName,
  27821. // Gend: res.Output.Baseinfo.Gend,
  27822. // Naty: res.Output.Baseinfo.Naty,
  27823. // Brdy: res.Output.Baseinfo.Brdy,
  27824. // Age: res.Output.Baseinfo.Age,
  27825. // Iinfo: infoStr,
  27826. // Idetinfo: idetinfoStr,
  27827. // PatientId: patient.ID,
  27828. // RecordDate: theTime.Unix(),
  27829. // UserOrgId: adminInfo.CurrentOrgId,
  27830. // AdminUserId: adminInfo.AdminUser.Id,
  27831. // IsReturn: 1,
  27832. // }
  27833. //
  27834. // //doctor_id := strconv.FormatInt(patientPrescription.DoctorId, 10)
  27835. // //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")
  27836. // //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")
  27837. //
  27838. // //var dat map[string]interface{}
  27839. // //if err := json.Unmarshal([]byte(result), &dat); err == nil {
  27840. // // fmt.Println(dat)
  27841. // //} else {
  27842. // // fmt.Println(err)
  27843. // //}
  27844. //
  27845. // var dat2 map[string]interface{}
  27846. // if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  27847. // fmt.Println(dat2)
  27848. // } else {
  27849. // fmt.Println(err)
  27850. // }
  27851. //
  27852. // } else {
  27853. // adminUser := c.GetAdminUserInfo()
  27854. // errlog := &models.HisOrderError{
  27855. // UserOrgId: adminUser.CurrentOrgId,
  27856. // Ctime: time.Now().Unix(),
  27857. // Mtime: time.Now().Unix(),
  27858. // ErrMsg: res.ErrMsg,
  27859. // Status: 1,
  27860. // PatientId: id,
  27861. // RecordTime: recordDateTime,
  27862. // Stage: 1,
  27863. // }
  27864. // service.CreateErrMsgLog(errlog)
  27865. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  27866. // return
  27867. // }
  27868. // }
  27869. //
  27870. //}
  27871. //func (c *HisApiController) GetUploadDiag() {
  27872. // id, _ := c.GetInt64("id")
  27873. // record_time := c.GetString("record_time")
  27874. //
  27875. // diagnosis_id, _ := c.GetInt64("diagnosis")
  27876. // sick_type, _ := c.GetInt64("sick_type")
  27877. // reg_type, _ := c.GetInt64("reg_type")
  27878. //
  27879. // timeLayout := "2006-01-02"
  27880. // loc, _ := time.LoadLocation("Local")
  27881. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  27882. // if err != nil {
  27883. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  27884. // return
  27885. // }
  27886. //
  27887. // var patientPrescription models.HisPrescriptionInfo
  27888. // recordDateTime := theTime.Unix()
  27889. // adminInfo := c.GetAdminUserInfo()
  27890. // patientPrescription, _ = service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  27891. //
  27892. // if patientPrescription.ID == 0 {
  27893. // patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  27894. // }
  27895. //
  27896. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  27897. // diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  27898. // his, _ := service.GetVMHisPatientInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  27899. // sickConfig, _ := service.FindSickById(sick_type)
  27900. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  27901. //
  27902. // api2 := "http://127.0.0.1:9532/" + "gdyb/four?psn_no=" + his.PsnNo +
  27903. // "&mdtrt_id=" + his.Number + "&doctor=" + patientPrescription.Doctor + "&department=" + department.Name +
  27904. // "&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 +
  27905. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&sick_code=" + sickConfig.ContentCode + "&sick_name=" + sickConfig.ClassName
  27906. // resp2, requestErr2 := http.Get(api2)
  27907. // if requestErr2 != nil {
  27908. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27909. // return
  27910. // }
  27911. // body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  27912. // if ioErr2 != nil {
  27913. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  27914. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27915. // return
  27916. // }
  27917. // var respJSON2 map[string]interface{}
  27918. // if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  27919. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27920. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27921. // return
  27922. // }
  27923. // respJSON2 = respJSON2["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27924. // userJSONBytes2, _ := json.Marshal(respJSON2)
  27925. //
  27926. // var res2 ResultSix
  27927. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  27928. // utils.ErrorLog("解析失败:%v", err)
  27929. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27930. // return
  27931. // }
  27932. // if res2.Infcode != 0 {
  27933. // adminUser := c.GetAdminUserInfo()
  27934. // errlog := &models.HisOrderError{
  27935. // UserOrgId: adminUser.CurrentOrgId,
  27936. // Ctime: time.Now().Unix(),
  27937. // Mtime: time.Now().Unix(),
  27938. // ErrMsg: res2.ErrMsg,
  27939. // Status: 1,
  27940. // PatientId: id,
  27941. // RecordTime: recordDateTime,
  27942. // Stage: 3,
  27943. // }
  27944. // service.CreateErrMsgLog(errlog)
  27945. //
  27946. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterThreeException)
  27947. // return
  27948. // }
  27949. //
  27950. // c.ServeSuccessJSON(map[string]interface{}{
  27951. // "msg": "上传成功",
  27952. // })
  27953. //
  27954. //}
  27955. type QueryResult struct {
  27956. ID int64
  27957. Name string
  27958. Code string
  27959. List_type_code string
  27960. }
  27961. func (c *HisApiController) GetCheckCode() {
  27962. ids_str := c.GetString("ids")
  27963. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  27964. ids_arr := strings.Split(ids_str, ",")
  27965. var queryResult []QueryResult
  27966. ids := make([]int64, 0)
  27967. for _, item := range ids_arr {
  27968. id, _ := strconv.ParseInt(item, 10, 64)
  27969. ids = append(ids, id)
  27970. }
  27971. if record_type == 1 {
  27972. drugs, _ := service.GetBatchDrugList(ids)
  27973. for _, item := range drugs {
  27974. result := QueryResult{
  27975. ID: item.ID,
  27976. Name: item.DrugName,
  27977. Code: item.MedicalInsuranceNumber,
  27978. List_type_code: "101",
  27979. }
  27980. queryResult = append(queryResult, result)
  27981. }
  27982. } else if record_type == 2 {
  27983. goods, _ := service.GetBatchGoodInformationList(ids)
  27984. fmt.Println(goods)
  27985. for _, item := range goods {
  27986. result := QueryResult{
  27987. ID: item.ID,
  27988. Name: item.GoodName,
  27989. Code: item.SocialSecurityDirectoryCode,
  27990. List_type_code: "301",
  27991. }
  27992. queryResult = append(queryResult, result)
  27993. }
  27994. } else if record_type == 3 {
  27995. projects, _ := service.GetBathchMyPorjecgList(ids)
  27996. for _, item := range projects {
  27997. result := QueryResult{
  27998. ID: item.ID,
  27999. Name: item.ProjectName,
  28000. Code: item.MedicalCode,
  28001. List_type_code: "201",
  28002. }
  28003. queryResult = append(queryResult, result)
  28004. }
  28005. }
  28006. admin_user_id, _ := c.GetInt64("admin_user_id")
  28007. adminUser := c.GetAdminUserInfo()
  28008. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  28009. //config, _ := /**/service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  28010. var user_name string
  28011. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  28012. if role.ID == 0 {
  28013. user_name = "管理员"
  28014. } else {
  28015. user_name = role.UserName
  28016. }
  28017. baseParams := models.BaseParams{
  28018. SecretKey: miConfig.SecretKey,
  28019. FixmedinsCode: miConfig.Code,
  28020. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  28021. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  28022. OrgName: miConfig.OrgName,
  28023. Doctor: user_name,
  28024. }
  28025. var result string
  28026. if miConfig.MdtrtareaAdmvs == "430800" {
  28027. for _, item := range queryResult {
  28028. if record_type == 1 {
  28029. 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)
  28030. } else if record_type == 2 {
  28031. fmt.Println(item.Code)
  28032. 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)
  28033. } else if record_type == 3 {
  28034. 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)
  28035. }
  28036. var dat map[string]interface{}
  28037. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  28038. fmt.Println(dat)
  28039. } else {
  28040. fmt.Println(err)
  28041. }
  28042. userJSONBytes, _ := json.Marshal(dat)
  28043. var res ResultSix
  28044. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28045. utils.ErrorLog("解析失败:%v", err)
  28046. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28047. return
  28048. }
  28049. if res.Infcode == 0 {
  28050. if record_type == 1 {
  28051. service.UpdateBaseDrugById(item.ID)
  28052. } else if record_type == 2 {
  28053. service.UpdateGoodInformaitonByDetail(item.ID)
  28054. } else if record_type == 3 {
  28055. service.UpdateProjectById(item.ID)
  28056. }
  28057. c.ServeSuccessJSON(map[string]interface{}{
  28058. "failed_code": 0,
  28059. "msg": "目录对照成功",
  28060. })
  28061. } else {
  28062. c.ServeSuccessJSON(map[string]interface{}{
  28063. "failed_code": -10,
  28064. "msg": res.ErrMsg,
  28065. })
  28066. }
  28067. }
  28068. } else {
  28069. for _, item := range queryResult {
  28070. var result string
  28071. if record_type == 1 {
  28072. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2023-04-26", "", item.List_type_code, admin_user_id)
  28073. } else if record_type == 2 {
  28074. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2023-04-26", "", item.List_type_code, admin_user_id)
  28075. } else if record_type == 3 {
  28076. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2023-04-26", "", item.List_type_code, admin_user_id)
  28077. }
  28078. var dat map[string]interface{}
  28079. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  28080. fmt.Println(dat)
  28081. } else {
  28082. fmt.Println(err)
  28083. }
  28084. userJSONBytes, _ := json.Marshal(dat)
  28085. var res ResultSix
  28086. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28087. utils.ErrorLog("解析失败:%v", err)
  28088. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28089. return
  28090. }
  28091. if res.Infcode == 0 {
  28092. if record_type == 1 {
  28093. service.UpdateBaseDrugById(item.ID)
  28094. } else if record_type == 2 {
  28095. service.UpdateGoodInformaitonByDetail(item.ID)
  28096. } else if record_type == 3 {
  28097. service.UpdateProjectById(item.ID)
  28098. }
  28099. c.ServeSuccessJSON(map[string]interface{}{
  28100. "failed_code": 0,
  28101. "msg": "目录对照成功",
  28102. })
  28103. } else {
  28104. c.ServeSuccessJSON(map[string]interface{}{
  28105. "failed_code": -10,
  28106. "msg": res.ErrMsg,
  28107. })
  28108. }
  28109. }
  28110. }
  28111. }
  28112. func (c *HisApiController) UnCheckCode() {
  28113. ids_str := c.GetString("ids")
  28114. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  28115. admin_user_id, _ := c.GetInt64("admin_user_id")
  28116. ids_arr := strings.Split(ids_str, ",")
  28117. var queryResult []QueryResult
  28118. ids := make([]int64, 0)
  28119. for _, item := range ids_arr {
  28120. id, _ := strconv.ParseInt(item, 10, 64)
  28121. ids = append(ids, id)
  28122. }
  28123. if record_type == 1 {
  28124. drugs, _ := service.GetBatchDrugList(ids)
  28125. for _, item := range drugs {
  28126. result := QueryResult{
  28127. ID: item.ID,
  28128. Name: item.DrugName,
  28129. Code: item.MedicalInsuranceNumber,
  28130. List_type_code: "101",
  28131. }
  28132. queryResult = append(queryResult, result)
  28133. }
  28134. } else if record_type == 2 {
  28135. goods, _ := service.GetBatchGoodInformationList(ids)
  28136. for _, item := range goods {
  28137. result := QueryResult{
  28138. ID: item.ID,
  28139. Name: item.GoodName,
  28140. Code: item.SocialSecurityDirectoryCode,
  28141. List_type_code: "301",
  28142. }
  28143. queryResult = append(queryResult, result)
  28144. }
  28145. } else if record_type == 3 {
  28146. projects, _ := service.GetBathchMyPorjecgList(ids)
  28147. for _, item := range projects {
  28148. result := QueryResult{
  28149. ID: item.ID,
  28150. Name: item.ProjectName,
  28151. Code: item.MedicalCode,
  28152. List_type_code: "201",
  28153. }
  28154. queryResult = append(queryResult, result)
  28155. }
  28156. }
  28157. adminUser := c.GetAdminUserInfo()
  28158. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  28159. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  28160. var user_name string
  28161. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  28162. if role.ID == 0 {
  28163. user_name = "xxx"
  28164. } else {
  28165. user_name = role.UserName
  28166. }
  28167. baseParams := &models.BaseParams{
  28168. SecretKey: miConfig.SecretKey,
  28169. FixmedinsCode: miConfig.Code,
  28170. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  28171. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  28172. OrgName: miConfig.OrgName,
  28173. Doctor: user_name,
  28174. }
  28175. if config.IsOpen == 1 {
  28176. if miConfig.MdtrtareaAdmvs == "430800" {
  28177. for _, item := range queryResult {
  28178. var result string
  28179. if record_type == 1 {
  28180. 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)
  28181. } else if record_type == 2 {
  28182. fmt.Println(item.Code)
  28183. 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)
  28184. } else if record_type == 3 {
  28185. 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)
  28186. }
  28187. var dat map[string]interface{}
  28188. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  28189. fmt.Println(dat)
  28190. } else {
  28191. fmt.Println(err)
  28192. }
  28193. userJSONBytes, _ := json.Marshal(dat)
  28194. var res ResultSix
  28195. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28196. utils.ErrorLog("解析失败:%v", err)
  28197. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28198. return
  28199. }
  28200. if res.Infcode == 0 {
  28201. if record_type == 1 {
  28202. service.UpdateBaseDrugById(item.ID)
  28203. } else if record_type == 2 {
  28204. service.UpdateGoodInformaitonByDetail(item.ID)
  28205. } else if record_type == 3 {
  28206. service.UpdateProjectById(item.ID)
  28207. }
  28208. c.ServeSuccessJSON(map[string]interface{}{
  28209. "failed_code": 0,
  28210. "msg": "目录对照成功",
  28211. })
  28212. } else {
  28213. c.ServeSuccessJSON(map[string]interface{}{
  28214. "failed_code": -10,
  28215. "msg": res.ErrMsg,
  28216. })
  28217. }
  28218. }
  28219. } else {
  28220. for _, item := range queryResult {
  28221. var result string
  28222. if record_type == 1 {
  28223. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  28224. } else if record_type == 2 {
  28225. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  28226. } else if record_type == 3 {
  28227. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  28228. }
  28229. var dat2 map[string]interface{}
  28230. if err := json.Unmarshal([]byte(result), &dat2); err == nil {
  28231. fmt.Println(dat2)
  28232. } else {
  28233. fmt.Println(err)
  28234. }
  28235. userJSONBytes, _ := json.Marshal(dat2)
  28236. var res ResultSix
  28237. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28238. utils.ErrorLog("解析失败:%v", err)
  28239. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28240. return
  28241. }
  28242. if res.Infcode == 0 {
  28243. if record_type == 1 {
  28244. service.UpdateDrugByIdDetail(item.ID)
  28245. } else if record_type == 2 {
  28246. service.UpdateGoodInfoById(item.ID)
  28247. } else if record_type == 3 {
  28248. service.UpdateMyProjectById(item.ID)
  28249. }
  28250. c.ServeSuccessJSON(map[string]interface{}{
  28251. "failed_code": 0,
  28252. "msg": "撤销目录对照成功",
  28253. })
  28254. } else {
  28255. c.ServeSuccessJSON(map[string]interface{}{
  28256. "failed_code": -10,
  28257. "msg": res.ErrMsg,
  28258. })
  28259. }
  28260. }
  28261. }
  28262. }
  28263. }
  28264. func (c *HisApiController) GetPatientInfo() {
  28265. id_card_no := c.GetString("id_card_no")
  28266. admin_user_id, _ := c.GetInt64("admin_user_id")
  28267. patient, _ := service.GetPatientByIDCard(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  28268. if patient.ID == 0 {
  28269. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  28270. return
  28271. }
  28272. role, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  28273. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  28274. config, _ := service.GetMedicalInsuranceConfig(c.GetAdminUserInfo().CurrentOrgId)
  28275. var res ResultTwo
  28276. var res10265 ResultTwo10265
  28277. if config.IsOpen == 1 {
  28278. if miConfig.MdtrtareaAdmvs == "150499" {
  28279. //请求内网数据
  28280. api := "http://172.16.13.254:9532/" + "nmyb/1101?cert_no=" + patient.IdCardNo +
  28281. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  28282. "&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
  28283. resp, requestErr := http.Get(api)
  28284. if requestErr != nil {
  28285. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28286. return
  28287. }
  28288. body, ioErr := ioutil.ReadAll(resp.Body)
  28289. if ioErr != nil {
  28290. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28291. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28292. return
  28293. }
  28294. var respJSON map[string]interface{}
  28295. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  28296. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28297. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28298. return
  28299. }
  28300. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28301. result_byte, _ := json.Marshal(respJSON)
  28302. result := string(result_byte)
  28303. var dat map[string]interface{}
  28304. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  28305. fmt.Println(dat)
  28306. } else {
  28307. fmt.Println(err)
  28308. }
  28309. userJSONBytes, _ := json.Marshal(dat)
  28310. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  28311. utils.ErrorLog("解析失败:%v", err)
  28312. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28313. return
  28314. }
  28315. Infcode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  28316. res.Infcode = Infcode
  28317. res.ErrMsg = res10265.ErrMsg
  28318. res.Output = res10265.Output
  28319. res.InfRefmsgid = res10265.InfRefmsgid
  28320. res.RespondTime = res10265.RespondTime
  28321. res.WarnInfo = res10265.WarnInfo
  28322. } else {
  28323. result := service.Gdyb1101A(id_card_no, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  28324. var dat map[string]interface{}
  28325. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  28326. fmt.Println(dat)
  28327. } else {
  28328. fmt.Println(err)
  28329. }
  28330. userJSONBytes, _ := json.Marshal(dat)
  28331. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28332. utils.ErrorLog("解析失败:%v", err)
  28333. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28334. return
  28335. }
  28336. }
  28337. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28338. // utils.ErrorLog("解析失败:%v", err)
  28339. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28340. // return
  28341. //}
  28342. for index, item := range res.Output.Iinfo {
  28343. if item.PsnInsuStas == "2" {
  28344. fmt.Println("--------")
  28345. res.Output.Iinfo[index].Insutype = "300"
  28346. res.Output.Iinfo[index].PsnInsuStas = "1"
  28347. }
  28348. }
  28349. fmt.Println(res.Output.Iinfo)
  28350. if res.Infcode != 0 {
  28351. c.ServeSuccessJSON(map[string]interface{}{
  28352. "failed_code": -10,
  28353. "msg": res.ErrMsg,
  28354. })
  28355. } else {
  28356. c.ServeSuccessJSON(map[string]interface{}{
  28357. "failed_code": 0,
  28358. "info": res,
  28359. })
  28360. }
  28361. }
  28362. }
  28363. func (c *HisApiController) PsnPutOnRecord() {
  28364. record_type, _ := c.GetInt64("type")
  28365. patient_id, _ := c.GetInt64("patient_id")
  28366. admin_user_id, _ := c.GetInt64("admin_user_id")
  28367. start_time := c.GetString("start_time")
  28368. end_time := c.GetString("end_time")
  28369. adminUser := c.GetAdminUserInfo()
  28370. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  28371. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  28372. var patients []*models.Patients
  28373. if record_type == 1 { //全部备案
  28374. patient, _ := service.GetAllPatient(adminUser.CurrentOrgId)
  28375. patients = append(patients, patient...)
  28376. } else { //单个备案
  28377. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  28378. patients = append(patients, patient)
  28379. }
  28380. var user_name string
  28381. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  28382. if role.ID == 0 {
  28383. user_name = "xxx"
  28384. } else {
  28385. user_name = role.UserName
  28386. }
  28387. if config.IsOpen == 1 {
  28388. for _, item := range patients {
  28389. 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
  28390. resp, requestErr := http.Get(api)
  28391. if requestErr != nil {
  28392. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28393. return
  28394. }
  28395. defer resp.Body.Close()
  28396. body, ioErr := ioutil.ReadAll(resp.Body)
  28397. if ioErr != nil {
  28398. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28399. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28400. return
  28401. }
  28402. var respJSON map[string]interface{}
  28403. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  28404. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28405. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28406. return
  28407. }
  28408. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28409. userJSONBytes, _ := json.Marshal(userJSON)
  28410. var res ResultTwo
  28411. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28412. utils.ErrorLog("解析失败:%v", err)
  28413. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28414. return
  28415. }
  28416. if res.Infcode == 0 {
  28417. 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)
  28418. var dat map[string]interface{}
  28419. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  28420. fmt.Println(dat)
  28421. } else {
  28422. fmt.Println(err)
  28423. }
  28424. userJSONBytes, _ := json.Marshal(dat)
  28425. var res2 ResultThirteen
  28426. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  28427. utils.ErrorLog("解析失败:%v", err)
  28428. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28429. return
  28430. }
  28431. if res2.Infcode == 0 {
  28432. psnResult := &models.GdybPsnRecord{
  28433. UserOrgId: adminUser.CurrentOrgId,
  28434. PatientId: item.ID,
  28435. PsnNo: res.Output.Baseinfo.PsnNo,
  28436. Ctime: time.Now().Unix(),
  28437. Mtime: time.Now().Unix(),
  28438. Status: 1,
  28439. IsCancel: 1,
  28440. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  28441. }
  28442. service.CreatePsnRecord(psnResult)
  28443. } else {
  28444. c.ServeSuccessJSON(map[string]interface{}{
  28445. "failed_code": -10,
  28446. "msg": res2.ErrMsg,
  28447. })
  28448. return
  28449. }
  28450. }
  28451. }
  28452. }
  28453. }
  28454. func (c *HisApiController) PsnUnPutOnRecord() {
  28455. id, _ := c.GetInt64("id")
  28456. //record_type, _ := c.GetInt64("type")
  28457. admin_user_id, _ := c.GetInt64("admin_user_id")
  28458. adminUser := c.GetAdminUserInfo()
  28459. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  28460. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  28461. var user_name string
  28462. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  28463. if role.ID == 0 {
  28464. user_name = "xxx"
  28465. } else {
  28466. user_name = role.UserName
  28467. }
  28468. psn_record, _ := service.GetPsnRecordById(id)
  28469. if psn_record.ID == 0 {
  28470. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  28471. return
  28472. }
  28473. if config.IsOpen == 1 {
  28474. result := service.Gdyb2506(psn_record.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  28475. var dat map[string]interface{}
  28476. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  28477. fmt.Println(dat)
  28478. } else {
  28479. fmt.Println(err)
  28480. }
  28481. userJSONBytes, _ := json.Marshal(dat)
  28482. var res ResultFourteen
  28483. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28484. utils.ErrorLog("解析失败:%v", err)
  28485. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28486. return
  28487. }
  28488. if res.Infcode == 0 {
  28489. psn_record.IsCancel = 2
  28490. service.CreatePsnRecord(&psn_record)
  28491. } else {
  28492. c.ServeSuccessJSON(map[string]interface{}{
  28493. "failed_code": -10,
  28494. "msg": res.ErrMsg,
  28495. })
  28496. return
  28497. }
  28498. }
  28499. }
  28500. func (c *HisApiController) PsnPutNCDSOnRecord() {
  28501. patient_id, _ := c.GetInt64("patient_id")
  28502. insutype_two := c.GetString("insutype")
  28503. psn_no := c.GetString("psn_no")
  28504. doctor_id, _ := c.GetInt64("doctor_id")
  28505. sick_id, _ := c.GetInt64("sick_id")
  28506. department_id, _ := c.GetInt64("department_id")
  28507. start_time := c.GetString("start_time")
  28508. end_time := c.GetString("end_time")
  28509. check_time := c.GetString("check_time")
  28510. hospital_code := c.GetString("hospital_code")
  28511. hospital_name := c.GetString("hospital_name")
  28512. adminUser := c.GetAdminUserInfo()
  28513. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  28514. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  28515. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  28516. sick, _ := service.FindSickById(sick_id)
  28517. doctor, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  28518. if len(hospital_code) == 0 {
  28519. hospital_code = miConfig.Code
  28520. }
  28521. if len(hospital_name) == 0 {
  28522. hospital_name = miConfig.OrgName
  28523. }
  28524. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  28525. var res ResultTwo
  28526. var res10265 ResultTwo10265
  28527. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  28528. psn_info, _ := service.GetPsnByPatientId(patient.ID)
  28529. api := "http://192.168.2.3:9532/" + "hbyb/1101?cert_no=" + "" +
  28530. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  28531. "&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
  28532. resp, requestErr := http.Get(api)
  28533. if requestErr != nil {
  28534. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28535. return
  28536. }
  28537. body, ioErr := ioutil.ReadAll(resp.Body)
  28538. if ioErr != nil {
  28539. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28540. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28541. return
  28542. }
  28543. var respJSON map[string]interface{}
  28544. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  28545. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28546. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28547. return
  28548. }
  28549. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28550. result, _ := json.Marshal(respJSON)
  28551. fmt.Println("log")
  28552. fmt.Println(string(result))
  28553. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  28554. utils.ErrorLog("解析失败:%v", err)
  28555. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28556. return
  28557. }
  28558. res.ErrMsg = res10265.ErrMsg
  28559. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  28560. res.Infcode = infocode
  28561. res.Output = res10265.Output
  28562. res.InfRefmsgid = res10265.InfRefmsgid
  28563. } else {
  28564. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  28565. if miConfig.Code == "H15049901371" {
  28566. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  28567. utils.ErrorLog("解析失败:%v", err)
  28568. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28569. return
  28570. }
  28571. res.ErrMsg = res10265.ErrMsg
  28572. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  28573. res.Infcode = infocode
  28574. res.Output = res10265.Output
  28575. res.InfRefmsgid = res10265.InfRefmsgid
  28576. } else {
  28577. if err := json.Unmarshal([]byte(result), &res); err != nil {
  28578. utils.ErrorLog("解析失败:%v", err)
  28579. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28580. return
  28581. }
  28582. }
  28583. }
  28584. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  28585. infoStr := string(Iinfos)
  28586. var rf []*ResultFive
  28587. json.Unmarshal([]byte(infoStr), &rf)
  28588. var insuplc_admdvs string
  28589. var insutype string
  28590. var is390 int = 0
  28591. var is310 int = 0
  28592. var insutypes []*ResultFive
  28593. for _, item := range rf {
  28594. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  28595. insutypes = append(insutypes, item)
  28596. }
  28597. }
  28598. if len(insutypes) == 1 {
  28599. insutype = insutypes[0].Insutype
  28600. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  28601. } else {
  28602. for _, i := range insutypes {
  28603. if i.Insutype == "390" {
  28604. is390 = 1
  28605. }
  28606. if i.Insutype == "310" {
  28607. is310 = 1
  28608. }
  28609. }
  28610. }
  28611. if is390 == 1 {
  28612. insutype = "390"
  28613. }
  28614. if is310 == 1 {
  28615. insutype = "310"
  28616. }
  28617. if len(insutypes) == 2 {
  28618. insutype = insutype_two
  28619. }
  28620. if len(insutypes) == 0 {
  28621. insutype = "310"
  28622. }
  28623. insutype = insutype_two
  28624. fmt.Println(insutype)
  28625. for _, item := range rf {
  28626. fmt.Println(item.Insutype)
  28627. fmt.Println(insutype)
  28628. if item.Insutype == insutype {
  28629. fmt.Println(item.Insutype)
  28630. fmt.Println(insutype)
  28631. insuplc_admdvs = item.InsuplcAdmdvs
  28632. }
  28633. }
  28634. fmt.Println(insuplc_admdvs)
  28635. var res2 ResultThirteen
  28636. var res10265_2 ResultThirteen10265
  28637. if config.IsOpen == 1 {
  28638. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  28639. } else {
  28640. if miConfig.MdtrtareaAdmvs == "150499" {
  28641. //
  28642. //api := "http://172.16.13.254:9532/" + "nmyb/2503?psn_no=" + psn_no + "&insutype=" + insutype + "sick_name" + sick.ClassName + "&sick_code=" + sick.CountryCode +
  28643. // "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  28644. // "&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
  28645. //resp, requestErr := http.Get(api)
  28646. //if requestErr != nil {
  28647. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28648. // return
  28649. //}
  28650. //
  28651. //body, ioErr := ioutil.ReadAll(resp.Body)
  28652. //if ioErr != nil {
  28653. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28654. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28655. // return
  28656. //}
  28657. //var respJSON map[string]interface{}
  28658. //if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  28659. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28660. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28661. // return
  28662. //}
  28663. //
  28664. //respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28665. //result, _ := json.Marshal(respJSON)
  28666. //if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  28667. // utils.ErrorLog("解析失败:%v", err)
  28668. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28669. // return
  28670. //}
  28671. //infocode = resThree.Infcode
  28672. //result, _ := json.Marshal(respJSON)
  28673. //if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  28674. // utils.ErrorLog("解析失败:%v", err)
  28675. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28676. // return
  28677. //}
  28678. //
  28679. //resThree.ErrMsg = resThree10265.ErrMsg
  28680. //
  28681. //resThree.Output = resThree10265.Output
  28682. //
  28683. //resThree.InfRefmsgid = resThree10265.InfRefmsgid
  28684. //
  28685. //infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  28686. //
  28687. } else {
  28688. 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)
  28689. var dat map[string]interface{}
  28690. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  28691. fmt.Println(dat)
  28692. } else {
  28693. fmt.Println(err)
  28694. }
  28695. userJSONBytes, _ := json.Marshal(dat)
  28696. if miConfig.Code == "H15049901371" {
  28697. if err := json.Unmarshal(userJSONBytes, &res10265_2); err != nil {
  28698. utils.ErrorLog("解析失败:%v", err)
  28699. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28700. return
  28701. }
  28702. res2.ErrMsg = res10265_2.ErrMsg
  28703. infocode, _ := strconv.ParseInt(res10265_2.Infcode, 10, 64)
  28704. res2.Infcode = infocode
  28705. res2.Output = res10265_2.Output
  28706. res2.InfRefmsgid = res10265_2.InfRefmsgid
  28707. } else {
  28708. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  28709. utils.ErrorLog("解析失败:%v", err)
  28710. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28711. return
  28712. }
  28713. }
  28714. }
  28715. }
  28716. if res2.Infcode == 0 {
  28717. psnResult := &models.GdybPsnNcdsRecord{
  28718. UserOrgId: adminUser.CurrentOrgId,
  28719. PatientId: patient.ID,
  28720. PsnNo: psn_no,
  28721. DoctorId: doctor.AdminUserId,
  28722. DepartmentId: department_id,
  28723. SickType: sick_id,
  28724. Insutype: insutype,
  28725. Ctime: time.Now().Unix(),
  28726. Mtime: time.Now().Unix(),
  28727. Status: 1,
  28728. IsCancel: 1,
  28729. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  28730. }
  28731. service.CreatePsnNCDSRecord(psnResult)
  28732. c.ServeSuccessJSON(map[string]interface{}{
  28733. "failed_code": 0,
  28734. "msg": "备案成功",
  28735. "result": psnResult,
  28736. })
  28737. } else {
  28738. c.ServeSuccessJSON(map[string]interface{}{
  28739. "failed_code": -10,
  28740. "msg": res2.ErrMsg,
  28741. })
  28742. return
  28743. }
  28744. }
  28745. }
  28746. func (c *HisApiController) PsnPutUnNCDSOnRecord() {
  28747. id, _ := c.GetInt64("id")
  28748. admin_user_id, _ := c.GetInt64("admin_user_id")
  28749. adminUser := c.GetAdminUserInfo()
  28750. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  28751. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  28752. //config, _ := service.Ge(adminUser.CurrentOrgId)
  28753. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  28754. //role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  28755. //var user_name string
  28756. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  28757. //if role.ID == 0 {
  28758. // user_name = "xxx"
  28759. //} else {
  28760. // user_name = role.UserName
  28761. //}
  28762. psn_record, _ := service.GetPsnNCDSRecordById(id)
  28763. if psn_record.ID == 0 {
  28764. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  28765. return
  28766. }
  28767. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  28768. var res ResultTwo
  28769. var res10265 ResultTwo10265
  28770. if miConfig.Code == "H15049901371" {
  28771. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  28772. utils.ErrorLog("解析失败:%v", err)
  28773. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28774. return
  28775. }
  28776. res.ErrMsg = res10265.ErrMsg
  28777. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  28778. res.Infcode = infocode
  28779. res.Output = res10265.Output
  28780. res.InfRefmsgid = res10265.InfRefmsgid
  28781. } else {
  28782. if err := json.Unmarshal([]byte(result), &res); err != nil {
  28783. utils.ErrorLog("解析失败:%v", err)
  28784. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28785. return
  28786. }
  28787. }
  28788. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  28789. infoStr := string(Iinfos)
  28790. var rf []*ResultFive
  28791. json.Unmarshal([]byte(infoStr), &rf)
  28792. var insuplc_admdvs string
  28793. var insutype string
  28794. var is390 int = 0
  28795. var is310 int = 0
  28796. var insutypes []*ResultFive
  28797. for _, item := range rf {
  28798. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  28799. insutypes = append(insutypes, item)
  28800. }
  28801. }
  28802. if len(insutypes) == 1 {
  28803. insutype = insutypes[0].Insutype
  28804. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  28805. } else {
  28806. for _, i := range insutypes {
  28807. if i.Insutype == "390" {
  28808. is390 = 1
  28809. }
  28810. if i.Insutype == "310" {
  28811. is310 = 1
  28812. }
  28813. }
  28814. }
  28815. if is390 == 1 {
  28816. insutype = "390"
  28817. }
  28818. if is310 == 1 {
  28819. insutype = "310"
  28820. }
  28821. if len(insutypes) == 0 {
  28822. insutype = "310"
  28823. }
  28824. insutype = psn_record.Insutype
  28825. for _, item := range rf {
  28826. if item.Insutype == insutype {
  28827. insuplc_admdvs = item.InsuplcAdmdvs
  28828. }
  28829. }
  28830. if config.IsOpen == 1 {
  28831. result := service.Gdyb2504(psn_record.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, insuplc_admdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  28832. var dat map[string]interface{}
  28833. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  28834. fmt.Println(dat)
  28835. } else {
  28836. fmt.Println(err)
  28837. }
  28838. userJSONBytes, _ := json.Marshal(dat)
  28839. var res ResultFourteen
  28840. var res10265 ResultFourteen10265
  28841. if miConfig.Code == "H15049901371" {
  28842. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  28843. utils.ErrorLog("解析失败:%v", err)
  28844. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28845. return
  28846. }
  28847. res.ErrMsg = res10265.ErrMsg
  28848. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  28849. res.Infcode = infocode
  28850. res.Output = res10265.Output
  28851. res.InfRefmsgid = res10265.InfRefmsgid
  28852. } else {
  28853. if err := json.Unmarshal([]byte(result), &res); err != nil {
  28854. utils.ErrorLog("解析失败:%v", err)
  28855. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28856. return
  28857. }
  28858. }
  28859. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28860. // utils.ErrorLog("解析失败:%v", err)
  28861. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28862. // return
  28863. //}
  28864. if res.Infcode == 0 {
  28865. psn_record.IsCancel = 2
  28866. service.CreatePsnNCDSRecord(&psn_record)
  28867. c.ServeSuccessJSON(map[string]interface{}{
  28868. "failed_code": 0,
  28869. "msg": "撤销备案成功",
  28870. })
  28871. } else {
  28872. c.ServeSuccessJSON(map[string]interface{}{
  28873. "failed_code": -10,
  28874. "msg": res.ErrMsg,
  28875. })
  28876. return
  28877. }
  28878. }
  28879. }
  28880. func (c *HisApiController) TestTest() {
  28881. patient, _ := service.GetHisPatientInfo(4, 456, 1619712000)
  28882. fmt.Println(patient.Iinfo)
  28883. }
  28884. type CustomData struct {
  28885. MsgId string
  28886. PsnNo string
  28887. Info string
  28888. }
  28889. func (c *HisApiController) ReversalData() {
  28890. var customData []*CustomData
  28891. custom := &CustomData{
  28892. MsgId: "H44022900158202103301714472004",
  28893. PsnNo: "44020000001101329945",
  28894. Info: "2207",
  28895. }
  28896. customData = append(customData, custom)
  28897. custom1 := &CustomData{
  28898. MsgId: "H4402290015820210330172057803",
  28899. PsnNo: "44020000001101161813",
  28900. Info: "2207",
  28901. }
  28902. customData = append(customData, custom1)
  28903. custom2 := &CustomData{
  28904. MsgId: "H44022900158202103301705198813",
  28905. PsnNo: "44190000133097375417",
  28906. Info: "2207",
  28907. }
  28908. customData = append(customData, custom2)
  28909. custom3 := &CustomData{
  28910. MsgId: "H44022900158202103301715524756",
  28911. PsnNo: "44020000001100187221",
  28912. Info: "2207",
  28913. }
  28914. customData = append(customData, custom3)
  28915. custom4 := &CustomData{
  28916. MsgId: "H44022900158202103301730376224",
  28917. PsnNo: "44020000001101959155",
  28918. Info: "2207",
  28919. }
  28920. customData = append(customData, custom4)
  28921. custom5 := &CustomData{
  28922. MsgId: "H44022900158202103301748008725",
  28923. PsnNo: "44020000001104246641",
  28924. Info: "2207",
  28925. }
  28926. customData = append(customData, custom5)
  28927. custom6 := &CustomData{
  28928. MsgId: "H44022900158202103301718096755",
  28929. PsnNo: "44020000001102211860",
  28930. Info: "2207",
  28931. }
  28932. customData = append(customData, custom6)
  28933. custom7 := &CustomData{
  28934. MsgId: "H44022900158202103301736551640",
  28935. PsnNo: "44020000001102687718",
  28936. Info: "2207",
  28937. }
  28938. customData = append(customData, custom7)
  28939. custom8 := &CustomData{
  28940. MsgId: "H44022900158202103301743097676",
  28941. PsnNo: "44020000001102127785",
  28942. Info: "2207",
  28943. }
  28944. customData = append(customData, custom8)
  28945. custom9 := &CustomData{
  28946. MsgId: "H44022900158202103301712304203",
  28947. PsnNo: "44020000001101518097",
  28948. Info: "2207",
  28949. }
  28950. customData = append(customData, custom9)
  28951. custom10 := &CustomData{
  28952. MsgId: "H44022900158202103301738448785",
  28953. PsnNo: "44020000001100500813",
  28954. Info: "2207",
  28955. }
  28956. customData = append(customData, custom10)
  28957. custom11 := &CustomData{
  28958. MsgId: "H44022900158202103301732455843",
  28959. PsnNo: "44020000001102690557",
  28960. Info: "2207",
  28961. }
  28962. customData = append(customData, custom11)
  28963. custom12 := &CustomData{
  28964. MsgId: "H44022900158202103301745421708",
  28965. PsnNo: "44020000001102211928",
  28966. Info: "2207",
  28967. }
  28968. customData = append(customData, custom12)
  28969. custom1212 := &CustomData{
  28970. MsgId: "H440229001582021033017351627",
  28971. PsnNo: "44020000001102481733",
  28972. Info: "2207",
  28973. }
  28974. customData = append(customData, custom1212)
  28975. custom13 := &CustomData{
  28976. MsgId: "H44022900158202103301740327951",
  28977. PsnNo: "44020000001103174866",
  28978. Info: "2207",
  28979. }
  28980. customData = append(customData, custom13)
  28981. custom14 := &CustomData{
  28982. MsgId: "H4402290015820210330174922668",
  28983. PsnNo: "44020000001102927272",
  28984. Info: "2207",
  28985. }
  28986. customData = append(customData, custom14)
  28987. custom15 := &CustomData{
  28988. MsgId: "H44022900158202103301752362273",
  28989. PsnNo: "44020000001102942890",
  28990. Info: "2207",
  28991. }
  28992. customData = append(customData, custom15)
  28993. custom16 := &CustomData{
  28994. MsgId: "H44022900158202103301751082917",
  28995. PsnNo: "44020000001101662162",
  28996. Info: "2207",
  28997. }
  28998. customData = append(customData, custom16)
  28999. custom17 := &CustomData{
  29000. MsgId: "H44022900158202103301754147728",
  29001. PsnNo: "44020000000229014511",
  29002. Info: "2207",
  29003. }
  29004. customData = append(customData, custom17)
  29005. adminUser := c.GetAdminUserInfo()
  29006. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  29007. for _, item := range customData {
  29008. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  29009. fmt.Println(result)
  29010. }
  29011. }
  29012. func (c *HisApiController) GetAllopatry() {
  29013. year := c.GetString("year")
  29014. month := c.GetString("month")
  29015. admin_user_id, _ := c.GetInt64("admin_user_id")
  29016. adminUser := c.GetAdminUserInfo()
  29017. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  29018. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  29019. result, _ := service.Gdyb9001Two(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  29020. var dat map[string]interface{}
  29021. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  29022. fmt.Println(dat)
  29023. } else {
  29024. fmt.Println(err)
  29025. }
  29026. userJSONBytes, _ := json.Marshal(dat)
  29027. var res models.Result9001
  29028. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29029. utils.ErrorLog("解析失败:%v", err)
  29030. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29031. return
  29032. }
  29033. fmt.Println(res.Output.Signinoutb)
  29034. fmt.Println(res.Output.Signinoutb.SignNo)
  29035. fmt.Println(string(userJSONBytes))
  29036. result3, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo, 0)
  29037. var dat3 map[string]interface{}
  29038. if err := json.Unmarshal([]byte(result3), &dat3); err == nil {
  29039. fmt.Println(dat3)
  29040. } else {
  29041. fmt.Println(err)
  29042. }
  29043. userJSONBytes3, _ := json.Marshal(dat3)
  29044. var res3 models.Result3260
  29045. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  29046. utils.ErrorLog("解析失败:%v", err)
  29047. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29048. return
  29049. }
  29050. var curpage int
  29051. var pagesize int = 100
  29052. var start int = 1
  29053. //var stop int
  29054. //pagecount := 10
  29055. pagecount := int(math.Ceil(float64(res3.Output.Totalrow) / float64(pagesize)))
  29056. var res22 []models.Result3260
  29057. for curpage = 1; curpage <= pagecount; curpage++ {
  29058. if curpage == 1 {
  29059. start = 0
  29060. } else {
  29061. start = (curpage-1)*pagesize + 1
  29062. }
  29063. fmt.Println(start)
  29064. //stop = curpage * pagesize
  29065. //if stop > int(res3.Output.Totalrow) {
  29066. // stop =int(res3.Output.Totalrow)
  29067. //}
  29068. result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo, start)
  29069. var dat2 map[string]interface{}
  29070. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  29071. fmt.Println(dat)
  29072. } else {
  29073. fmt.Println(err)
  29074. }
  29075. userJSONBytes2, _ := json.Marshal(dat2)
  29076. var res2 models.Result3260
  29077. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  29078. utils.ErrorLog("解析失败:%v", err)
  29079. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29080. return
  29081. }
  29082. if res2.Infcode == 0 {
  29083. res22 = append(res22, res2)
  29084. //service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res2, res.Output.Signinoutb.SignNo)
  29085. //var dat2 map[string]interface{}
  29086. //if err := json.Unmarshal([]byte(result3), &dat2); err == nil {
  29087. // fmt.Println(dat)
  29088. //} else {
  29089. // fmt.Println(err)
  29090. //}
  29091. //c.ServeSuccessJSON(map[string]interface{}{
  29092. // "list": res2.Output.Data,
  29093. //})
  29094. //continue
  29095. }
  29096. }
  29097. service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res22, res.Output.Signinoutb.SignNo)
  29098. //service.Gdyb3263(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res22, res.Output.Signinoutb.SignNo)
  29099. //result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo, 101)
  29100. //var dat2 map[string]interface{}
  29101. //if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  29102. // fmt.Println(dat)
  29103. //} else {
  29104. // fmt.Println(err)
  29105. //}
  29106. //userJSONBytes2, _ := json.Marshal(dat2)
  29107. //var res2 models.Result3260
  29108. //if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  29109. // utils.ErrorLog("解析失败:%v", err)
  29110. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29111. // return
  29112. //}
  29113. //if res2.Infcode == 0 {
  29114. // service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res2, res.Output.Signinoutb.SignNo)
  29115. // var dat2 map[string]interface{}
  29116. // if err := json.Unmarshal([]byte(result3), &dat2); err == nil {
  29117. // fmt.Println(dat)
  29118. // } else {
  29119. // fmt.Println(err)
  29120. // }
  29121. // c.ServeSuccessJSON(map[string]interface{}{
  29122. // "list": res2.Output.Data,
  29123. // })
  29124. //}
  29125. }
  29126. func (c *HisApiController) ComfirmAllopatry() {
  29127. year := c.GetString("year")
  29128. month := c.GetString("month")
  29129. admin_user_id, _ := c.GetInt64("admin_user_id")
  29130. adminUser := c.GetAdminUserInfo()
  29131. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  29132. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  29133. result, _ := service.Gdyb9001Two(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  29134. var dat map[string]interface{}
  29135. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  29136. fmt.Println(dat)
  29137. } else {
  29138. fmt.Println(err)
  29139. }
  29140. userJSONBytes, _ := json.Marshal(dat)
  29141. var res models.Result9001
  29142. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29143. utils.ErrorLog("解析失败:%v", err)
  29144. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29145. return
  29146. }
  29147. result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo, 0)
  29148. var dat2 map[string]interface{}
  29149. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  29150. fmt.Println(dat)
  29151. } else {
  29152. fmt.Println(err)
  29153. }
  29154. userJSONBytes2, _ := json.Marshal(dat2)
  29155. var res2 models.Result3260
  29156. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  29157. utils.ErrorLog("解析失败:%v", err)
  29158. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29159. return
  29160. }
  29161. //if res2.Infcode == 0 {
  29162. // result, _, msgId := service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res2, res.Output.Signinoutb.SignNo)
  29163. // var dat map[string]interface{}
  29164. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  29165. // fmt.Println(dat)
  29166. // } else {
  29167. // fmt.Println(err)
  29168. // }
  29169. // userJSONBytes, _ := json.Marshal(dat)
  29170. // var res3 models.Result3261
  29171. // if err := json.Unmarshal(userJSONBytes, &res3); err != nil {
  29172. // utils.ErrorLog("解析失败:%v", err)
  29173. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29174. // return
  29175. // }
  29176. //
  29177. // if res3.Infcode == 0 {
  29178. // record := &models.HisYidiClearRecord{
  29179. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  29180. // Ctime: time.Now().Unix(),
  29181. // Mtime: time.Now().Unix(),
  29182. // Status: 1,
  29183. // MsgId: msgId,
  29184. // }
  29185. // service.SaveClearRecord(record)
  29186. // c.ServeSuccessJSON(map[string]interface{}{
  29187. // "msg": "提取成功",
  29188. // })
  29189. // }
  29190. //}
  29191. }
  29192. func (c *HisApiController) RefundAllopatry() {
  29193. year := c.GetString("year")
  29194. month := c.GetString("month")
  29195. //id, _ := c.GetInt64("id")
  29196. admin_user_id, _ := c.GetInt64("admin_user_id")
  29197. adminUser := c.GetAdminUserInfo()
  29198. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  29199. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  29200. //record, _ := service.GetClearRecordById(id)
  29201. result2, _ := service.Gdyb9001Two(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  29202. var dat map[string]interface{}
  29203. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  29204. fmt.Println(dat)
  29205. } else {
  29206. fmt.Println(err)
  29207. }
  29208. userJSONBytes, _ := json.Marshal(dat)
  29209. var res models.Result9001
  29210. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29211. utils.ErrorLog("解析失败:%v", err)
  29212. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29213. return
  29214. }
  29215. result, _ := service.Gdyb3262(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, "", res.Output.Signinoutb.SignNo)
  29216. var dat2 map[string]interface{}
  29217. if err := json.Unmarshal([]byte(result), &dat2); err == nil {
  29218. fmt.Println(dat)
  29219. } else {
  29220. fmt.Println(err)
  29221. }
  29222. userJSONBytes2, _ := json.Marshal(dat2)
  29223. var empty ResultFourteen
  29224. if err := json.Unmarshal(userJSONBytes2, &empty); err != nil {
  29225. utils.ErrorLog("解析失败:%v", err)
  29226. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29227. return
  29228. }
  29229. if empty.Infcode == 0 {
  29230. c.ServeSuccessJSON(map[string]interface{}{
  29231. "msg": "撤销成功",
  29232. })
  29233. return
  29234. }
  29235. }
  29236. func (c *HisApiController) ReversalOtherData() {
  29237. var customData []*CustomData
  29238. custom := &CustomData{
  29239. MsgId: "H44022900158202103301714472004",
  29240. PsnNo: "44020000001101329945",
  29241. Info: "2208",
  29242. }
  29243. customData = append(customData, custom)
  29244. custom1 := &CustomData{
  29245. MsgId: "H4402290015820210330172057803",
  29246. PsnNo: "44020000001101161813",
  29247. Info: "2208",
  29248. }
  29249. customData = append(customData, custom1)
  29250. custom2 := &CustomData{
  29251. MsgId: "H44022900158202103301705198813",
  29252. PsnNo: "44190000133097375417",
  29253. Info: "2208",
  29254. }
  29255. customData = append(customData, custom2)
  29256. custom3 := &CustomData{
  29257. MsgId: "H44022900158202103301715524756",
  29258. PsnNo: "44020000001100187221",
  29259. Info: "2208",
  29260. }
  29261. customData = append(customData, custom3)
  29262. custom4 := &CustomData{
  29263. MsgId: "H44022900158202103301730376224",
  29264. PsnNo: "44020000001101959155",
  29265. Info: "2208",
  29266. }
  29267. customData = append(customData, custom4)
  29268. custom5 := &CustomData{
  29269. MsgId: "H44022900158202103301748008725",
  29270. PsnNo: "44020000001104246641",
  29271. Info: "2208",
  29272. }
  29273. customData = append(customData, custom5)
  29274. custom6 := &CustomData{
  29275. MsgId: "H44022900158202103301718096755",
  29276. PsnNo: "44020000001102211860",
  29277. Info: "2208",
  29278. }
  29279. customData = append(customData, custom6)
  29280. custom7 := &CustomData{
  29281. MsgId: "H44022900158202103301736551640",
  29282. PsnNo: "44020000001102687718",
  29283. Info: "2208",
  29284. }
  29285. customData = append(customData, custom7)
  29286. custom8 := &CustomData{
  29287. MsgId: "H44022900158202103301743097676",
  29288. PsnNo: "44020000001102127785",
  29289. Info: "2208",
  29290. }
  29291. customData = append(customData, custom8)
  29292. custom9 := &CustomData{
  29293. MsgId: "H44022900158202103301712304203",
  29294. PsnNo: "44020000001101518097",
  29295. Info: "2208",
  29296. }
  29297. customData = append(customData, custom9)
  29298. custom10 := &CustomData{
  29299. MsgId: "H44022900158202103301738448785",
  29300. PsnNo: "44020000001100500813",
  29301. Info: "2208",
  29302. }
  29303. customData = append(customData, custom10)
  29304. custom11 := &CustomData{
  29305. MsgId: "H44022900158202103301732455843",
  29306. PsnNo: "44020000001102690557",
  29307. Info: "2208",
  29308. }
  29309. customData = append(customData, custom11)
  29310. custom12 := &CustomData{
  29311. MsgId: "H44022900158202103301745421708",
  29312. PsnNo: "44020000001102211928",
  29313. Info: "2208",
  29314. }
  29315. customData = append(customData, custom12)
  29316. custom1212 := &CustomData{
  29317. MsgId: "H440229001582021033017351627",
  29318. PsnNo: "44020000001102481733",
  29319. Info: "2208",
  29320. }
  29321. customData = append(customData, custom1212)
  29322. custom13 := &CustomData{
  29323. MsgId: "H44022900158202103301740327951",
  29324. PsnNo: "44020000001103174866",
  29325. Info: "2208",
  29326. }
  29327. customData = append(customData, custom13)
  29328. custom14 := &CustomData{
  29329. MsgId: "H4402290015820210330174922668",
  29330. PsnNo: "44020000001102927272",
  29331. Info: "2208",
  29332. }
  29333. customData = append(customData, custom14)
  29334. custom15 := &CustomData{
  29335. MsgId: "H44022900158202103301752362273",
  29336. PsnNo: "44020000001102942890",
  29337. Info: "2208",
  29338. }
  29339. customData = append(customData, custom15)
  29340. custom16 := &CustomData{
  29341. MsgId: "H44022900158202103301751082917",
  29342. PsnNo: "44020000001101662162",
  29343. Info: "2208",
  29344. }
  29345. customData = append(customData, custom16)
  29346. custom17 := &CustomData{
  29347. MsgId: "H44022900158202103301754147728",
  29348. PsnNo: "44020000000229014511",
  29349. Info: "2208",
  29350. }
  29351. customData = append(customData, custom17)
  29352. adminUser := c.GetAdminUserInfo()
  29353. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  29354. for _, item := range customData {
  29355. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  29356. fmt.Println(result)
  29357. }
  29358. }
  29359. func PathExists(path string) (bool, error) {
  29360. _, err := os.Stat(path)
  29361. if err == nil {
  29362. return true, nil
  29363. }
  29364. if os.IsNotExist(err) {
  29365. return false, nil
  29366. }
  29367. return false, err
  29368. }
  29369. // 创建文件夹
  29370. func Mkdir(dir string) {
  29371. // 创建文件夹
  29372. exist, err := PathExists(dir)
  29373. if err != nil {
  29374. fmt.Println(err.Error())
  29375. } else {
  29376. if exist {
  29377. fmt.Println(dir + "文件夹已存在!")
  29378. } else {
  29379. // 文件夹名称,权限
  29380. err := os.Mkdir(dir, os.ModePerm)
  29381. if err != nil {
  29382. fmt.Println(dir+"文件夹创建失败:", err.Error())
  29383. } else {
  29384. fmt.Println(dir + "文件夹创建成功!")
  29385. }
  29386. }
  29387. }
  29388. }
  29389. // 压缩文件
  29390. func Zip(srcFile string, destZip string) error {
  29391. zipfile, err := os.Create(destZip)
  29392. if err != nil {
  29393. return err
  29394. }
  29395. defer zipfile.Close()
  29396. archive := zip.NewWriter(zipfile)
  29397. defer archive.Close()
  29398. filepath.Walk(srcFile, func(path string, info os.FileInfo, err error) error {
  29399. if err != nil {
  29400. return err
  29401. }
  29402. header, err := zip.FileInfoHeader(info)
  29403. if err != nil {
  29404. return err
  29405. }
  29406. header.Name = strings.TrimPrefix(path, filepath.Dir(srcFile)+"/")
  29407. // header.Name = path
  29408. if info.IsDir() {
  29409. header.Name += "/"
  29410. } else {
  29411. header.Method = zip.Deflate
  29412. }
  29413. writer, err := archive.CreateHeader(header)
  29414. if err != nil {
  29415. return err
  29416. }
  29417. if !info.IsDir() {
  29418. file, err := os.Open(path)
  29419. if err != nil {
  29420. return err
  29421. }
  29422. defer file.Close()
  29423. _, err = io.Copy(writer, file)
  29424. }
  29425. return err
  29426. })
  29427. return err
  29428. }
  29429. func ReadFile(filePath string) []byte {
  29430. f, err := os.Open(filePath)
  29431. if err != nil {
  29432. fmt.Println("read file fail", err)
  29433. return nil
  29434. }
  29435. defer f.Close()
  29436. fd, err := ioutil.ReadAll(f)
  29437. if err != nil {
  29438. fmt.Println("read to fd fail", err)
  29439. return nil
  29440. }
  29441. return fd
  29442. }
  29443. func saveLogq(result string, request string, infno string, desc string) {
  29444. dir := "日志"
  29445. utils.Mkdir(dir)
  29446. month := time.Unix(1557042972, 0).Format("1")
  29447. year := time.Now().Format("2006")
  29448. month = time.Now().Format("01")
  29449. day := time.Now().Format("02")
  29450. hour := time.Now().Format("15")
  29451. min := time.Now().Format("04")
  29452. sec := time.Now().Format("05")
  29453. result_time := year + "-" + month + "-" + day + " " + hour + ":" + min + ":" + sec
  29454. file := year + month + day + "_log"
  29455. file_name := file + ".txt"
  29456. file_path := "日志" + "/" + file_name
  29457. exist, _ := utils.PathExists(file_path)
  29458. if exist { //存在
  29459. fmt.Println("存在")
  29460. f, err := os.OpenFile(file_path, os.O_WRONLY, 0644)
  29461. if err != nil {
  29462. fmt.Println("read fail")
  29463. }
  29464. content := "\r\n" + "\r\n" + "\r\n" + result_time + " " + "【 " + desc + infno + "入参" + " 】:" + "\r\n" + request + "\r\n" + result_time + " " + "【 " + desc + infno + "出参" + " 】:" + "\r\n" + result
  29465. n, _ := f.Seek(0, 2)
  29466. _, err = f.WriteAt([]byte(content), n)
  29467. } else { //不存在
  29468. fmt.Println("文件不存在,创建文件")
  29469. f, err := os.Create("日志" + "/" + file_name)
  29470. defer f.Close()
  29471. if err != nil {
  29472. } else {
  29473. _, err = f.Write([]byte("记录日志"))
  29474. }
  29475. }
  29476. }
  29477. func saveLog(result string, request string, infno string, desc string) {
  29478. org_id, _ := beego.AppConfig.Int64("org_id")
  29479. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  29480. dir := miConfig.OrgName + "日志"
  29481. utils.Mkdir(dir)
  29482. month := time.Unix(1557042972, 0).Format("1")
  29483. year := time.Now().Format("2006")
  29484. month = time.Now().Format("01")
  29485. day := time.Now().Format("02")
  29486. hour := time.Now().Format("15")
  29487. min := time.Now().Format("04")
  29488. sec := time.Now().Format("05")
  29489. result_time := year + "-" + month + "-" + day + " " + hour + ":" + min + ":" + sec
  29490. file := strconv.FormatInt(org_id, 10) + "_" + year + month + day + "_log"
  29491. file_name := file + ".txt"
  29492. file_path := miConfig.OrgName + "日志" + "/" + file_name
  29493. exist, _ := utils.PathExists(file_path)
  29494. if exist { //存在
  29495. fmt.Println("存在")
  29496. f, err := os.OpenFile(file_path, os.O_WRONLY, 0644)
  29497. if err != nil {
  29498. fmt.Println("read fail")
  29499. }
  29500. content := "\r\n" + "\r\n" + "\r\n" + result_time + " " + "【 " + desc + infno + "入参" + " 】:" + "\r\n" + request + "\r\n" + result_time + " " + "【 " + desc + infno + "出参" + " 】:" + "\r\n" + result
  29501. n, _ := f.Seek(0, 2)
  29502. _, err = f.WriteAt([]byte(content), n)
  29503. } else { //不存在
  29504. fmt.Println("文件不存在,创建文件")
  29505. f, err := os.Create(miConfig.OrgName + "日志" + "/" + file_name)
  29506. defer f.Close()
  29507. if err != nil {
  29508. } else {
  29509. _, err = f.Write([]byte("记录日志"))
  29510. }
  29511. }
  29512. }
  29513. type Charset string
  29514. const (
  29515. UTF8 = Charset("UTF-8")
  29516. GB18030 = Charset("GB18030")
  29517. )
  29518. func ConvertToString(src string, srcCode string, tagCode string) string {
  29519. srcCoder := mahonia.NewDecoder(srcCode)
  29520. srcResult := srcCoder.ConvertString(src)
  29521. tagCoder := mahonia.NewDecoder(tagCode)
  29522. _, cdata, _ := tagCoder.Translate([]byte(srcResult), true)
  29523. result := string(cdata)
  29524. return result
  29525. }
  29526. func ReadEleCard(admin_user_id int64, org_id int64, c *HisApiController) string {
  29527. roles, _ := service.GetAdminUserInfoByID(org_id, admin_user_id)
  29528. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  29529. var token string
  29530. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  29531. var api string
  29532. if miConfig.MdtrtareaAdmvs == "320921" {
  29533. 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 +
  29534. "&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
  29535. fmt.Println(api)
  29536. } else {
  29537. 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 +
  29538. "&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
  29539. }
  29540. resp, requestErr := http.Get(api)
  29541. if requestErr != nil {
  29542. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29543. return ""
  29544. }
  29545. body, ioErr := ioutil.ReadAll(resp.Body)
  29546. if ioErr != nil {
  29547. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29548. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29549. return ""
  29550. }
  29551. var respJSON map[string]interface{}
  29552. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  29553. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29554. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29555. return ""
  29556. }
  29557. var status string
  29558. status = respJSON["data"].(map[string]interface{})["status"].(string)
  29559. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  29560. var res ResultTwo //1101结果
  29561. var res10265 ResultTwo10265 //1101结果
  29562. if status == "0" { //读卡成功
  29563. var card_info string //卡信息
  29564. var busi_card_info string
  29565. token = respJSON["data"].(map[string]interface{})["token"].(string)
  29566. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  29567. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  29568. fmt.Println(card_info)
  29569. fmt.Println(busi_card_info)
  29570. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  29571. result, _ := json.Marshal(respJSON)
  29572. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  29573. utils.ErrorLog("解析失败:%v", err)
  29574. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29575. return ""
  29576. }
  29577. res.ErrMsg = res10265.ErrMsg
  29578. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  29579. res.Infcode = infocode
  29580. res.Output = res10265.Output
  29581. res.InfRefmsgid = res10265.InfRefmsgid
  29582. if res.Infcode == 0 {
  29583. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  29584. if err == gorm.ErrRecordNotFound {
  29585. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  29586. return ""
  29587. } else if err != nil {
  29588. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  29589. return ""
  29590. } else {
  29591. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  29592. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  29593. infoStr := string(Iinfos)
  29594. idetinfoStr := string(Idetinfos)
  29595. psn := &models.HisPsn{
  29596. PsnNo: res.Output.Baseinfo.PsnNo,
  29597. PatientId: patient.ID,
  29598. Certno: res.Output.Baseinfo.Certno,
  29599. Gend: res.Output.Baseinfo.Gend,
  29600. Naty: res.Output.Baseinfo.Naty,
  29601. PsnCertType: res.Output.Baseinfo.PsnCertType,
  29602. PsnName: res.Output.Baseinfo.PsnName,
  29603. Idetinfo: idetinfoStr,
  29604. Insuinfo: infoStr,
  29605. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  29606. CardInfo: card_info,
  29607. VerifyNumber: token,
  29608. }
  29609. service.CreateHisPsn(psn)
  29610. return token
  29611. }
  29612. }
  29613. } else {
  29614. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  29615. return ""
  29616. }
  29617. } else { //读卡失败
  29618. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  29619. return ""
  29620. }
  29621. return token
  29622. }
  29623. func ReadEleCardforah(admin_user_id int64, org_id int64, c *HisApiController) string {
  29624. roles, _ := service.GetAdminUserInfoByID(org_id, admin_user_id)
  29625. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  29626. var token string
  29627. var api string
  29628. api = miConfig.SecretKey + "ahyb/readcardcharge?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  29629. "&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
  29630. fmt.Println(api)
  29631. resp, requestErr := http.Get(api)
  29632. if requestErr != nil {
  29633. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29634. return ""
  29635. }
  29636. body, ioErr := ioutil.ReadAll(resp.Body)
  29637. if ioErr != nil {
  29638. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29639. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29640. return ""
  29641. }
  29642. var respJSON map[string]interface{}
  29643. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  29644. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29645. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29646. return ""
  29647. }
  29648. var status string
  29649. status = respJSON["data"].(map[string]interface{})["status"].(string)
  29650. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  29651. var res ResultTwo //1101结果
  29652. if status == "1" { //读卡成功
  29653. var card_info string //卡信息
  29654. var busi_card_info string
  29655. token = respJSON["data"].(map[string]interface{})["token"].(string)
  29656. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  29657. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  29658. fmt.Println(card_info)
  29659. fmt.Println(busi_card_info)
  29660. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  29661. result, _ := json.Marshal(respJSON)
  29662. if err := json.Unmarshal([]byte(result), &res); err != nil {
  29663. utils.ErrorLog("解析失败:%v", err)
  29664. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29665. return ""
  29666. }
  29667. if res.Infcode == 0 {
  29668. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  29669. if err == gorm.ErrRecordNotFound {
  29670. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  29671. return ""
  29672. } else if err != nil {
  29673. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  29674. return ""
  29675. } else {
  29676. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  29677. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  29678. infoStr := string(Iinfos)
  29679. idetinfoStr := string(Idetinfos)
  29680. psn := &models.HisPsn{
  29681. PsnNo: res.Output.Baseinfo.PsnNo,
  29682. PatientId: patient.ID,
  29683. Certno: res.Output.Baseinfo.Certno,
  29684. Gend: res.Output.Baseinfo.Gend,
  29685. Naty: res.Output.Baseinfo.Naty,
  29686. PsnCertType: res.Output.Baseinfo.PsnCertType,
  29687. PsnName: res.Output.Baseinfo.PsnName,
  29688. Idetinfo: idetinfoStr,
  29689. Insuinfo: infoStr,
  29690. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  29691. CardInfo: card_info,
  29692. VerifyNumber: token,
  29693. }
  29694. service.CreateHisPsn(psn)
  29695. return token
  29696. }
  29697. }
  29698. } else {
  29699. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  29700. return ""
  29701. }
  29702. return token
  29703. }
  29704. func ReadEleFace(admin_user_id int64, org_id int64, c *HisApiController) string {
  29705. roles, _ := service.GetAdminUserInfoByID(org_id, admin_user_id)
  29706. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  29707. var token string
  29708. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  29709. var api string
  29710. if miConfig.MdtrtareaAdmvs == "320921" {
  29711. 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 +
  29712. "&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
  29713. fmt.Println(api)
  29714. } else {
  29715. 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 +
  29716. "&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
  29717. }
  29718. resp, requestErr := http.Get(api)
  29719. if requestErr != nil {
  29720. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29721. return ""
  29722. }
  29723. body, ioErr := ioutil.ReadAll(resp.Body)
  29724. if ioErr != nil {
  29725. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29726. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29727. return ""
  29728. }
  29729. var respJSON map[string]interface{}
  29730. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  29731. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29732. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29733. return ""
  29734. }
  29735. var status string
  29736. status = respJSON["data"].(map[string]interface{})["status"].(string)
  29737. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  29738. var res ResultTwo //1101结果
  29739. var res10265 ResultTwo10265 //1101结果
  29740. if status == "0" { //读卡成功
  29741. var card_info string //卡信息
  29742. var busi_card_info string
  29743. token = respJSON["data"].(map[string]interface{})["token"].(string)
  29744. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  29745. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  29746. fmt.Println(card_info)
  29747. fmt.Println(busi_card_info)
  29748. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  29749. result, _ := json.Marshal(respJSON)
  29750. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  29751. utils.ErrorLog("解析失败:%v", err)
  29752. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29753. return ""
  29754. }
  29755. res.ErrMsg = res10265.ErrMsg
  29756. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  29757. res.Infcode = infocode
  29758. res.Output = res10265.Output
  29759. res.InfRefmsgid = res10265.InfRefmsgid
  29760. if res.Infcode == 0 {
  29761. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  29762. if err == gorm.ErrRecordNotFound {
  29763. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  29764. return ""
  29765. } else if err != nil {
  29766. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  29767. return ""
  29768. } else {
  29769. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  29770. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  29771. infoStr := string(Iinfos)
  29772. idetinfoStr := string(Idetinfos)
  29773. psn := &models.HisPsn{
  29774. PsnNo: res.Output.Baseinfo.PsnNo,
  29775. PatientId: patient.ID,
  29776. Certno: res.Output.Baseinfo.Certno,
  29777. Gend: res.Output.Baseinfo.Gend,
  29778. Naty: res.Output.Baseinfo.Naty,
  29779. PsnCertType: res.Output.Baseinfo.PsnCertType,
  29780. PsnName: res.Output.Baseinfo.PsnName,
  29781. Idetinfo: idetinfoStr,
  29782. Insuinfo: infoStr,
  29783. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  29784. CardInfo: card_info,
  29785. VerifyNumber: token,
  29786. }
  29787. service.CreateHisPsn(psn)
  29788. return token
  29789. }
  29790. }
  29791. } else {
  29792. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  29793. return ""
  29794. }
  29795. } else { //读卡失败
  29796. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  29797. return ""
  29798. }
  29799. return token
  29800. }
  29801. func DeleteExtraSpaceTwo(s string) string {
  29802. //删除字符串中的多余空格,有多个空格时,仅保留一个空格
  29803. s1 := strings.Replace(s, " ", " ", -1) //替换tab为空格
  29804. regstr := "\\s{2,}" //两个及两个以上空格的正则表达式
  29805. reg, _ := regexp.Compile(regstr) //编译正则表达式
  29806. s2 := make([]byte, len(s1)) //定义字符数组切片
  29807. copy(s2, s1) //将字符串复制到切片
  29808. spc_index := reg.FindStringIndex(string(s2)) //在字符串中搜索
  29809. for len(spc_index) > 0 { //找到适配项
  29810. s2 = append(s2[:spc_index[0]+1], s2[spc_index[1]:]...) //删除多余空格
  29811. spc_index = reg.FindStringIndex(string(s2)) //继续在字符串中搜索
  29812. }
  29813. return string(s2)
  29814. }
  29815. func Remove0000(s string) string {
  29816. str := make([]rune, 0, len(s))
  29817. for _, v := range []rune(s) {
  29818. if v == 0 {
  29819. continue
  29820. }
  29821. str = append(str, v)
  29822. }
  29823. return string(str)
  29824. }
  29825. func (c *HisApiController) GetELeCertInfo(code string, operator_id string, operator_name string) (string, string) {
  29826. DllDef := syscall.MustLoadDLL("HeaSecReadInfo.dll")
  29827. readCard := DllDef.MustFindProc("EcQuery")
  29828. pCardInfo := make([]byte, 8192)
  29829. pBusiCardInfo := make([]byte, 8192)
  29830. data := make(map[string]interface{})
  29831. //pData := make(map[string]interface{})
  29832. inputData := make(map[string]interface{})
  29833. inputData["orgId"] = code
  29834. inputData["businessType"] = "01101"
  29835. inputData["operatorId"] = operator_id
  29836. inputData["operatorName"] = operator_name
  29837. inputData["officeId"] = "001"
  29838. inputData["officeName"] = "血透室"
  29839. //
  29840. data["data"] = inputData
  29841. data["transType"] = "ec.query"
  29842. data["orgId"] = code
  29843. bytesData, _ := json.Marshal(data)
  29844. pCardInfo = bytesData
  29845. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&pCardInfo[0])), (uintptr)(unsafe.Pointer(&pBusiCardInfo[0])))
  29846. fmt.Println(ret2)
  29847. //fmt.Println(DeleteExtraSpace(string(bytesData)))
  29848. //fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  29849. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(bytesData)), "gbk", "utf-8"))
  29850. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  29851. if ret2 != 0 {
  29852. return "", ""
  29853. }
  29854. return DeleteExtraSpace(string(bytesData)), DeleteExtraSpace(string(pBusiCardInfo))
  29855. }
  29856. func DeleteExtraSpace(s string) string {
  29857. //删除字符串中的多余空格,有多个空格时,仅保留一个空格
  29858. s1 := strings.Replace(s, " ", " ", -1) //替换tab为空格
  29859. regstr := "\\s{2,}" //两个及两个以上空格的正则表达式
  29860. reg, _ := regexp.Compile(regstr) //编译正则表达式
  29861. s2 := make([]byte, len(s1)) //定义字符数组切片
  29862. copy(s2, s1) //将字符串复制到切片
  29863. spc_index := reg.FindStringIndex(string(s2)) //在字符串中搜索
  29864. for len(spc_index) > 0 { //找到适配项
  29865. s2 = append(s2[:spc_index[0]+1], s2[spc_index[1]:]...) //删除多余空格
  29866. spc_index = reg.FindStringIndex(string(s2)) //继续在字符串中搜索
  29867. }
  29868. return string(s2)
  29869. }
  29870. // 对账
  29871. func (c *HisApiController) Post3202() {
  29872. start_time := c.GetString("start_time")
  29873. end_time := c.GetString("end_time")
  29874. //insutype := c.GetString("insutype")
  29875. clr_type := c.GetString("clr_type")
  29876. clr_org := c.GetString("clr_optins")
  29877. admin_user_id, _ := c.GetInt64("admin_user_id")
  29878. adminUser := c.GetAdminUserInfo()
  29879. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  29880. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  29881. if len(clr_org) == 0 {
  29882. clr_org = miConfig.MdtrtareaAdmvs
  29883. }
  29884. timeLayout := "2006-01-02"
  29885. loc, _ := time.LoadLocation("Local")
  29886. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  29887. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  29888. var orders []*models.HisOrder
  29889. if clr_org == "421300" {
  29890. orders, _ = service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  29891. } else {
  29892. orders, _ = service.GetOrderByTime11222(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  29893. }
  29894. //orders_two, _ := service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, "310", "", clr_type)
  29895. //fixmedins_setl_cnt := int64(len(orders))
  29896. var medfee_sumamt float64
  29897. var acct_pay float64
  29898. var fund_pay_sumamt float64
  29899. for _, item := range orders {
  29900. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  29901. acct_pay = acct_pay + item.AcctPay
  29902. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  29903. }
  29904. //var medfee_sumamt_two float64
  29905. //var acct_pay_two float64
  29906. //var fund_pay_sumamt_two float64
  29907. //for _, item := range orders_two {
  29908. // medfee_sumamt_two = medfee_sumamt_two + item.MedfeeSumamt
  29909. // acct_pay_two = acct_pay_two + item.AcctPay
  29910. // fund_pay_sumamt_two = fund_pay_sumamt_two + item.FundPaySumamt
  29911. //}
  29912. //var user_name string
  29913. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  29914. //if role.ID == 0 {
  29915. // user_name = "xxx"
  29916. //} else {
  29917. // user_name = role.UserName
  29918. //}
  29919. var res ResultSix
  29920. if config.IsOpen == 1 {
  29921. var bps []*models.BusinessParamsTwo
  29922. var bp models.BusinessParamsTwo
  29923. medfee_sumamt_str := fmt.Sprintf("%.2f", medfee_sumamt)
  29924. acct_pay_str := fmt.Sprintf("%.2f", acct_pay)
  29925. fund_pay_sumamt_str := fmt.Sprintf("%.2f", fund_pay_sumamt)
  29926. bp.MedfeeSumamt = medfee_sumamt_str
  29927. bp.AcctPay = acct_pay_str
  29928. bp.FundPaySumamt = fund_pay_sumamt_str
  29929. bp.Insutype = ""
  29930. bp.StmtBegndate = start_time
  29931. bp.ClrType = clr_type
  29932. bp.SetlOptins = clr_org
  29933. bp.StmtEnddate = end_time
  29934. bps = append(bps, &bp)
  29935. data := make(map[string]interface{})
  29936. data["bps"] = bps
  29937. data["org_name"] = miConfig.OrgName
  29938. data["doctor"] = role.UserName
  29939. data["fixmedins_code"] = miConfig.Code
  29940. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  29941. //data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  29942. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  29943. if miConfig.MdtrtareaAdmvs == "421300" {
  29944. client := &http.Client{}
  29945. bytesData, _ := json.Marshal(data)
  29946. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/3202", bytes.NewReader(bytesData))
  29947. resp, _ := client.Do(req)
  29948. defer resp.Body.Close()
  29949. body, ioErr := ioutil.ReadAll(resp.Body)
  29950. if ioErr != nil {
  29951. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29952. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29953. return
  29954. }
  29955. var respJSON map[string]interface{}
  29956. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29957. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29958. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29959. return
  29960. }
  29961. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29962. userJSONBytes, _ := json.Marshal(respJSON)
  29963. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29964. utils.ErrorLog("解析失败:%v", err)
  29965. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29966. return
  29967. }
  29968. }
  29969. if miConfig.MdtrtareaAdmvs == "420200" {
  29970. client := &http.Client{}
  29971. bytesData, _ := json.Marshal(data)
  29972. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/3202", bytes.NewReader(bytesData))
  29973. resp, _ := client.Do(req)
  29974. defer resp.Body.Close()
  29975. body, ioErr := ioutil.ReadAll(resp.Body)
  29976. if ioErr != nil {
  29977. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29978. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29979. return
  29980. }
  29981. var respJSON map[string]interface{}
  29982. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29983. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29984. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29985. return
  29986. }
  29987. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29988. userJSONBytes, _ := json.Marshal(respJSON)
  29989. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29990. utils.ErrorLog("解析失败:%v", err)
  29991. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29992. return
  29993. }
  29994. }
  29995. if miConfig.MdtrtareaAdmvs == "421182" {
  29996. client := &http.Client{}
  29997. bytesData, _ := json.Marshal(data)
  29998. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/3202", bytes.NewReader(bytesData))
  29999. resp, _ := client.Do(req)
  30000. defer resp.Body.Close()
  30001. body, ioErr := ioutil.ReadAll(resp.Body)
  30002. if ioErr != nil {
  30003. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30004. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30005. return
  30006. }
  30007. var respJSON map[string]interface{}
  30008. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30009. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30010. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30011. return
  30012. }
  30013. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30014. userJSONBytes, _ := json.Marshal(respJSON)
  30015. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30016. utils.ErrorLog("解析失败:%v", err)
  30017. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30018. return
  30019. }
  30020. }
  30021. if res.Infcode == 0 {
  30022. c.ServeSuccessJSON(map[string]interface{}{
  30023. "msg": "发起成功",
  30024. })
  30025. } else {
  30026. c.ServeSuccessJSON(map[string]interface{}{
  30027. "failed_code": -10,
  30028. "msg": res.ErrMsg,
  30029. })
  30030. }
  30031. }
  30032. }
  30033. func (c *HisApiController) Post3202b() {
  30034. start_time := c.GetString("start_time")
  30035. end_time := c.GetString("end_time")
  30036. //insutype := c.GetString("insutype")
  30037. clr_type := c.GetString("clr_type")
  30038. clr_org := c.GetString("clr_optins")
  30039. admin_user_id, _ := c.GetInt64("admin_user_id")
  30040. adminUser := c.GetAdminUserInfo()
  30041. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  30042. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  30043. if len(clr_org) == 0 {
  30044. clr_org = miConfig.MdtrtareaAdmvs
  30045. }
  30046. timeLayout := "2006-01-02"
  30047. loc, _ := time.LoadLocation("Local")
  30048. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  30049. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  30050. orders, _ := service.GetOrderByTimeFourfor11(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  30051. //orders_two, _ := service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, "310", "", clr_type)
  30052. //fixmedins_setl_cnt := int64(len(orders))
  30053. var medfee_sumamt float64
  30054. var acct_pay float64
  30055. var fund_pay_sumamt float64
  30056. for _, item := range orders {
  30057. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  30058. acct_pay = acct_pay + item.AcctPay
  30059. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  30060. }
  30061. //var medfee_sumamt_two float64
  30062. //var acct_pay_two float64
  30063. //var fund_pay_sumamt_two float64
  30064. //for _, item := range orders_two {
  30065. // medfee_sumamt_two = medfee_sumamt_two + item.MedfeeSumamt
  30066. // acct_pay_two = acct_pay_two + item.AcctPay
  30067. // fund_pay_sumamt_two = fund_pay_sumamt_two + item.FundPaySumamt
  30068. //}
  30069. //var user_name string
  30070. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  30071. //if role.ID == 0 {
  30072. // user_name = "xxx"
  30073. //} else {
  30074. // user_name = role.UserName
  30075. //}
  30076. var res ResultSix
  30077. if config.IsOpen == 1 {
  30078. var bps []*models.BusinessParamsTwo
  30079. var bp models.BusinessParamsTwo
  30080. medfee_sumamt_str := fmt.Sprintf("%.2f", medfee_sumamt)
  30081. acct_pay_str := fmt.Sprintf("%.2f", acct_pay)
  30082. fund_pay_sumamt_str := fmt.Sprintf("%.2f", fund_pay_sumamt)
  30083. bp.MedfeeSumamt = medfee_sumamt_str
  30084. bp.AcctPay = acct_pay_str
  30085. bp.FundPaySumamt = fund_pay_sumamt_str
  30086. bp.Insutype = "390"
  30087. bp.StmtBegndate = start_time
  30088. bp.ClrType = clr_type
  30089. bp.SetlOptins = clr_org
  30090. bp.StmtEnddate = end_time
  30091. bps = append(bps, &bp)
  30092. data := make(map[string]interface{})
  30093. data["bps"] = bps
  30094. data["org_name"] = miConfig.OrgName
  30095. data["doctor"] = role.UserName
  30096. data["fixmedins_code"] = miConfig.Code
  30097. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  30098. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  30099. if miConfig.MdtrtareaAdmvs == "421300" {
  30100. client := &http.Client{}
  30101. bytesData, _ := json.Marshal(data)
  30102. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/3202b", bytes.NewReader(bytesData))
  30103. resp, _ := client.Do(req)
  30104. defer resp.Body.Close()
  30105. body, ioErr := ioutil.ReadAll(resp.Body)
  30106. if ioErr != nil {
  30107. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30108. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30109. return
  30110. }
  30111. var respJSON map[string]interface{}
  30112. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30113. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30114. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30115. return
  30116. }
  30117. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30118. userJSONBytes, _ := json.Marshal(respJSON)
  30119. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30120. utils.ErrorLog("解析失败:%v", err)
  30121. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30122. return
  30123. }
  30124. }
  30125. if miConfig.MdtrtareaAdmvs == "420200" {
  30126. client := &http.Client{}
  30127. bytesData, _ := json.Marshal(data)
  30128. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/3202b", bytes.NewReader(bytesData))
  30129. resp, _ := client.Do(req)
  30130. defer resp.Body.Close()
  30131. body, ioErr := ioutil.ReadAll(resp.Body)
  30132. if ioErr != nil {
  30133. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30134. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30135. return
  30136. }
  30137. var respJSON map[string]interface{}
  30138. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30139. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30140. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30141. return
  30142. }
  30143. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30144. userJSONBytes, _ := json.Marshal(respJSON)
  30145. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30146. utils.ErrorLog("解析失败:%v", err)
  30147. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30148. return
  30149. }
  30150. }
  30151. if miConfig.MdtrtareaAdmvs == "421182" {
  30152. client := &http.Client{}
  30153. bytesData, _ := json.Marshal(data)
  30154. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/3202b", bytes.NewReader(bytesData))
  30155. resp, _ := client.Do(req)
  30156. defer resp.Body.Close()
  30157. body, ioErr := ioutil.ReadAll(resp.Body)
  30158. if ioErr != nil {
  30159. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30160. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30161. return
  30162. }
  30163. var respJSON map[string]interface{}
  30164. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30165. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30166. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30167. return
  30168. }
  30169. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30170. userJSONBytes, _ := json.Marshal(respJSON)
  30171. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30172. utils.ErrorLog("解析失败:%v", err)
  30173. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30174. return
  30175. }
  30176. }
  30177. if res.Infcode == 0 {
  30178. c.ServeSuccessJSON(map[string]interface{}{
  30179. "msg": "发起成功",
  30180. })
  30181. } else {
  30182. c.ServeSuccessJSON(map[string]interface{}{
  30183. "failed_code": -10,
  30184. "msg": res.ErrMsg,
  30185. })
  30186. }
  30187. }
  30188. }
  30189. func (c *HisApiController) Post1608() {
  30190. start_time := c.GetString("start_time")
  30191. end_time := c.GetString("end_time")
  30192. admin_user_id, _ := c.GetInt64("admin_user_id")
  30193. adminUser := c.GetAdminUserInfo()
  30194. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  30195. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  30196. timeLayout := "2006-01-02"
  30197. loc, _ := time.LoadLocation("Local")
  30198. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  30199. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  30200. orders, _ := service.GetOrderByTimeFourfor11(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  30201. //orders_two, _ := service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, "310", "", clr_type)
  30202. fixmedins_setl_cnt := int64(len(orders))
  30203. var medfee_sumamt float64
  30204. var func_smamt float64
  30205. for _, item := range orders {
  30206. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  30207. func_smamt = func_smamt + item.FundPaySumamt + item.AcctPay
  30208. }
  30209. times := strings.Split(start_time, "-")
  30210. time_tows := strings.Split(end_time, "-")
  30211. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  30212. var res ResultSix
  30213. if config.IsOpen == 1 {
  30214. //var bps []*models.BusinessParamsTwo
  30215. //var bp models.BusinessParamsTwo
  30216. medfee_sumamt_str := fmt.Sprintf("%.2f", medfee_sumamt)
  30217. func_smamt_str := fmt.Sprintf("%.2f", func_smamt)
  30218. data := make(map[string]interface{})
  30219. data["org_name"] = miConfig.OrgName
  30220. data["doctor"] = role.UserName
  30221. data["func_smamt"] = func_smamt_str
  30222. data["fixmedins_code"] = miConfig.Code
  30223. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  30224. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  30225. data["cnt"] = strconv.FormatInt(fixmedins_setl_cnt, 10)
  30226. data["medfee_sumamt"] = medfee_sumamt_str
  30227. data["start_time"] = times[0] + times[1] + times[2]
  30228. data["end_time"] = time_tows[0] + time_tows[1] + time_tows[2]
  30229. if miConfig.MdtrtareaAdmvs == "421300" {
  30230. client := &http.Client{}
  30231. bytesData, _ := json.Marshal(data)
  30232. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/1608", bytes.NewReader(bytesData))
  30233. resp, _ := client.Do(req)
  30234. defer resp.Body.Close()
  30235. body, ioErr := ioutil.ReadAll(resp.Body)
  30236. if ioErr != nil {
  30237. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30238. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30239. return
  30240. }
  30241. var respJSON map[string]interface{}
  30242. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30243. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30244. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30245. return
  30246. }
  30247. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30248. userJSONBytes, _ := json.Marshal(respJSON)
  30249. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30250. utils.ErrorLog("解析失败:%v", err)
  30251. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30252. return
  30253. }
  30254. }
  30255. if miConfig.MdtrtareaAdmvs == "420200" {
  30256. client := &http.Client{}
  30257. bytesData, _ := json.Marshal(data)
  30258. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/1608", bytes.NewReader(bytesData))
  30259. resp, _ := client.Do(req)
  30260. defer resp.Body.Close()
  30261. body, ioErr := ioutil.ReadAll(resp.Body)
  30262. if ioErr != nil {
  30263. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30264. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30265. return
  30266. }
  30267. var respJSON map[string]interface{}
  30268. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30269. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30270. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30271. return
  30272. }
  30273. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30274. userJSONBytes, _ := json.Marshal(respJSON)
  30275. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30276. utils.ErrorLog("解析失败:%v", err)
  30277. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30278. return
  30279. }
  30280. }
  30281. if miConfig.MdtrtareaAdmvs == "421182" {
  30282. client := &http.Client{}
  30283. bytesData, _ := json.Marshal(data)
  30284. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/1608", bytes.NewReader(bytesData))
  30285. resp, _ := client.Do(req)
  30286. defer resp.Body.Close()
  30287. body, ioErr := ioutil.ReadAll(resp.Body)
  30288. if ioErr != nil {
  30289. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30290. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30291. return
  30292. }
  30293. var respJSON map[string]interface{}
  30294. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30295. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30296. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30297. return
  30298. }
  30299. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30300. userJSONBytes, _ := json.Marshal(respJSON)
  30301. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30302. utils.ErrorLog("解析失败:%v", err)
  30303. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30304. return
  30305. }
  30306. }
  30307. if res.Infcode == 0 {
  30308. c.ServeSuccessJSON(map[string]interface{}{
  30309. "msg": "发起成功",
  30310. })
  30311. } else {
  30312. c.ServeSuccessJSON(map[string]interface{}{
  30313. "failed_code": -10,
  30314. "msg": res.ErrMsg,
  30315. })
  30316. }
  30317. }
  30318. }
  30319. // 5.11.1.1【5262】结算信息按时间段查询
  30320. func Post5262(c *HisApiController, bp models.BusinessParams5262, page int64, limit int64) {
  30321. admin_user_id, _ := c.GetInt64("admin_user_id")
  30322. adminUser := c.GetAdminUserInfo()
  30323. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  30324. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  30325. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  30326. var res Result5262
  30327. if config.IsOpen == 1 {
  30328. if miConfig.MdtrtareaAdmvs == "421300" {
  30329. data := make(map[string]interface{})
  30330. data["bps"] = bp
  30331. data["org_name"] = miConfig.OrgName
  30332. data["doctor"] = role.UserName
  30333. data["fixmedins_code"] = miConfig.Code
  30334. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  30335. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  30336. data["page"] = strconv.FormatInt(page, 10)
  30337. data["limit"] = strconv.FormatInt(limit, 10)
  30338. fmt.Println(data)
  30339. client := &http.Client{}
  30340. bytesData, _ := json.Marshal(data)
  30341. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/5262", bytes.NewReader(bytesData))
  30342. resp, _ := client.Do(req)
  30343. defer resp.Body.Close()
  30344. body, ioErr := ioutil.ReadAll(resp.Body)
  30345. if ioErr != nil {
  30346. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30347. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30348. return
  30349. }
  30350. var respJSON map[string]interface{}
  30351. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30352. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30353. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30354. return
  30355. }
  30356. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30357. userJSONBytes, _ := json.Marshal(respJSON)
  30358. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30359. utils.ErrorLog("解析失败:%v", err)
  30360. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30361. return
  30362. }
  30363. }
  30364. if miConfig.MdtrtareaAdmvs == "420200" {
  30365. data := make(map[string]interface{})
  30366. data["bps"] = bp
  30367. data["org_name"] = miConfig.OrgName
  30368. data["doctor"] = role.UserName
  30369. data["fixmedins_code"] = miConfig.Code
  30370. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  30371. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  30372. data["page"] = strconv.FormatInt(page, 10)
  30373. data["limit"] = strconv.FormatInt(limit, 10)
  30374. fmt.Println(data)
  30375. client := &http.Client{}
  30376. bytesData, _ := json.Marshal(data)
  30377. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/5262", bytes.NewReader(bytesData))
  30378. resp, _ := client.Do(req)
  30379. defer resp.Body.Close()
  30380. body, ioErr := ioutil.ReadAll(resp.Body)
  30381. if ioErr != nil {
  30382. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30383. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30384. return
  30385. }
  30386. var respJSON map[string]interface{}
  30387. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30388. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30389. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30390. return
  30391. }
  30392. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30393. userJSONBytes, _ := json.Marshal(respJSON)
  30394. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30395. utils.ErrorLog("解析失败:%v", err)
  30396. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30397. return
  30398. }
  30399. }
  30400. if miConfig.MdtrtareaAdmvs == "421182" {
  30401. data := make(map[string]interface{})
  30402. data["bps"] = bp
  30403. data["org_name"] = miConfig.OrgName
  30404. data["doctor"] = role.UserName
  30405. data["fixmedins_code"] = miConfig.Code
  30406. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  30407. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  30408. data["page"] = strconv.FormatInt(page, 10)
  30409. data["limit"] = strconv.FormatInt(limit, 10)
  30410. fmt.Println(data)
  30411. client := &http.Client{}
  30412. bytesData, _ := json.Marshal(data)
  30413. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/5262", bytes.NewReader(bytesData))
  30414. resp, _ := client.Do(req)
  30415. defer resp.Body.Close()
  30416. body, ioErr := ioutil.ReadAll(resp.Body)
  30417. if ioErr != nil {
  30418. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30419. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30420. return
  30421. }
  30422. var respJSON map[string]interface{}
  30423. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30424. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30425. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30426. return
  30427. }
  30428. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30429. userJSONBytes, _ := json.Marshal(respJSON)
  30430. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30431. utils.ErrorLog("解析失败:%v", err)
  30432. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30433. return
  30434. }
  30435. }
  30436. if res.Infcode == 0 {
  30437. c.ServeSuccessJSON(map[string]interface{}{
  30438. "order": res.Output.Result,
  30439. "total": res.Output.PageInfo.RecordCounts,
  30440. })
  30441. } else {
  30442. c.ServeSuccessJSON(map[string]interface{}{
  30443. "failed_code": -10,
  30444. "msg": res.ErrMsg,
  30445. })
  30446. }
  30447. }
  30448. }
  30449. // 5.11.1.2【5267】异地结算信息时间段查询
  30450. func Post5267(c *HisApiController, bp models.BusinessParams5262, page int64, limit int64) {
  30451. admin_user_id, _ := c.GetInt64("admin_user_id")
  30452. adminUser := c.GetAdminUserInfo()
  30453. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  30454. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  30455. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  30456. var res Result5267
  30457. if config.IsOpen == 1 {
  30458. if miConfig.MdtrtareaAdmvs == "421300" {
  30459. data := make(map[string]interface{})
  30460. data["bps"] = bp
  30461. data["org_name"] = miConfig.OrgName
  30462. data["doctor"] = role.UserName
  30463. data["fixmedins_code"] = miConfig.Code
  30464. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  30465. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  30466. data["page"] = page
  30467. data["limit"] = limit
  30468. fmt.Println(data)
  30469. client := &http.Client{}
  30470. bytesData, _ := json.Marshal(data)
  30471. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/5267", bytes.NewReader(bytesData))
  30472. resp, _ := client.Do(req)
  30473. defer resp.Body.Close()
  30474. body, ioErr := ioutil.ReadAll(resp.Body)
  30475. if ioErr != nil {
  30476. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30477. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30478. return
  30479. }
  30480. var respJSON map[string]interface{}
  30481. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30482. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30483. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30484. return
  30485. }
  30486. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30487. userJSONBytes, _ := json.Marshal(respJSON)
  30488. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30489. utils.ErrorLog("解析失败:%v", err)
  30490. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30491. return
  30492. }
  30493. }
  30494. if miConfig.MdtrtareaAdmvs == "420200" {
  30495. data := make(map[string]interface{})
  30496. data["bps"] = bp
  30497. data["org_name"] = miConfig.OrgName
  30498. data["doctor"] = role.UserName
  30499. data["fixmedins_code"] = miConfig.Code
  30500. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  30501. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  30502. data["page"] = page
  30503. data["limit"] = limit
  30504. fmt.Println(data)
  30505. client := &http.Client{}
  30506. bytesData, _ := json.Marshal(data)
  30507. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/5267", bytes.NewReader(bytesData))
  30508. resp, _ := client.Do(req)
  30509. defer resp.Body.Close()
  30510. body, ioErr := ioutil.ReadAll(resp.Body)
  30511. if ioErr != nil {
  30512. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30513. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30514. return
  30515. }
  30516. var respJSON map[string]interface{}
  30517. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30518. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30519. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30520. return
  30521. }
  30522. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30523. userJSONBytes, _ := json.Marshal(respJSON)
  30524. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30525. utils.ErrorLog("解析失败:%v", err)
  30526. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30527. return
  30528. }
  30529. }
  30530. if miConfig.MdtrtareaAdmvs == "421182" {
  30531. data := make(map[string]interface{})
  30532. data["bps"] = bp
  30533. data["org_name"] = miConfig.OrgName
  30534. data["doctor"] = role.UserName
  30535. data["fixmedins_code"] = miConfig.Code
  30536. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  30537. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  30538. data["page"] = page
  30539. data["limit"] = limit
  30540. fmt.Println(data)
  30541. client := &http.Client{}
  30542. bytesData, _ := json.Marshal(data)
  30543. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/5267", bytes.NewReader(bytesData))
  30544. resp, _ := client.Do(req)
  30545. defer resp.Body.Close()
  30546. body, ioErr := ioutil.ReadAll(resp.Body)
  30547. if ioErr != nil {
  30548. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30549. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30550. return
  30551. }
  30552. var respJSON map[string]interface{}
  30553. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30554. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30555. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30556. return
  30557. }
  30558. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30559. userJSONBytes, _ := json.Marshal(respJSON)
  30560. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30561. utils.ErrorLog("解析失败:%v", err)
  30562. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30563. return
  30564. }
  30565. }
  30566. if res.Infcode == 0 {
  30567. c.ServeSuccessJSON(map[string]interface{}{
  30568. "order": res.Output.Result,
  30569. "total": res.Output.PageInfo.RecordCounts,
  30570. })
  30571. } else {
  30572. c.ServeSuccessJSON(map[string]interface{}{
  30573. "failed_code": -10,
  30574. "msg": res.ErrMsg,
  30575. })
  30576. }
  30577. }
  30578. }
  30579. func (c *HisApiController) Post3501() {
  30580. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  30581. data := make(map[string]interface{})
  30582. var struct3501s []models.Struct3501
  30583. var struct3501 models.Struct3501
  30584. struct3501.OrgName = miConfig.OrgName
  30585. struct3501.AccessKey = miConfig.AccessKey
  30586. struct3501.RequestUrl = miConfig.Url
  30587. struct3501.SecretKey = miConfig.SecretKey
  30588. struct3501.ManuDate = "2022-08-17"
  30589. struct3501.FixmedinsBchno = ""
  30590. struct3501.ManuLotnum = ""
  30591. struct3501.RxFlag = "0"
  30592. struct3501.ExpyEnd = "2022-08-17"
  30593. struct3501.Invdate = "2022-08-17"
  30594. struct3501.InvCnt = "20.25"
  30595. struct3501.Memo = ""
  30596. struct3501.MedListCodg = "XB01ABD056B002020200517"
  30597. struct3501.FixmedinsHilistId = miConfig.Code
  30598. struct3501.FixmedinsHilistName = miConfig.OrgName
  30599. struct3501s = append(struct3501s, struct3501)
  30600. data["struct_3501s"] = struct3501s
  30601. client := &http.Client{}
  30602. bytesData, _ := json.Marshal(data)
  30603. var req *http.Request
  30604. if miConfig.MdtrtareaAdmvs == "320921" {
  30605. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  30606. } else {
  30607. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  30608. }
  30609. resp, _ := client.Do(req)
  30610. defer resp.Body.Close()
  30611. body, ioErr := ioutil.ReadAll(resp.Body)
  30612. if ioErr != nil {
  30613. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30614. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30615. return
  30616. }
  30617. var respJSON map[string]interface{}
  30618. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30619. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30620. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30621. return
  30622. }
  30623. var res ResultSix
  30624. var resSix10265 ResultSix10265 //1101结果
  30625. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  30626. result, _ := json.Marshal(respJSON)
  30627. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  30628. utils.ErrorLog("解析失败:%v", err)
  30629. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30630. return
  30631. }
  30632. res.InfRefmsgid = resSix10265.InfRefmsgid
  30633. res.Output = resSix10265.Output
  30634. res.ErrMsg = resSix10265.ErrMsg
  30635. res.Cainfo = resSix10265.Cainfo
  30636. res.WarnMsg = resSix10265.WarnMsg
  30637. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  30638. res.Infcode = infocode
  30639. if infocode == 0 {
  30640. c.ServeSuccessJSON(map[string]interface{}{
  30641. "msg": "上传成功",
  30642. })
  30643. return
  30644. } else {
  30645. c.ServeSuccessJSON(map[string]interface{}{
  30646. "failed_code": -10,
  30647. "msg": res.ErrMsg,
  30648. })
  30649. return
  30650. }
  30651. }
  30652. func (c *HisApiController) Post3502() {
  30653. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  30654. data := make(map[string]interface{})
  30655. var struct3502s []models.Struct3502
  30656. var struct3502 models.Struct3502
  30657. struct3502.OrgName = miConfig.OrgName
  30658. struct3502.AccessKey = miConfig.AccessKey
  30659. struct3502.RequestUrl = miConfig.Url
  30660. struct3502.SecretKey = miConfig.SecretKey
  30661. struct3502.ManuDate = "2022-08-15"
  30662. struct3502.FixmedinsBchno = ""
  30663. struct3502.ManuLotnum = ""
  30664. struct3502.RxFlag = "0"
  30665. struct3502.ExpyEnd = "2022-08-15"
  30666. struct3502.Invdate = "2022-08-15"
  30667. struct3502.InvCnt = "20.25"
  30668. struct3502.Memo = ""
  30669. struct3502.MedListCodg = "XB01ABD056B002020200517"
  30670. struct3502.FixmedinsHilistId = miConfig.Code
  30671. struct3502.FixmedinsHilistName = miConfig.OrgName
  30672. struct3502s = append(struct3502s, struct3502)
  30673. data["struct_3502s"] = struct3502s
  30674. client := &http.Client{}
  30675. bytesData, _ := json.Marshal(data)
  30676. var req *http.Request
  30677. if miConfig.MdtrtareaAdmvs == "320921" {
  30678. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  30679. } else {
  30680. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  30681. }
  30682. resp, _ := client.Do(req)
  30683. defer resp.Body.Close()
  30684. body, ioErr := ioutil.ReadAll(resp.Body)
  30685. if ioErr != nil {
  30686. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30687. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30688. return
  30689. }
  30690. var respJSON map[string]interface{}
  30691. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30692. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30693. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30694. return
  30695. }
  30696. var res ResultSix
  30697. var resSix10265 ResultSix10265 //1101结果
  30698. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  30699. result, _ := json.Marshal(respJSON)
  30700. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  30701. utils.ErrorLog("解析失败:%v", err)
  30702. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30703. return
  30704. }
  30705. res.InfRefmsgid = resSix10265.InfRefmsgid
  30706. res.Output = resSix10265.Output
  30707. res.ErrMsg = resSix10265.ErrMsg
  30708. res.Cainfo = resSix10265.Cainfo
  30709. res.WarnMsg = resSix10265.WarnMsg
  30710. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  30711. res.Infcode = infocode
  30712. if infocode == 0 {
  30713. c.ServeSuccessJSON(map[string]interface{}{
  30714. "msg": "上传成功",
  30715. })
  30716. return
  30717. } else {
  30718. c.ServeSuccessJSON(map[string]interface{}{
  30719. "failed_code": -10,
  30720. "msg": res.ErrMsg,
  30721. })
  30722. return
  30723. }
  30724. }
  30725. func (c *HisApiController) Post3503() {
  30726. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  30727. data := make(map[string]interface{})
  30728. var struct3501s []models.Struct3501
  30729. var struct3501 models.Struct3501
  30730. struct3501.OrgName = miConfig.OrgName
  30731. struct3501.AccessKey = miConfig.AccessKey
  30732. struct3501.RequestUrl = miConfig.Url
  30733. struct3501.SecretKey = miConfig.SecretKey
  30734. struct3501.ManuDate = "2022-08-15"
  30735. struct3501.FixmedinsBchno = ""
  30736. struct3501.ManuLotnum = ""
  30737. struct3501.RxFlag = "0"
  30738. struct3501.ExpyEnd = "2022-08-15"
  30739. struct3501.Invdate = "2022-08-15"
  30740. struct3501.InvCnt = "20.25"
  30741. struct3501.Memo = ""
  30742. struct3501.MedListCodg = "XB01ABD056B002020200517"
  30743. struct3501.FixmedinsHilistId = miConfig.Code
  30744. struct3501.FixmedinsHilistName = miConfig.OrgName
  30745. struct3501s = append(struct3501s, struct3501)
  30746. data["struct_3501s"] = struct3501s
  30747. client := &http.Client{}
  30748. bytesData, _ := json.Marshal(data)
  30749. var req *http.Request
  30750. if miConfig.MdtrtareaAdmvs == "320921" {
  30751. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  30752. } else {
  30753. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  30754. }
  30755. resp, _ := client.Do(req)
  30756. defer resp.Body.Close()
  30757. body, ioErr := ioutil.ReadAll(resp.Body)
  30758. if ioErr != nil {
  30759. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30760. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30761. return
  30762. }
  30763. var respJSON map[string]interface{}
  30764. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30765. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30766. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30767. return
  30768. }
  30769. var res ResultSix
  30770. var resSix10265 ResultSix10265 //1101结果
  30771. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  30772. result, _ := json.Marshal(respJSON)
  30773. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  30774. utils.ErrorLog("解析失败:%v", err)
  30775. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30776. return
  30777. }
  30778. res.InfRefmsgid = resSix10265.InfRefmsgid
  30779. res.Output = resSix10265.Output
  30780. res.ErrMsg = resSix10265.ErrMsg
  30781. res.Cainfo = resSix10265.Cainfo
  30782. res.WarnMsg = resSix10265.WarnMsg
  30783. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  30784. res.Infcode = infocode
  30785. if infocode == 0 {
  30786. c.ServeSuccessJSON(map[string]interface{}{
  30787. "msg": "上传成功",
  30788. })
  30789. return
  30790. } else {
  30791. c.ServeSuccessJSON(map[string]interface{}{
  30792. "failed_code": -10,
  30793. "msg": res.ErrMsg,
  30794. })
  30795. return
  30796. }
  30797. }
  30798. func (c *HisApiController) Post3504() {
  30799. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  30800. data := make(map[string]interface{})
  30801. var struct3501s []models.Struct3501
  30802. var struct3501 models.Struct3501
  30803. struct3501.OrgName = miConfig.OrgName
  30804. struct3501.AccessKey = miConfig.AccessKey
  30805. struct3501.RequestUrl = miConfig.Url
  30806. struct3501.SecretKey = miConfig.SecretKey
  30807. struct3501.ManuDate = "2022-08-15"
  30808. struct3501.FixmedinsBchno = ""
  30809. struct3501.ManuLotnum = ""
  30810. struct3501.RxFlag = "0"
  30811. struct3501.ExpyEnd = "2022-08-15"
  30812. struct3501.Invdate = "2022-08-15"
  30813. struct3501.InvCnt = "20.25"
  30814. struct3501.Memo = ""
  30815. struct3501.MedListCodg = "XB01ABD056B002020200517"
  30816. struct3501.FixmedinsHilistId = miConfig.Code
  30817. struct3501.FixmedinsHilistName = miConfig.OrgName
  30818. struct3501s = append(struct3501s, struct3501)
  30819. data["struct_3501s"] = struct3501s
  30820. client := &http.Client{}
  30821. bytesData, _ := json.Marshal(data)
  30822. var req *http.Request
  30823. if miConfig.MdtrtareaAdmvs == "320921" {
  30824. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  30825. } else {
  30826. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  30827. }
  30828. resp, _ := client.Do(req)
  30829. defer resp.Body.Close()
  30830. body, ioErr := ioutil.ReadAll(resp.Body)
  30831. if ioErr != nil {
  30832. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30833. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30834. return
  30835. }
  30836. var respJSON map[string]interface{}
  30837. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30838. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30839. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30840. return
  30841. }
  30842. var res ResultSix
  30843. var resSix10265 ResultSix10265 //1101结果
  30844. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  30845. result, _ := json.Marshal(respJSON)
  30846. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  30847. utils.ErrorLog("解析失败:%v", err)
  30848. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30849. return
  30850. }
  30851. res.InfRefmsgid = resSix10265.InfRefmsgid
  30852. res.Output = resSix10265.Output
  30853. res.ErrMsg = resSix10265.ErrMsg
  30854. res.Cainfo = resSix10265.Cainfo
  30855. res.WarnMsg = resSix10265.WarnMsg
  30856. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  30857. res.Infcode = infocode
  30858. if infocode == 0 {
  30859. c.ServeSuccessJSON(map[string]interface{}{
  30860. "msg": "上传成功",
  30861. })
  30862. return
  30863. } else {
  30864. c.ServeSuccessJSON(map[string]interface{}{
  30865. "failed_code": -10,
  30866. "msg": res.ErrMsg,
  30867. })
  30868. return
  30869. }
  30870. }
  30871. func (c *HisApiController) Post3505() {
  30872. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  30873. data := make(map[string]interface{})
  30874. var struct3501s []models.Struct3501
  30875. var struct3501 models.Struct3501
  30876. struct3501.OrgName = miConfig.OrgName
  30877. struct3501.AccessKey = miConfig.AccessKey
  30878. struct3501.RequestUrl = miConfig.Url
  30879. struct3501.SecretKey = miConfig.SecretKey
  30880. struct3501.ManuDate = "2022-08-15"
  30881. struct3501.FixmedinsBchno = ""
  30882. struct3501.ManuLotnum = ""
  30883. struct3501.RxFlag = "0"
  30884. struct3501.ExpyEnd = "2022-08-15"
  30885. struct3501.Invdate = "2022-08-15"
  30886. struct3501.InvCnt = "20.25"
  30887. struct3501.Memo = ""
  30888. struct3501.MedListCodg = "XB01ABD056B002020200517"
  30889. struct3501.FixmedinsHilistId = miConfig.Code
  30890. struct3501.FixmedinsHilistName = miConfig.OrgName
  30891. struct3501s = append(struct3501s, struct3501)
  30892. data["struct_3501s"] = struct3501s
  30893. client := &http.Client{}
  30894. bytesData, _ := json.Marshal(data)
  30895. var req *http.Request
  30896. if miConfig.MdtrtareaAdmvs == "320921" {
  30897. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  30898. } else {
  30899. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  30900. }
  30901. resp, _ := client.Do(req)
  30902. defer resp.Body.Close()
  30903. body, ioErr := ioutil.ReadAll(resp.Body)
  30904. if ioErr != nil {
  30905. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30906. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30907. return
  30908. }
  30909. var respJSON map[string]interface{}
  30910. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30911. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30912. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30913. return
  30914. }
  30915. var res ResultSix
  30916. var resSix10265 ResultSix10265 //1101结果
  30917. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  30918. result, _ := json.Marshal(respJSON)
  30919. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  30920. utils.ErrorLog("解析失败:%v", err)
  30921. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30922. return
  30923. }
  30924. res.InfRefmsgid = resSix10265.InfRefmsgid
  30925. res.Output = resSix10265.Output
  30926. res.ErrMsg = resSix10265.ErrMsg
  30927. res.Cainfo = resSix10265.Cainfo
  30928. res.WarnMsg = resSix10265.WarnMsg
  30929. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  30930. res.Infcode = infocode
  30931. if infocode == 0 {
  30932. c.ServeSuccessJSON(map[string]interface{}{
  30933. "msg": "上传成功",
  30934. })
  30935. return
  30936. } else {
  30937. c.ServeSuccessJSON(map[string]interface{}{
  30938. "failed_code": -10,
  30939. "msg": res.ErrMsg,
  30940. })
  30941. return
  30942. }
  30943. }
  30944. func (c *HisApiController) Post3506() {
  30945. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  30946. data := make(map[string]interface{})
  30947. var struct3501s []models.Struct3501
  30948. var struct3501 models.Struct3501
  30949. struct3501.OrgName = miConfig.OrgName
  30950. struct3501.AccessKey = miConfig.AccessKey
  30951. struct3501.RequestUrl = miConfig.Url
  30952. struct3501.SecretKey = miConfig.SecretKey
  30953. struct3501.ManuDate = "2022-08-15"
  30954. struct3501.FixmedinsBchno = ""
  30955. struct3501.ManuLotnum = ""
  30956. struct3501.RxFlag = "0"
  30957. struct3501.ExpyEnd = "2022-08-15"
  30958. struct3501.Invdate = "2022-08-15"
  30959. struct3501.InvCnt = "20.25"
  30960. struct3501.Memo = ""
  30961. struct3501.MedListCodg = "XB01ABD056B002020200517"
  30962. struct3501.FixmedinsHilistId = miConfig.Code
  30963. struct3501.FixmedinsHilistName = miConfig.OrgName
  30964. struct3501s = append(struct3501s, struct3501)
  30965. data["struct_3501s"] = struct3501s
  30966. client := &http.Client{}
  30967. bytesData, _ := json.Marshal(data)
  30968. var req *http.Request
  30969. if miConfig.MdtrtareaAdmvs == "320921" {
  30970. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  30971. } else {
  30972. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  30973. }
  30974. resp, _ := client.Do(req)
  30975. defer resp.Body.Close()
  30976. body, ioErr := ioutil.ReadAll(resp.Body)
  30977. if ioErr != nil {
  30978. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30979. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30980. return
  30981. }
  30982. var respJSON map[string]interface{}
  30983. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30984. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30985. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30986. return
  30987. }
  30988. var res ResultSix
  30989. var resSix10265 ResultSix10265 //1101结果
  30990. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  30991. result, _ := json.Marshal(respJSON)
  30992. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  30993. utils.ErrorLog("解析失败:%v", err)
  30994. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30995. return
  30996. }
  30997. res.InfRefmsgid = resSix10265.InfRefmsgid
  30998. res.Output = resSix10265.Output
  30999. res.ErrMsg = resSix10265.ErrMsg
  31000. res.Cainfo = resSix10265.Cainfo
  31001. res.WarnMsg = resSix10265.WarnMsg
  31002. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  31003. res.Infcode = infocode
  31004. if infocode == 0 {
  31005. c.ServeSuccessJSON(map[string]interface{}{
  31006. "msg": "上传成功",
  31007. })
  31008. return
  31009. } else {
  31010. c.ServeSuccessJSON(map[string]interface{}{
  31011. "failed_code": -10,
  31012. "msg": res.ErrMsg,
  31013. })
  31014. return
  31015. }
  31016. }
  31017. func (c *HisApiController) Post3507() {
  31018. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  31019. data := make(map[string]interface{})
  31020. var struct3501s []models.Struct3501
  31021. var struct3501 models.Struct3501
  31022. struct3501.OrgName = miConfig.OrgName
  31023. struct3501.AccessKey = miConfig.AccessKey
  31024. struct3501.RequestUrl = miConfig.Url
  31025. struct3501.SecretKey = miConfig.SecretKey
  31026. struct3501.ManuDate = "2022-08-15"
  31027. struct3501.FixmedinsBchno = ""
  31028. struct3501.ManuLotnum = ""
  31029. struct3501.RxFlag = "0"
  31030. struct3501.ExpyEnd = "2022-08-15"
  31031. struct3501.Invdate = "2022-08-15"
  31032. struct3501.InvCnt = "20.25"
  31033. struct3501.Memo = ""
  31034. struct3501.MedListCodg = "XB01ABD056B002020200517"
  31035. struct3501.FixmedinsHilistId = miConfig.Code
  31036. struct3501.FixmedinsHilistName = miConfig.OrgName
  31037. struct3501s = append(struct3501s, struct3501)
  31038. data["struct_3501s"] = struct3501s
  31039. client := &http.Client{}
  31040. bytesData, _ := json.Marshal(data)
  31041. var req *http.Request
  31042. if miConfig.MdtrtareaAdmvs == "320921" {
  31043. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  31044. } else {
  31045. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  31046. }
  31047. resp, _ := client.Do(req)
  31048. defer resp.Body.Close()
  31049. body, ioErr := ioutil.ReadAll(resp.Body)
  31050. if ioErr != nil {
  31051. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  31052. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31053. return
  31054. }
  31055. var respJSON map[string]interface{}
  31056. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  31057. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31058. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31059. return
  31060. }
  31061. var res ResultSix
  31062. var resSix10265 ResultSix10265 //1101结果
  31063. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  31064. result, _ := json.Marshal(respJSON)
  31065. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  31066. utils.ErrorLog("解析失败:%v", err)
  31067. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31068. return
  31069. }
  31070. res.InfRefmsgid = resSix10265.InfRefmsgid
  31071. res.Output = resSix10265.Output
  31072. res.ErrMsg = resSix10265.ErrMsg
  31073. res.Cainfo = resSix10265.Cainfo
  31074. res.WarnMsg = resSix10265.WarnMsg
  31075. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  31076. res.Infcode = infocode
  31077. if infocode == 0 {
  31078. c.ServeSuccessJSON(map[string]interface{}{
  31079. "msg": "上传成功",
  31080. })
  31081. return
  31082. } else {
  31083. c.ServeSuccessJSON(map[string]interface{}{
  31084. "failed_code": -10,
  31085. "msg": res.ErrMsg,
  31086. })
  31087. return
  31088. }
  31089. }
  31090. func GetjxELeInfo(code string, operator_id string, operator_name string, md string) (string, string) {
  31091. // WebSocket服务器地址
  31092. serverURL := "ws://127.0.0.1:8899"
  31093. // 解析WebSocket服务器地址
  31094. u, err := url.Parse(serverURL)
  31095. if err != nil {
  31096. }
  31097. // 建立WebSocket连接
  31098. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  31099. if err != nil {
  31100. }
  31101. defer conn.Close()
  31102. input2 := make(map[string]interface{})
  31103. input := make(map[string]interface{})
  31104. inputData := make(map[string]interface{})
  31105. inputData["orgId"] = code
  31106. inputData["businessType"] = "01101"
  31107. inputData["operatorId"] = operator_id
  31108. inputData["operatorName"] = operator_name
  31109. inputData["officeId"] = "001"
  31110. inputData["officeName"] = "血透室"
  31111. inputData["deviceType"] = ""
  31112. input["data"] = inputData
  31113. input["orgId"] = code
  31114. input["transType"] = "ec.query"
  31115. //if md == ""
  31116. if md[:4] == "4403" {
  31117. input2["url"] = "http://hosp-sz.gd.hsip.gov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  31118. } else if md[:4] == "4401" {
  31119. input2["url"] = "http://hosp-sz.gd.hsip.gov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  31120. } else {
  31121. input2["url"] = "http://hosp.gd.hsip.gov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  31122. }
  31123. input2["indata"] = input
  31124. fmt.Println(input2)
  31125. bytesData, _ := json.Marshal(input2)
  31126. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  31127. if err != nil {
  31128. fmt.Println(err)
  31129. }
  31130. // 接收消息
  31131. _, receivedMessage, err := conn.ReadMessage()
  31132. if err != nil {
  31133. fmt.Println(err)
  31134. }
  31135. return "", string(receivedMessage)
  31136. }
  31137. func GetjxELeInfoaaa(code string, operator_id string, operator_name string) (string, string) {
  31138. // WebSocket服务器地址
  31139. serverURL := "ws://127.0.0.1:8899"
  31140. // 解析WebSocket服务器地址
  31141. u, err := url.Parse(serverURL)
  31142. if err != nil {
  31143. }
  31144. // 建立WebSocket连接
  31145. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  31146. if err != nil {
  31147. }
  31148. defer conn.Close()
  31149. input2 := make(map[string]interface{})
  31150. input := make(map[string]interface{})
  31151. inputData := make(map[string]interface{})
  31152. inputData["orgId"] = code
  31153. inputData["businessType"] = "01103"
  31154. inputData["operatorId"] = operator_id
  31155. inputData["operatorName"] = operator_name
  31156. inputData["officeId"] = "001"
  31157. inputData["officeName"] = "血透室"
  31158. inputData["deviceType"] = ""
  31159. input["data"] = inputData
  31160. input["orgId"] = code
  31161. input["transType"] = "ec.query"
  31162. //if md ==
  31163. input2["url"] = "http://10.77.211.236/1.0.0/localQrCodeQuery"
  31164. input2["indata"] = input
  31165. fmt.Println(input2)
  31166. bytesData, _ := json.Marshal(input2)
  31167. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  31168. if err != nil {
  31169. fmt.Println(err)
  31170. }
  31171. // 接收消息
  31172. _, receivedMessage, err := conn.ReadMessage()
  31173. if err != nil {
  31174. fmt.Println(err)
  31175. }
  31176. return "", string(receivedMessage)
  31177. }
  31178. func GetELeInfo(code string, operator_id string, operator_name string, md string) (string, string) {
  31179. // WebSocket服务器地址
  31180. serverURL := "ws://127.0.0.1:8899"
  31181. // 解析WebSocket服务器地址
  31182. u, err := url.Parse(serverURL)
  31183. if err != nil {
  31184. }
  31185. // 建立WebSocket连接
  31186. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  31187. if err != nil {
  31188. }
  31189. defer conn.Close()
  31190. input2 := make(map[string]interface{})
  31191. input := make(map[string]interface{})
  31192. inputData := make(map[string]interface{})
  31193. inputData["orgId"] = code
  31194. inputData["businessType"] = "01101"
  31195. inputData["operatorId"] = operator_id
  31196. inputData["operatorName"] = operator_name
  31197. inputData["officeId"] = "001"
  31198. inputData["officeName"] = "血透室"
  31199. inputData["deviceType"] = ""
  31200. input["data"] = inputData
  31201. input["orgId"] = code
  31202. input["transType"] = "ec.query"
  31203. //if md == ""
  31204. if md[:4] == "4403" {
  31205. input2["url"] = "http://igb.hsa.gdgov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  31206. } else if md[:4] == "4401" {
  31207. input2["url"] = "http://igb.hsa.gdgov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  31208. } else {
  31209. input2["url"] = "http://hosp.gd.hsip.gov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  31210. }
  31211. input2["indata"] = input
  31212. fmt.Println(input2)
  31213. bytesData, _ := json.Marshal(input2)
  31214. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  31215. if err != nil {
  31216. fmt.Println(err)
  31217. }
  31218. // 接收消息
  31219. _, receivedMessage, err := conn.ReadMessage()
  31220. if err != nil {
  31221. fmt.Println(err)
  31222. }
  31223. return "", string(receivedMessage)
  31224. }
  31225. func GetELeInfoThree(code string, operator_id string, operator_name string) (string, string) {
  31226. // WebSocket服务器地址
  31227. serverURL := "ws://127.0.0.1:8899"
  31228. // 解析WebSocket服务器地址
  31229. u, err := url.Parse(serverURL)
  31230. if err != nil {
  31231. }
  31232. // 建立WebSocket连接
  31233. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  31234. if err != nil {
  31235. }
  31236. defer conn.Close()
  31237. input2 := make(map[string]interface{})
  31238. input := make(map[string]interface{})
  31239. inputData := make(map[string]interface{})
  31240. inputData["orgId"] = code
  31241. inputData["businessType"] = "01301"
  31242. inputData["operatorId"] = operator_id
  31243. inputData["operatorName"] = operator_name
  31244. inputData["officeId"] = "001"
  31245. inputData["officeName"] = "血透室"
  31246. inputData["deviceType"] = ""
  31247. input["data"] = inputData
  31248. input["orgId"] = code
  31249. input["transType"] = "ec.query"
  31250. input2["url"] = "http://igb.hsa.gdgov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  31251. input2["indata"] = input
  31252. bytesData, _ := json.Marshal(input2)
  31253. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  31254. if err != nil {
  31255. fmt.Println(err)
  31256. }
  31257. // 接收消息
  31258. _, receivedMessage, err := conn.ReadMessage()
  31259. if err != nil {
  31260. fmt.Println(err)
  31261. }
  31262. return "", string(receivedMessage)
  31263. }
  31264. func RemoveRepeatedPurviewElement2(arr []string) (newArr []string) {
  31265. newArr = make([]string, 0)
  31266. for i := 0; i < len(arr); i++ {
  31267. repeat := false
  31268. for j := i + 1; j < len(arr); j++ {
  31269. if arr[i] == arr[j] {
  31270. repeat = true
  31271. break
  31272. }
  31273. }
  31274. if !repeat {
  31275. newArr = append(newArr, arr[i])
  31276. }
  31277. }
  31278. return
  31279. }
  31280. func getBirthdateAndAge(idNumber string) (string, int, error) {
  31281. if len(idNumber) != 18 {
  31282. return "", 0, fmt.Errorf("invalid ID number length. It should be 18 digits")
  31283. }
  31284. // 提取出生日期
  31285. year, err := strconv.Atoi(idNumber[6:10])
  31286. if err != nil {
  31287. return "", 0, err
  31288. }
  31289. month, err := strconv.Atoi(idNumber[10:12])
  31290. if err != nil {
  31291. return "", 0, err
  31292. }
  31293. day, err := strconv.Atoi(idNumber[12:14])
  31294. if err != nil {
  31295. return "", 0, err
  31296. }
  31297. // 格式化生日字符串
  31298. birthdate := time.Date(year, time.Month(month), day, 0, 0, 0, 0, time.UTC)
  31299. birthdateFormatted := birthdate.Format("2006-01-02")
  31300. // 计算年龄
  31301. today := time.Now()
  31302. age := today.Year() - birthdate.Year()
  31303. if today.YearDay() < birthdate.YearDay() {
  31304. age--
  31305. }
  31306. return birthdateFormatted, age, nil
  31307. }