his_api_controller.go 1.3MB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088190891909019091190921909319094190951909619097190981909919100191011910219103191041910519106191071910819109191101911119112191131911419115191161911719118191191912019121191221912319124191251912619127191281912919130191311913219133191341913519136191371913819139191401914119142191431914419145191461914719148191491915019151191521915319154191551915619157191581915919160191611916219163191641916519166191671916819169191701917119172191731917419175191761917719178191791918019181191821918319184191851918619187191881918919190191911919219193191941919519196191971919819199192001920119202192031920419205192061920719208192091921019211192121921319214192151921619217192181921919220192211922219223192241922519226192271922819229192301923119232192331923419235192361923719238192391924019241192421924319244192451924619247192481924919250192511925219253192541925519256192571925819259192601926119262192631926419265192661926719268192691927019271192721927319274192751927619277192781927919280192811928219283192841928519286192871928819289192901929119292192931929419295192961929719298192991930019301193021930319304193051930619307193081930919310193111931219313193141931519316193171931819319193201932119322193231932419325193261932719328193291933019331193321933319334193351933619337193381933919340193411934219343193441934519346193471934819349193501935119352193531935419355193561935719358193591936019361193621936319364193651936619367193681936919370193711937219373193741937519376193771937819379193801938119382193831938419385193861938719388193891939019391193921939319394193951939619397193981939919400194011940219403194041940519406194071940819409194101941119412194131941419415194161941719418194191942019421194221942319424194251942619427194281942919430194311943219433194341943519436194371943819439194401944119442194431944419445194461944719448194491945019451194521945319454194551945619457194581945919460194611946219463194641946519466194671946819469194701947119472194731947419475194761947719478194791948019481194821948319484194851948619487194881948919490194911949219493194941949519496194971949819499195001950119502195031950419505195061950719508195091951019511195121951319514195151951619517195181951919520195211952219523195241952519526195271952819529195301953119532195331953419535195361953719538195391954019541195421954319544195451954619547195481954919550195511955219553195541955519556195571955819559195601956119562195631956419565195661956719568195691957019571195721957319574195751957619577195781957919580195811958219583195841958519586195871958819589195901959119592195931959419595195961959719598195991960019601196021960319604196051960619607196081960919610196111961219613196141961519616196171961819619196201962119622196231962419625196261962719628196291963019631196321963319634196351963619637196381963919640196411964219643196441964519646196471964819649196501965119652196531965419655196561965719658196591966019661196621966319664196651966619667196681966919670196711967219673196741967519676196771967819679196801968119682196831968419685196861968719688196891969019691196921969319694196951969619697196981969919700197011970219703197041970519706197071970819709197101971119712197131971419715197161971719718197191972019721197221972319724197251972619727197281972919730197311973219733197341973519736197371973819739197401974119742197431974419745197461974719748197491975019751197521975319754197551975619757197581975919760197611976219763197641976519766197671976819769197701977119772197731977419775197761977719778197791978019781197821978319784197851978619787197881978919790197911979219793197941979519796197971979819799198001980119802198031980419805198061980719808198091981019811198121981319814198151981619817198181981919820198211982219823198241982519826198271982819829198301983119832198331983419835198361983719838198391984019841198421984319844198451984619847198481984919850198511985219853198541985519856198571985819859198601986119862198631986419865198661986719868198691987019871198721987319874198751987619877198781987919880198811988219883198841988519886198871988819889198901989119892198931989419895198961989719898198991990019901199021990319904199051990619907199081990919910199111991219913199141991519916199171991819919199201992119922199231992419925199261992719928199291993019931199321993319934199351993619937199381993919940199411994219943199441994519946199471994819949199501995119952199531995419955199561995719958199591996019961199621996319964199651996619967199681996919970199711997219973199741997519976199771997819979199801998119982199831998419985199861998719988199891999019991199921999319994199951999619997199981999920000200012000220003200042000520006200072000820009200102001120012200132001420015200162001720018200192002020021200222002320024200252002620027200282002920030200312003220033200342003520036200372003820039200402004120042200432004420045200462004720048200492005020051200522005320054200552005620057200582005920060200612006220063200642006520066200672006820069200702007120072200732007420075200762007720078200792008020081200822008320084200852008620087200882008920090200912009220093200942009520096200972009820099201002010120102201032010420105201062010720108201092011020111201122011320114201152011620117201182011920120201212012220123201242012520126201272012820129201302013120132201332013420135201362013720138201392014020141201422014320144201452014620147201482014920150201512015220153201542015520156201572015820159201602016120162201632016420165201662016720168201692017020171201722017320174201752017620177201782017920180201812018220183201842018520186201872018820189201902019120192201932019420195201962019720198201992020020201202022020320204202052020620207202082020920210202112021220213202142021520216202172021820219202202022120222202232022420225202262022720228202292023020231202322023320234202352023620237202382023920240202412024220243202442024520246202472024820249202502025120252202532025420255202562025720258202592026020261202622026320264202652026620267202682026920270202712027220273202742027520276202772027820279202802028120282202832028420285202862028720288202892029020291202922029320294202952029620297202982029920300203012030220303203042030520306203072030820309203102031120312203132031420315203162031720318203192032020321203222032320324203252032620327203282032920330203312033220333203342033520336203372033820339203402034120342203432034420345203462034720348203492035020351203522035320354203552035620357203582035920360203612036220363203642036520366203672036820369203702037120372203732037420375203762037720378203792038020381203822038320384203852038620387203882038920390203912039220393203942039520396203972039820399204002040120402204032040420405204062040720408204092041020411204122041320414204152041620417204182041920420204212042220423204242042520426204272042820429204302043120432204332043420435204362043720438204392044020441204422044320444204452044620447204482044920450204512045220453204542045520456204572045820459204602046120462204632046420465204662046720468204692047020471204722047320474204752047620477204782047920480204812048220483204842048520486204872048820489204902049120492204932049420495204962049720498204992050020501205022050320504205052050620507205082050920510205112051220513205142051520516205172051820519205202052120522205232052420525205262052720528205292053020531205322053320534205352053620537205382053920540205412054220543205442054520546205472054820549205502055120552205532055420555205562055720558205592056020561205622056320564205652056620567205682056920570205712057220573205742057520576205772057820579205802058120582205832058420585205862058720588205892059020591205922059320594205952059620597205982059920600206012060220603206042060520606206072060820609206102061120612206132061420615206162061720618206192062020621206222062320624206252062620627206282062920630206312063220633206342063520636206372063820639206402064120642206432064420645206462064720648206492065020651206522065320654206552065620657206582065920660206612066220663206642066520666206672066820669206702067120672206732067420675206762067720678206792068020681206822068320684206852068620687206882068920690206912069220693206942069520696206972069820699207002070120702207032070420705207062070720708207092071020711207122071320714207152071620717207182071920720207212072220723207242072520726207272072820729207302073120732207332073420735207362073720738207392074020741207422074320744207452074620747207482074920750207512075220753207542075520756207572075820759207602076120762207632076420765207662076720768207692077020771207722077320774207752077620777207782077920780207812078220783207842078520786207872078820789207902079120792207932079420795207962079720798207992080020801208022080320804208052080620807208082080920810208112081220813208142081520816208172081820819208202082120822208232082420825208262082720828208292083020831208322083320834208352083620837208382083920840208412084220843208442084520846208472084820849208502085120852208532085420855208562085720858208592086020861208622086320864208652086620867208682086920870208712087220873208742087520876208772087820879208802088120882208832088420885208862088720888208892089020891208922089320894208952089620897208982089920900209012090220903209042090520906209072090820909209102091120912209132091420915209162091720918209192092020921209222092320924209252092620927209282092920930209312093220933209342093520936209372093820939209402094120942209432094420945209462094720948209492095020951209522095320954209552095620957209582095920960209612096220963209642096520966209672096820969209702097120972209732097420975209762097720978209792098020981209822098320984209852098620987209882098920990209912099220993209942099520996209972099820999210002100121002210032100421005210062100721008210092101021011210122101321014210152101621017210182101921020210212102221023210242102521026210272102821029210302103121032210332103421035210362103721038210392104021041210422104321044210452104621047210482104921050210512105221053210542105521056210572105821059210602106121062210632106421065210662106721068210692107021071210722107321074210752107621077210782107921080210812108221083210842108521086210872108821089210902109121092210932109421095210962109721098210992110021101211022110321104211052110621107211082110921110211112111221113211142111521116211172111821119211202112121122211232112421125211262112721128211292113021131211322113321134211352113621137211382113921140211412114221143211442114521146211472114821149211502115121152211532115421155211562115721158211592116021161211622116321164211652116621167211682116921170211712117221173211742117521176211772117821179211802118121182211832118421185211862118721188211892119021191211922119321194211952119621197211982119921200212012120221203212042120521206212072120821209212102121121212212132121421215212162121721218212192122021221212222122321224212252122621227212282122921230212312123221233212342123521236212372123821239212402124121242212432124421245212462124721248212492125021251212522125321254212552125621257212582125921260212612126221263212642126521266212672126821269212702127121272212732127421275212762127721278212792128021281212822128321284212852128621287212882128921290212912129221293212942129521296212972129821299213002130121302213032130421305213062130721308213092131021311213122131321314213152131621317213182131921320213212132221323213242132521326213272132821329213302133121332213332133421335213362133721338213392134021341213422134321344213452134621347213482134921350213512135221353213542135521356213572135821359213602136121362213632136421365213662136721368213692137021371213722137321374213752137621377213782137921380213812138221383213842138521386213872138821389213902139121392213932139421395213962139721398213992140021401214022140321404214052140621407214082140921410214112141221413214142141521416214172141821419214202142121422214232142421425214262142721428214292143021431214322143321434214352143621437214382143921440214412144221443214442144521446214472144821449214502145121452214532145421455214562145721458214592146021461214622146321464214652146621467214682146921470214712147221473214742147521476214772147821479214802148121482214832148421485214862148721488214892149021491214922149321494214952149621497214982149921500215012150221503215042150521506215072150821509215102151121512215132151421515215162151721518215192152021521215222152321524215252152621527215282152921530215312153221533215342153521536215372153821539215402154121542215432154421545215462154721548215492155021551215522155321554215552155621557215582155921560215612156221563215642156521566215672156821569215702157121572215732157421575215762157721578215792158021581215822158321584215852158621587215882158921590215912159221593215942159521596215972159821599216002160121602216032160421605216062160721608216092161021611216122161321614216152161621617216182161921620216212162221623216242162521626216272162821629216302163121632216332163421635216362163721638216392164021641216422164321644216452164621647216482164921650216512165221653216542165521656216572165821659216602166121662216632166421665216662166721668216692167021671216722167321674216752167621677216782167921680216812168221683216842168521686216872168821689216902169121692216932169421695216962169721698216992170021701217022170321704217052170621707217082170921710217112171221713217142171521716217172171821719217202172121722217232172421725217262172721728217292173021731217322173321734217352173621737217382173921740217412174221743217442174521746217472174821749217502175121752217532175421755217562175721758217592176021761217622176321764217652176621767217682176921770217712177221773217742177521776217772177821779217802178121782217832178421785217862178721788217892179021791217922179321794217952179621797217982179921800218012180221803218042180521806218072180821809218102181121812218132181421815218162181721818218192182021821218222182321824218252182621827218282182921830218312183221833218342183521836218372183821839218402184121842218432184421845218462184721848218492185021851218522185321854218552185621857218582185921860218612186221863218642186521866218672186821869218702187121872218732187421875218762187721878218792188021881218822188321884218852188621887218882188921890218912189221893218942189521896218972189821899219002190121902219032190421905219062190721908219092191021911219122191321914219152191621917219182191921920219212192221923219242192521926219272192821929219302193121932219332193421935219362193721938219392194021941219422194321944219452194621947219482194921950219512195221953219542195521956219572195821959219602196121962219632196421965219662196721968219692197021971219722197321974219752197621977219782197921980219812198221983219842198521986219872198821989219902199121992219932199421995219962199721998219992200022001220022200322004220052200622007220082200922010220112201222013220142201522016220172201822019220202202122022220232202422025220262202722028220292203022031220322203322034220352203622037220382203922040220412204222043220442204522046220472204822049220502205122052220532205422055220562205722058220592206022061220622206322064220652206622067220682206922070220712207222073220742207522076220772207822079220802208122082220832208422085220862208722088220892209022091220922209322094220952209622097220982209922100221012210222103221042210522106221072210822109221102211122112221132211422115221162211722118221192212022121221222212322124221252212622127221282212922130221312213222133221342213522136221372213822139221402214122142221432214422145221462214722148221492215022151221522215322154221552215622157221582215922160221612216222163221642216522166221672216822169221702217122172221732217422175221762217722178221792218022181221822218322184221852218622187221882218922190221912219222193221942219522196221972219822199222002220122202222032220422205222062220722208222092221022211222122221322214222152221622217222182221922220222212222222223222242222522226222272222822229222302223122232222332223422235222362223722238222392224022241222422224322244222452224622247222482224922250222512225222253222542225522256222572225822259222602226122262222632226422265222662226722268222692227022271222722227322274222752227622277222782227922280222812228222283222842228522286222872228822289222902229122292222932229422295222962229722298222992230022301223022230322304223052230622307223082230922310223112231222313223142231522316223172231822319223202232122322223232232422325223262232722328223292233022331223322233322334223352233622337223382233922340223412234222343223442234522346223472234822349223502235122352223532235422355223562235722358223592236022361223622236322364223652236622367223682236922370223712237222373223742237522376223772237822379223802238122382223832238422385223862238722388223892239022391223922239322394223952239622397223982239922400224012240222403224042240522406224072240822409224102241122412224132241422415224162241722418224192242022421224222242322424224252242622427224282242922430224312243222433224342243522436224372243822439224402244122442224432244422445224462244722448224492245022451224522245322454224552245622457224582245922460224612246222463224642246522466224672246822469224702247122472224732247422475224762247722478224792248022481224822248322484224852248622487224882248922490224912249222493224942249522496224972249822499225002250122502225032250422505225062250722508225092251022511225122251322514225152251622517225182251922520225212252222523225242252522526225272252822529225302253122532225332253422535225362253722538225392254022541225422254322544225452254622547225482254922550225512255222553225542255522556225572255822559225602256122562225632256422565225662256722568225692257022571225722257322574225752257622577225782257922580225812258222583225842258522586225872258822589225902259122592225932259422595225962259722598225992260022601226022260322604226052260622607226082260922610226112261222613226142261522616226172261822619226202262122622226232262422625226262262722628226292263022631226322263322634226352263622637226382263922640226412264222643226442264522646226472264822649226502265122652226532265422655226562265722658226592266022661226622266322664226652266622667226682266922670226712267222673226742267522676226772267822679226802268122682226832268422685226862268722688226892269022691226922269322694226952269622697226982269922700227012270222703227042270522706227072270822709227102271122712227132271422715227162271722718227192272022721227222272322724227252272622727227282272922730227312273222733227342273522736227372273822739227402274122742227432274422745227462274722748227492275022751227522275322754227552275622757227582275922760227612276222763227642276522766227672276822769227702277122772227732277422775227762277722778227792278022781227822278322784227852278622787227882278922790227912279222793227942279522796227972279822799228002280122802228032280422805228062280722808228092281022811228122281322814228152281622817228182281922820228212282222823228242282522826228272282822829228302283122832228332283422835228362283722838228392284022841228422284322844228452284622847228482284922850228512285222853228542285522856228572285822859228602286122862228632286422865228662286722868228692287022871228722287322874228752287622877228782287922880228812288222883228842288522886228872288822889228902289122892228932289422895228962289722898228992290022901229022290322904229052290622907229082290922910229112291222913229142291522916229172291822919229202292122922229232292422925229262292722928229292293022931229322293322934229352293622937229382293922940229412294222943229442294522946229472294822949229502295122952229532295422955229562295722958229592296022961229622296322964229652296622967229682296922970229712297222973229742297522976229772297822979229802298122982229832298422985229862298722988229892299022991229922299322994229952299622997229982299923000230012300223003230042300523006230072300823009230102301123012230132301423015230162301723018230192302023021230222302323024230252302623027230282302923030230312303223033230342303523036230372303823039230402304123042230432304423045230462304723048230492305023051230522305323054230552305623057230582305923060230612306223063230642306523066230672306823069230702307123072230732307423075230762307723078230792308023081230822308323084230852308623087230882308923090230912309223093230942309523096230972309823099231002310123102231032310423105231062310723108231092311023111231122311323114231152311623117231182311923120231212312223123231242312523126231272312823129231302313123132231332313423135231362313723138231392314023141231422314323144231452314623147231482314923150231512315223153231542315523156231572315823159231602316123162231632316423165231662316723168231692317023171231722317323174231752317623177231782317923180231812318223183231842318523186231872318823189231902319123192231932319423195231962319723198231992320023201232022320323204232052320623207232082320923210232112321223213232142321523216232172321823219232202322123222232232322423225232262322723228232292323023231232322323323234232352323623237232382323923240232412324223243232442324523246232472324823249232502325123252232532325423255232562325723258232592326023261232622326323264232652326623267232682326923270232712327223273232742327523276232772327823279232802328123282232832328423285232862328723288232892329023291232922329323294232952329623297232982329923300233012330223303233042330523306233072330823309233102331123312233132331423315233162331723318233192332023321233222332323324233252332623327233282332923330233312333223333233342333523336233372333823339233402334123342233432334423345233462334723348233492335023351233522335323354233552335623357233582335923360233612336223363233642336523366233672336823369233702337123372233732337423375233762337723378233792338023381233822338323384233852338623387233882338923390233912339223393233942339523396233972339823399234002340123402234032340423405234062340723408234092341023411234122341323414234152341623417234182341923420234212342223423234242342523426234272342823429234302343123432234332343423435234362343723438234392344023441234422344323444234452344623447234482344923450234512345223453234542345523456234572345823459234602346123462234632346423465234662346723468234692347023471234722347323474234752347623477234782347923480234812348223483234842348523486234872348823489234902349123492234932349423495234962349723498234992350023501235022350323504235052350623507235082350923510235112351223513235142351523516235172351823519235202352123522235232352423525235262352723528235292353023531235322353323534235352353623537235382353923540235412354223543235442354523546235472354823549235502355123552235532355423555235562355723558235592356023561235622356323564235652356623567235682356923570235712357223573235742357523576235772357823579235802358123582235832358423585235862358723588235892359023591235922359323594235952359623597235982359923600236012360223603236042360523606236072360823609236102361123612236132361423615236162361723618236192362023621236222362323624236252362623627236282362923630236312363223633236342363523636236372363823639236402364123642236432364423645236462364723648236492365023651236522365323654236552365623657236582365923660236612366223663236642366523666236672366823669236702367123672236732367423675236762367723678236792368023681236822368323684236852368623687236882368923690236912369223693236942369523696236972369823699237002370123702237032370423705237062370723708237092371023711237122371323714237152371623717237182371923720237212372223723237242372523726237272372823729237302373123732237332373423735237362373723738237392374023741237422374323744237452374623747237482374923750237512375223753237542375523756237572375823759237602376123762237632376423765237662376723768237692377023771237722377323774237752377623777237782377923780237812378223783237842378523786237872378823789237902379123792237932379423795237962379723798237992380023801238022380323804238052380623807238082380923810238112381223813238142381523816238172381823819238202382123822238232382423825238262382723828238292383023831238322383323834238352383623837238382383923840238412384223843238442384523846238472384823849238502385123852238532385423855238562385723858238592386023861238622386323864238652386623867238682386923870238712387223873238742387523876238772387823879238802388123882238832388423885238862388723888238892389023891238922389323894238952389623897238982389923900239012390223903239042390523906239072390823909239102391123912239132391423915239162391723918239192392023921239222392323924239252392623927239282392923930239312393223933239342393523936239372393823939239402394123942239432394423945239462394723948239492395023951239522395323954239552395623957239582395923960239612396223963239642396523966239672396823969239702397123972239732397423975239762397723978239792398023981239822398323984239852398623987239882398923990239912399223993239942399523996239972399823999240002400124002240032400424005240062400724008240092401024011240122401324014240152401624017240182401924020240212402224023240242402524026240272402824029240302403124032240332403424035240362403724038240392404024041240422404324044240452404624047240482404924050240512405224053240542405524056240572405824059240602406124062240632406424065240662406724068240692407024071240722407324074240752407624077240782407924080240812408224083240842408524086240872408824089240902409124092240932409424095240962409724098240992410024101241022410324104241052410624107241082410924110241112411224113241142411524116241172411824119241202412124122241232412424125241262412724128241292413024131241322413324134241352413624137241382413924140241412414224143241442414524146241472414824149241502415124152241532415424155241562415724158241592416024161241622416324164241652416624167241682416924170241712417224173241742417524176241772417824179241802418124182241832418424185241862418724188241892419024191241922419324194241952419624197241982419924200242012420224203242042420524206242072420824209242102421124212242132421424215242162421724218242192422024221242222422324224242252422624227242282422924230242312423224233242342423524236242372423824239242402424124242242432424424245242462424724248242492425024251242522425324254242552425624257242582425924260242612426224263242642426524266242672426824269242702427124272242732427424275242762427724278242792428024281242822428324284242852428624287242882428924290242912429224293242942429524296242972429824299243002430124302243032430424305243062430724308243092431024311243122431324314243152431624317243182431924320243212432224323243242432524326243272432824329243302433124332243332433424335243362433724338243392434024341243422434324344243452434624347243482434924350243512435224353243542435524356243572435824359243602436124362243632436424365243662436724368243692437024371243722437324374243752437624377243782437924380243812438224383243842438524386243872438824389243902439124392243932439424395243962439724398243992440024401244022440324404244052440624407244082440924410244112441224413244142441524416244172441824419244202442124422244232442424425244262442724428244292443024431244322443324434244352443624437244382443924440244412444224443244442444524446244472444824449244502445124452244532445424455244562445724458244592446024461244622446324464244652446624467244682446924470244712447224473244742447524476244772447824479244802448124482244832448424485244862448724488244892449024491244922449324494244952449624497244982449924500245012450224503245042450524506245072450824509245102451124512245132451424515245162451724518245192452024521245222452324524245252452624527245282452924530245312453224533245342453524536245372453824539245402454124542245432454424545245462454724548245492455024551245522455324554245552455624557245582455924560245612456224563245642456524566245672456824569245702457124572245732457424575245762457724578245792458024581245822458324584245852458624587245882458924590245912459224593245942459524596245972459824599246002460124602246032460424605246062460724608246092461024611246122461324614246152461624617246182461924620246212462224623246242462524626246272462824629246302463124632246332463424635246362463724638246392464024641246422464324644246452464624647246482464924650246512465224653246542465524656246572465824659246602466124662246632466424665246662466724668246692467024671246722467324674246752467624677246782467924680246812468224683246842468524686246872468824689246902469124692246932469424695246962469724698246992470024701247022470324704247052470624707247082470924710247112471224713247142471524716247172471824719247202472124722247232472424725247262472724728247292473024731247322473324734247352473624737247382473924740247412474224743247442474524746247472474824749247502475124752247532475424755247562475724758247592476024761247622476324764247652476624767247682476924770247712477224773247742477524776247772477824779247802478124782247832478424785247862478724788247892479024791247922479324794247952479624797247982479924800248012480224803248042480524806248072480824809248102481124812248132481424815248162481724818248192482024821248222482324824248252482624827248282482924830248312483224833248342483524836248372483824839248402484124842248432484424845248462484724848248492485024851248522485324854248552485624857248582485924860248612486224863248642486524866248672486824869248702487124872248732487424875248762487724878248792488024881248822488324884248852488624887248882488924890248912489224893248942489524896248972489824899249002490124902249032490424905249062490724908249092491024911249122491324914249152491624917249182491924920249212492224923249242492524926249272492824929249302493124932249332493424935249362493724938249392494024941249422494324944249452494624947249482494924950249512495224953249542495524956249572495824959249602496124962249632496424965249662496724968249692497024971249722497324974249752497624977249782497924980249812498224983249842498524986249872498824989249902499124992249932499424995249962499724998249992500025001250022500325004250052500625007250082500925010250112501225013250142501525016250172501825019250202502125022250232502425025250262502725028250292503025031250322503325034250352503625037250382503925040250412504225043250442504525046250472504825049250502505125052250532505425055250562505725058250592506025061250622506325064250652506625067250682506925070250712507225073250742507525076250772507825079250802508125082250832508425085250862508725088250892509025091250922509325094250952509625097250982509925100251012510225103251042510525106251072510825109251102511125112251132511425115251162511725118251192512025121251222512325124251252512625127251282512925130251312513225133251342513525136251372513825139251402514125142251432514425145251462514725148251492515025151251522515325154251552515625157251582515925160251612516225163251642516525166251672516825169251702517125172251732517425175251762517725178251792518025181251822518325184251852518625187251882518925190251912519225193251942519525196251972519825199252002520125202252032520425205252062520725208252092521025211252122521325214252152521625217252182521925220252212522225223252242522525226252272522825229252302523125232252332523425235252362523725238252392524025241252422524325244252452524625247252482524925250252512525225253252542525525256252572525825259252602526125262252632526425265252662526725268252692527025271252722527325274252752527625277252782527925280252812528225283252842528525286252872528825289252902529125292252932529425295252962529725298252992530025301253022530325304253052530625307253082530925310253112531225313253142531525316253172531825319253202532125322253232532425325253262532725328253292533025331253322533325334253352533625337253382533925340253412534225343253442534525346253472534825349253502535125352253532535425355253562535725358253592536025361253622536325364253652536625367253682536925370253712537225373253742537525376253772537825379253802538125382253832538425385253862538725388253892539025391253922539325394253952539625397253982539925400254012540225403254042540525406254072540825409254102541125412254132541425415254162541725418254192542025421254222542325424254252542625427254282542925430254312543225433254342543525436254372543825439254402544125442254432544425445254462544725448254492545025451254522545325454254552545625457254582545925460254612546225463254642546525466254672546825469254702547125472254732547425475254762547725478254792548025481254822548325484254852548625487254882548925490254912549225493254942549525496254972549825499255002550125502255032550425505255062550725508255092551025511255122551325514255152551625517255182551925520255212552225523255242552525526255272552825529255302553125532255332553425535255362553725538255392554025541255422554325544255452554625547255482554925550255512555225553255542555525556255572555825559255602556125562255632556425565255662556725568255692557025571255722557325574255752557625577255782557925580255812558225583255842558525586255872558825589255902559125592255932559425595255962559725598255992560025601256022560325604256052560625607256082560925610256112561225613256142561525616256172561825619256202562125622256232562425625256262562725628256292563025631256322563325634256352563625637256382563925640256412564225643256442564525646256472564825649256502565125652256532565425655256562565725658256592566025661256622566325664256652566625667256682566925670256712567225673256742567525676256772567825679256802568125682256832568425685256862568725688256892569025691256922569325694256952569625697256982569925700257012570225703257042570525706257072570825709257102571125712257132571425715257162571725718257192572025721257222572325724257252572625727257282572925730257312573225733257342573525736257372573825739257402574125742257432574425745257462574725748257492575025751257522575325754257552575625757257582575925760257612576225763257642576525766257672576825769257702577125772257732577425775257762577725778257792578025781257822578325784257852578625787257882578925790257912579225793257942579525796257972579825799258002580125802258032580425805258062580725808258092581025811258122581325814258152581625817258182581925820258212582225823258242582525826258272582825829258302583125832258332583425835258362583725838258392584025841258422584325844258452584625847258482584925850258512585225853258542585525856258572585825859258602586125862258632586425865258662586725868258692587025871258722587325874258752587625877258782587925880258812588225883258842588525886258872588825889258902589125892258932589425895258962589725898258992590025901259022590325904259052590625907259082590925910259112591225913259142591525916259172591825919259202592125922259232592425925259262592725928259292593025931259322593325934259352593625937259382593925940259412594225943259442594525946259472594825949259502595125952259532595425955259562595725958259592596025961259622596325964259652596625967259682596925970259712597225973259742597525976259772597825979259802598125982259832598425985259862598725988259892599025991259922599325994259952599625997259982599926000260012600226003260042600526006260072600826009260102601126012260132601426015260162601726018260192602026021260222602326024260252602626027260282602926030260312603226033260342603526036260372603826039260402604126042260432604426045260462604726048260492605026051260522605326054260552605626057260582605926060260612606226063260642606526066260672606826069260702607126072260732607426075260762607726078260792608026081260822608326084260852608626087260882608926090260912609226093260942609526096260972609826099261002610126102261032610426105261062610726108261092611026111261122611326114261152611626117261182611926120261212612226123261242612526126261272612826129261302613126132261332613426135261362613726138261392614026141261422614326144261452614626147261482614926150261512615226153261542615526156261572615826159261602616126162261632616426165261662616726168261692617026171261722617326174261752617626177261782617926180261812618226183261842618526186261872618826189261902619126192261932619426195261962619726198261992620026201262022620326204262052620626207262082620926210262112621226213262142621526216262172621826219262202622126222262232622426225262262622726228262292623026231262322623326234262352623626237262382623926240262412624226243262442624526246262472624826249262502625126252262532625426255262562625726258262592626026261262622626326264262652626626267262682626926270262712627226273262742627526276262772627826279262802628126282262832628426285262862628726288262892629026291262922629326294262952629626297262982629926300263012630226303263042630526306263072630826309263102631126312263132631426315263162631726318263192632026321263222632326324263252632626327263282632926330263312633226333263342633526336263372633826339263402634126342263432634426345263462634726348263492635026351263522635326354263552635626357263582635926360263612636226363263642636526366263672636826369263702637126372263732637426375263762637726378263792638026381263822638326384263852638626387263882638926390263912639226393263942639526396263972639826399264002640126402264032640426405264062640726408264092641026411264122641326414264152641626417264182641926420264212642226423264242642526426264272642826429264302643126432264332643426435264362643726438264392644026441264422644326444264452644626447264482644926450264512645226453264542645526456264572645826459264602646126462264632646426465264662646726468264692647026471264722647326474264752647626477264782647926480264812648226483264842648526486264872648826489264902649126492264932649426495264962649726498264992650026501265022650326504265052650626507265082650926510265112651226513265142651526516265172651826519265202652126522265232652426525265262652726528265292653026531265322653326534265352653626537265382653926540265412654226543265442654526546265472654826549265502655126552265532655426555265562655726558265592656026561265622656326564265652656626567265682656926570265712657226573265742657526576265772657826579265802658126582265832658426585265862658726588265892659026591265922659326594265952659626597265982659926600266012660226603266042660526606266072660826609266102661126612266132661426615266162661726618266192662026621266222662326624266252662626627266282662926630266312663226633266342663526636266372663826639266402664126642266432664426645266462664726648266492665026651266522665326654266552665626657266582665926660266612666226663266642666526666266672666826669266702667126672266732667426675266762667726678266792668026681266822668326684266852668626687266882668926690266912669226693266942669526696266972669826699267002670126702267032670426705267062670726708267092671026711267122671326714267152671626717267182671926720267212672226723267242672526726267272672826729267302673126732267332673426735267362673726738267392674026741267422674326744267452674626747267482674926750267512675226753267542675526756267572675826759267602676126762267632676426765267662676726768267692677026771267722677326774267752677626777267782677926780267812678226783267842678526786267872678826789267902679126792267932679426795267962679726798267992680026801268022680326804268052680626807268082680926810268112681226813268142681526816268172681826819268202682126822268232682426825268262682726828268292683026831268322683326834268352683626837268382683926840268412684226843268442684526846268472684826849268502685126852268532685426855268562685726858268592686026861268622686326864268652686626867268682686926870268712687226873268742687526876268772687826879268802688126882268832688426885268862688726888268892689026891268922689326894268952689626897268982689926900269012690226903269042690526906269072690826909269102691126912269132691426915269162691726918269192692026921269222692326924269252692626927269282692926930269312693226933269342693526936269372693826939269402694126942269432694426945269462694726948269492695026951269522695326954269552695626957269582695926960269612696226963269642696526966269672696826969269702697126972269732697426975269762697726978269792698026981269822698326984269852698626987269882698926990269912699226993269942699526996269972699826999270002700127002270032700427005270062700727008270092701027011270122701327014270152701627017270182701927020270212702227023270242702527026270272702827029270302703127032270332703427035270362703727038270392704027041270422704327044270452704627047270482704927050270512705227053270542705527056270572705827059270602706127062270632706427065270662706727068270692707027071270722707327074270752707627077270782707927080270812708227083270842708527086270872708827089270902709127092270932709427095270962709727098270992710027101271022710327104271052710627107271082710927110271112711227113271142711527116271172711827119271202712127122271232712427125271262712727128271292713027131271322713327134271352713627137271382713927140271412714227143271442714527146271472714827149271502715127152271532715427155271562715727158271592716027161271622716327164271652716627167271682716927170271712717227173271742717527176271772717827179271802718127182271832718427185271862718727188271892719027191271922719327194271952719627197271982719927200272012720227203272042720527206272072720827209272102721127212272132721427215272162721727218272192722027221272222722327224272252722627227272282722927230272312723227233272342723527236272372723827239272402724127242272432724427245272462724727248272492725027251272522725327254272552725627257272582725927260272612726227263272642726527266272672726827269272702727127272272732727427275272762727727278272792728027281272822728327284272852728627287272882728927290272912729227293272942729527296272972729827299273002730127302273032730427305273062730727308273092731027311273122731327314273152731627317273182731927320273212732227323273242732527326273272732827329273302733127332273332733427335273362733727338273392734027341273422734327344273452734627347273482734927350273512735227353273542735527356273572735827359273602736127362273632736427365273662736727368273692737027371273722737327374273752737627377273782737927380273812738227383273842738527386273872738827389273902739127392273932739427395273962739727398273992740027401274022740327404274052740627407274082740927410274112741227413274142741527416274172741827419274202742127422274232742427425274262742727428274292743027431274322743327434274352743627437274382743927440274412744227443274442744527446274472744827449274502745127452274532745427455274562745727458274592746027461274622746327464274652746627467274682746927470274712747227473274742747527476274772747827479274802748127482274832748427485274862748727488274892749027491274922749327494274952749627497274982749927500275012750227503275042750527506275072750827509275102751127512275132751427515275162751727518275192752027521275222752327524275252752627527275282752927530275312753227533275342753527536275372753827539275402754127542275432754427545275462754727548275492755027551275522755327554275552755627557275582755927560275612756227563275642756527566275672756827569275702757127572275732757427575275762757727578275792758027581275822758327584275852758627587275882758927590275912759227593275942759527596275972759827599276002760127602276032760427605276062760727608276092761027611276122761327614276152761627617276182761927620276212762227623276242762527626276272762827629276302763127632276332763427635276362763727638276392764027641276422764327644276452764627647276482764927650276512765227653276542765527656276572765827659276602766127662276632766427665276662766727668276692767027671276722767327674276752767627677276782767927680276812768227683276842768527686276872768827689276902769127692276932769427695276962769727698276992770027701277022770327704277052770627707277082770927710277112771227713277142771527716277172771827719277202772127722277232772427725277262772727728277292773027731277322773327734277352773627737277382773927740277412774227743277442774527746277472774827749277502775127752277532775427755277562775727758277592776027761277622776327764277652776627767277682776927770277712777227773277742777527776277772777827779277802778127782277832778427785277862778727788277892779027791277922779327794277952779627797277982779927800278012780227803278042780527806278072780827809278102781127812278132781427815278162781727818278192782027821278222782327824278252782627827278282782927830278312783227833278342783527836278372783827839278402784127842278432784427845278462784727848278492785027851278522785327854278552785627857278582785927860278612786227863278642786527866278672786827869278702787127872278732787427875278762787727878278792788027881278822788327884278852788627887278882788927890278912789227893278942789527896278972789827899279002790127902279032790427905279062790727908279092791027911279122791327914279152791627917279182791927920279212792227923279242792527926279272792827929279302793127932279332793427935279362793727938279392794027941279422794327944279452794627947279482794927950279512795227953279542795527956279572795827959279602796127962279632796427965279662796727968279692797027971279722797327974279752797627977279782797927980279812798227983279842798527986279872798827989279902799127992279932799427995279962799727998279992800028001280022800328004280052800628007280082800928010280112801228013280142801528016280172801828019280202802128022280232802428025280262802728028280292803028031280322803328034280352803628037280382803928040280412804228043280442804528046280472804828049280502805128052280532805428055280562805728058280592806028061280622806328064280652806628067280682806928070280712807228073280742807528076280772807828079280802808128082280832808428085280862808728088280892809028091280922809328094280952809628097280982809928100281012810228103281042810528106281072810828109281102811128112281132811428115281162811728118281192812028121281222812328124281252812628127281282812928130281312813228133281342813528136281372813828139281402814128142281432814428145281462814728148281492815028151281522815328154281552815628157281582815928160281612816228163281642816528166281672816828169281702817128172281732817428175281762817728178281792818028181281822818328184281852818628187281882818928190281912819228193281942819528196281972819828199282002820128202282032820428205282062820728208282092821028211282122821328214282152821628217282182821928220282212822228223282242822528226282272822828229282302823128232282332823428235282362823728238282392824028241282422824328244282452824628247282482824928250282512825228253282542825528256282572825828259282602826128262282632826428265282662826728268282692827028271282722827328274282752827628277282782827928280282812828228283282842828528286282872828828289282902829128292282932829428295282962829728298282992830028301283022830328304283052830628307283082830928310283112831228313283142831528316283172831828319283202832128322283232832428325283262832728328283292833028331283322833328334283352833628337283382833928340283412834228343283442834528346283472834828349283502835128352283532835428355283562835728358283592836028361283622836328364283652836628367283682836928370283712837228373283742837528376283772837828379283802838128382283832838428385283862838728388283892839028391283922839328394283952839628397283982839928400284012840228403284042840528406284072840828409284102841128412284132841428415284162841728418284192842028421284222842328424284252842628427284282842928430284312843228433284342843528436284372843828439284402844128442284432844428445284462844728448284492845028451284522845328454284552845628457284582845928460284612846228463284642846528466284672846828469284702847128472284732847428475284762847728478284792848028481284822848328484284852848628487284882848928490284912849228493284942849528496284972849828499285002850128502285032850428505285062850728508285092851028511285122851328514285152851628517285182851928520285212852228523285242852528526285272852828529285302853128532285332853428535285362853728538285392854028541285422854328544285452854628547285482854928550285512855228553285542855528556285572855828559285602856128562285632856428565285662856728568285692857028571285722857328574285752857628577285782857928580285812858228583285842858528586285872858828589285902859128592285932859428595285962859728598285992860028601286022860328604286052860628607286082860928610286112861228613286142861528616286172861828619286202862128622286232862428625286262862728628286292863028631286322863328634286352863628637286382863928640286412864228643286442864528646286472864828649286502865128652286532865428655286562865728658286592866028661286622866328664286652866628667286682866928670286712867228673286742867528676286772867828679286802868128682286832868428685286862868728688286892869028691286922869328694286952869628697286982869928700287012870228703287042870528706287072870828709287102871128712287132871428715287162871728718287192872028721287222872328724287252872628727287282872928730287312873228733287342873528736287372873828739287402874128742287432874428745287462874728748287492875028751287522875328754287552875628757287582875928760287612876228763287642876528766287672876828769287702877128772287732877428775287762877728778287792878028781287822878328784287852878628787287882878928790287912879228793287942879528796287972879828799288002880128802288032880428805288062880728808288092881028811288122881328814288152881628817288182881928820288212882228823288242882528826288272882828829288302883128832288332883428835288362883728838288392884028841288422884328844288452884628847288482884928850288512885228853288542885528856288572885828859288602886128862288632886428865288662886728868288692887028871288722887328874288752887628877288782887928880288812888228883288842888528886288872888828889288902889128892288932889428895288962889728898288992890028901289022890328904289052890628907289082890928910289112891228913289142891528916289172891828919289202892128922289232892428925289262892728928289292893028931289322893328934289352893628937289382893928940289412894228943289442894528946289472894828949289502895128952289532895428955289562895728958289592896028961289622896328964289652896628967289682896928970289712897228973289742897528976289772897828979289802898128982289832898428985289862898728988289892899028991289922899328994289952899628997289982899929000290012900229003290042900529006290072900829009290102901129012290132901429015290162901729018290192902029021290222902329024290252902629027290282902929030290312903229033290342903529036290372903829039290402904129042290432904429045290462904729048290492905029051290522905329054290552905629057290582905929060290612906229063290642906529066290672906829069290702907129072290732907429075290762907729078290792908029081290822908329084290852908629087290882908929090290912909229093290942909529096290972909829099291002910129102291032910429105291062910729108291092911029111291122911329114291152911629117291182911929120291212912229123291242912529126291272912829129291302913129132291332913429135291362913729138291392914029141291422914329144291452914629147291482914929150291512915229153291542915529156291572915829159291602916129162291632916429165291662916729168291692917029171291722917329174291752917629177291782917929180291812918229183291842918529186291872918829189291902919129192291932919429195291962919729198291992920029201292022920329204292052920629207292082920929210292112921229213292142921529216292172921829219292202922129222292232922429225292262922729228292292923029231292322923329234292352923629237292382923929240292412924229243292442924529246292472924829249292502925129252292532925429255292562925729258292592926029261292622926329264292652926629267292682926929270292712927229273292742927529276292772927829279292802928129282292832928429285292862928729288292892929029291292922929329294292952929629297292982929929300293012930229303293042930529306293072930829309293102931129312293132931429315293162931729318293192932029321293222932329324293252932629327293282932929330293312933229333293342933529336293372933829339293402934129342293432934429345293462934729348293492935029351293522935329354293552935629357293582935929360293612936229363293642936529366293672936829369293702937129372293732937429375293762937729378293792938029381293822938329384293852938629387293882938929390293912939229393293942939529396293972939829399294002940129402294032940429405294062940729408294092941029411294122941329414294152941629417294182941929420294212942229423294242942529426294272942829429294302943129432294332943429435294362943729438294392944029441294422944329444294452944629447294482944929450294512945229453294542945529456294572945829459294602946129462294632946429465294662946729468294692947029471294722947329474294752947629477294782947929480294812948229483294842948529486294872948829489294902949129492294932949429495294962949729498294992950029501295022950329504295052950629507295082950929510295112951229513295142951529516295172951829519295202952129522295232952429525295262952729528295292953029531295322953329534295352953629537295382953929540295412954229543295442954529546295472954829549295502955129552295532955429555295562955729558295592956029561295622956329564295652956629567295682956929570295712957229573295742957529576295772957829579295802958129582295832958429585295862958729588295892959029591295922959329594295952959629597295982959929600296012960229603296042960529606296072960829609296102961129612296132961429615296162961729618296192962029621296222962329624296252962629627296282962929630296312963229633296342963529636296372963829639296402964129642296432964429645296462964729648296492965029651296522965329654296552965629657296582965929660296612966229663296642966529666296672966829669296702967129672296732967429675296762967729678296792968029681296822968329684296852968629687296882968929690296912969229693296942969529696296972969829699297002970129702297032970429705297062970729708297092971029711297122971329714297152971629717297182971929720297212972229723297242972529726297272972829729297302973129732297332973429735297362973729738297392974029741297422974329744297452974629747297482974929750297512975229753297542975529756297572975829759297602976129762297632976429765297662976729768297692977029771297722977329774297752977629777297782977929780297812978229783297842978529786297872978829789297902979129792297932979429795297962979729798297992980029801298022980329804298052980629807298082980929810298112981229813298142981529816298172981829819298202982129822298232982429825298262982729828298292983029831298322983329834298352983629837298382983929840298412984229843298442984529846298472984829849298502985129852298532985429855298562985729858298592986029861298622986329864298652986629867298682986929870298712987229873298742987529876298772987829879298802988129882298832988429885298862988729888298892989029891298922989329894298952989629897298982989929900299012990229903299042990529906299072990829909299102991129912299132991429915299162991729918299192992029921299222992329924299252992629927299282992929930299312993229933299342993529936299372993829939299402994129942299432994429945299462994729948299492995029951299522995329954299552995629957299582995929960299612996229963299642996529966299672996829969299702997129972299732997429975299762997729978299792998029981299822998329984299852998629987299882998929990299912999229993299942999529996299972999829999300003000130002300033000430005300063000730008300093001030011300123001330014300153001630017300183001930020300213002230023300243002530026300273002830029300303003130032300333003430035300363003730038300393004030041300423004330044300453004630047300483004930050300513005230053300543005530056300573005830059300603006130062300633006430065300663006730068300693007030071300723007330074300753007630077300783007930080300813008230083300843008530086300873008830089300903009130092300933009430095300963009730098300993010030101301023010330104301053010630107301083010930110301113011230113301143011530116301173011830119301203012130122301233012430125301263012730128301293013030131301323013330134301353013630137301383013930140301413014230143301443014530146301473014830149301503015130152301533015430155301563015730158301593016030161301623016330164301653016630167301683016930170301713017230173301743017530176301773017830179301803018130182301833018430185301863018730188301893019030191301923019330194301953019630197301983019930200302013020230203302043020530206302073020830209302103021130212302133021430215302163021730218302193022030221302223022330224302253022630227302283022930230302313023230233302343023530236302373023830239302403024130242302433024430245302463024730248302493025030251302523025330254302553025630257302583025930260302613026230263302643026530266302673026830269302703027130272302733027430275302763027730278302793028030281302823028330284302853028630287302883028930290302913029230293302943029530296302973029830299303003030130302303033030430305303063030730308303093031030311303123031330314303153031630317303183031930320303213032230323303243032530326303273032830329303303033130332303333033430335303363033730338303393034030341303423034330344303453034630347303483034930350303513035230353303543035530356303573035830359303603036130362303633036430365303663036730368303693037030371303723037330374303753037630377303783037930380303813038230383303843038530386303873038830389303903039130392303933039430395303963039730398303993040030401304023040330404304053040630407304083040930410304113041230413304143041530416304173041830419304203042130422304233042430425304263042730428304293043030431304323043330434304353043630437304383043930440304413044230443304443044530446304473044830449304503045130452304533045430455304563045730458304593046030461304623046330464304653046630467304683046930470304713047230473304743047530476304773047830479304803048130482304833048430485304863048730488304893049030491304923049330494304953049630497304983049930500305013050230503305043050530506305073050830509305103051130512305133051430515305163051730518305193052030521305223052330524305253052630527305283052930530305313053230533305343053530536305373053830539305403054130542305433054430545305463054730548305493055030551305523055330554305553055630557305583055930560305613056230563305643056530566305673056830569305703057130572305733057430575305763057730578305793058030581305823058330584305853058630587305883058930590305913059230593305943059530596305973059830599306003060130602306033060430605306063060730608306093061030611306123061330614306153061630617306183061930620306213062230623306243062530626306273062830629306303063130632306333063430635306363063730638306393064030641306423064330644306453064630647306483064930650306513065230653306543065530656306573065830659306603066130662306633066430665306663066730668306693067030671306723067330674306753067630677306783067930680306813068230683306843068530686306873068830689306903069130692306933069430695306963069730698306993070030701307023070330704307053070630707307083070930710307113071230713307143071530716307173071830719307203072130722307233072430725307263072730728307293073030731307323073330734307353073630737307383073930740307413074230743307443074530746307473074830749307503075130752307533075430755307563075730758307593076030761307623076330764307653076630767307683076930770307713077230773307743077530776307773077830779307803078130782307833078430785307863078730788307893079030791307923079330794307953079630797307983079930800308013080230803308043080530806308073080830809308103081130812308133081430815308163081730818308193082030821308223082330824308253082630827308283082930830308313083230833308343083530836308373083830839308403084130842308433084430845308463084730848308493085030851308523085330854308553085630857308583085930860308613086230863308643086530866308673086830869308703087130872308733087430875308763087730878308793088030881308823088330884308853088630887308883088930890308913089230893308943089530896308973089830899309003090130902309033090430905309063090730908309093091030911309123091330914309153091630917309183091930920309213092230923309243092530926309273092830929309303093130932309333093430935309363093730938309393094030941309423094330944309453094630947309483094930950309513095230953309543095530956309573095830959309603096130962309633096430965309663096730968309693097030971309723097330974309753097630977309783097930980309813098230983309843098530986309873098830989309903099130992309933099430995309963099730998309993100031001310023100331004310053100631007310083100931010310113101231013310143101531016310173101831019310203102131022310233102431025310263102731028310293103031031310323103331034310353103631037310383103931040310413104231043310443104531046310473104831049310503105131052310533105431055310563105731058310593106031061310623106331064310653106631067310683106931070310713107231073310743107531076310773107831079310803108131082310833108431085310863108731088310893109031091310923109331094310953109631097310983109931100311013110231103311043110531106311073110831109311103111131112311133111431115311163111731118311193112031121311223112331124311253112631127311283112931130311313113231133311343113531136311373113831139311403114131142311433114431145311463114731148311493115031151311523115331154311553115631157311583115931160311613116231163311643116531166311673116831169311703117131172311733117431175311763117731178311793118031181311823118331184311853118631187311883118931190311913119231193311943119531196311973119831199312003120131202312033120431205312063120731208312093121031211312123121331214312153121631217312183121931220312213122231223312243122531226312273122831229312303123131232312333123431235312363123731238312393124031241312423124331244312453124631247312483124931250312513125231253312543125531256312573125831259312603126131262312633126431265312663126731268312693127031271312723127331274312753127631277312783127931280312813128231283312843128531286312873128831289312903129131292312933129431295312963129731298312993130031301313023130331304313053130631307313083130931310313113131231313313143131531316313173131831319313203132131322313233132431325313263132731328313293133031331313323133331334313353133631337313383133931340313413134231343313443134531346313473134831349313503135131352313533135431355313563135731358313593136031361313623136331364313653136631367313683136931370313713137231373313743137531376313773137831379313803138131382313833138431385313863138731388313893139031391313923139331394313953139631397313983139931400314013140231403314043140531406314073140831409314103141131412314133141431415314163141731418314193142031421314223142331424314253142631427314283142931430314313143231433314343143531436314373143831439314403144131442314433144431445314463144731448314493145031451314523145331454314553145631457314583145931460314613146231463314643146531466314673146831469314703147131472314733147431475314763147731478314793148031481314823148331484314853148631487314883148931490314913149231493314943149531496314973149831499315003150131502315033150431505315063150731508315093151031511315123151331514315153151631517315183151931520315213152231523315243152531526315273152831529315303153131532315333153431535315363153731538315393154031541315423154331544315453154631547315483154931550315513155231553315543155531556315573155831559315603156131562315633156431565315663156731568315693157031571315723157331574315753157631577315783157931580315813158231583315843158531586315873158831589315903159131592315933159431595315963159731598315993160031601316023160331604316053160631607316083160931610316113161231613316143161531616316173161831619316203162131622316233162431625316263162731628316293163031631316323163331634316353163631637316383163931640316413164231643316443164531646316473164831649316503165131652316533165431655316563165731658316593166031661316623166331664316653166631667316683166931670316713167231673316743167531676316773167831679316803168131682316833168431685316863168731688316893169031691316923169331694316953169631697316983169931700317013170231703317043170531706317073170831709317103171131712317133171431715317163171731718317193172031721317223172331724317253172631727317283172931730317313173231733317343173531736317373173831739317403174131742317433174431745317463174731748317493175031751317523175331754317553175631757317583175931760317613176231763317643176531766317673176831769317703177131772317733177431775317763177731778317793178031781317823178331784317853178631787317883178931790317913179231793317943179531796317973179831799318003180131802318033180431805318063180731808318093181031811318123181331814318153181631817318183181931820318213182231823318243182531826318273182831829318303183131832318333183431835318363183731838318393184031841318423184331844318453184631847318483184931850318513185231853318543185531856318573185831859318603186131862318633186431865318663186731868318693187031871318723187331874318753187631877318783187931880318813188231883318843188531886318873188831889318903189131892318933189431895318963189731898318993190031901319023190331904319053190631907319083190931910319113191231913319143191531916319173191831919319203192131922319233192431925319263192731928319293193031931319323193331934319353193631937319383193931940319413194231943319443194531946319473194831949319503195131952319533195431955319563195731958319593196031961319623196331964319653196631967319683196931970319713197231973319743197531976319773197831979319803198131982319833198431985319863198731988319893199031991319923199331994319953199631997319983199932000320013200232003320043200532006320073200832009320103201132012320133201432015320163201732018320193202032021320223202332024320253202632027320283202932030320313203232033320343203532036320373203832039320403204132042320433204432045320463204732048320493205032051320523205332054320553205632057320583205932060320613206232063320643206532066320673206832069320703207132072320733207432075320763207732078320793208032081320823208332084320853208632087320883208932090320913209232093320943209532096320973209832099321003210132102321033210432105321063210732108321093211032111321123211332114321153211632117321183211932120321213212232123321243212532126321273212832129321303213132132321333213432135321363213732138321393214032141321423214332144321453214632147321483214932150321513215232153321543215532156321573215832159321603216132162321633216432165321663216732168321693217032171321723217332174321753217632177321783217932180321813218232183321843218532186321873218832189321903219132192321933219432195321963219732198321993220032201322023220332204322053220632207322083220932210322113221232213322143221532216322173221832219322203222132222322233222432225322263222732228322293223032231322323223332234322353223632237322383223932240322413224232243322443224532246322473224832249322503225132252322533225432255322563225732258322593226032261322623226332264322653226632267322683226932270322713227232273322743227532276322773227832279322803228132282322833228432285322863228732288322893229032291322923229332294322953229632297322983229932300323013230232303323043230532306323073230832309323103231132312323133231432315323163231732318323193232032321323223232332324323253232632327323283232932330323313233232333323343233532336323373233832339323403234132342323433234432345323463234732348323493235032351323523235332354323553235632357323583235932360323613236232363323643236532366323673236832369323703237132372323733237432375323763237732378323793238032381323823238332384323853238632387323883238932390323913239232393323943239532396323973239832399324003240132402324033240432405324063240732408324093241032411324123241332414324153241632417324183241932420324213242232423324243242532426324273242832429324303243132432324333243432435324363243732438324393244032441324423244332444324453244632447324483244932450324513245232453324543245532456324573245832459324603246132462324633246432465324663246732468324693247032471324723247332474324753247632477324783247932480324813248232483324843248532486324873248832489324903249132492324933249432495324963249732498324993250032501325023250332504325053250632507325083250932510325113251232513325143251532516325173251832519325203252132522325233252432525325263252732528325293253032531325323253332534325353253632537325383253932540325413254232543325443254532546325473254832549325503255132552325533255432555325563255732558325593256032561325623256332564325653256632567325683256932570325713257232573325743257532576325773257832579325803258132582325833258432585325863258732588325893259032591325923259332594325953259632597325983259932600326013260232603326043260532606326073260832609326103261132612326133261432615326163261732618326193262032621326223262332624326253262632627326283262932630326313263232633326343263532636326373263832639326403264132642326433264432645326463264732648326493265032651326523265332654326553265632657326583265932660326613266232663326643266532666326673266832669326703267132672326733267432675326763267732678326793268032681326823268332684326853268632687326883268932690326913269232693326943269532696326973269832699327003270132702327033270432705327063270732708327093271032711327123271332714327153271632717327183271932720327213272232723327243272532726327273272832729327303273132732327333273432735327363273732738327393274032741327423274332744327453274632747327483274932750327513275232753327543275532756327573275832759327603276132762327633276432765327663276732768327693277032771327723277332774327753277632777327783277932780327813278232783327843278532786327873278832789327903279132792327933279432795327963279732798327993280032801328023280332804328053280632807328083280932810328113281232813328143281532816328173281832819328203282132822328233282432825328263282732828328293283032831328323283332834328353283632837328383283932840328413284232843328443284532846328473284832849328503285132852328533285432855328563285732858328593286032861328623286332864328653286632867328683286932870328713287232873328743287532876328773287832879328803288132882328833288432885328863288732888328893289032891328923289332894328953289632897328983289932900329013290232903329043290532906329073290832909329103291132912329133291432915329163291732918329193292032921329223292332924329253292632927329283292932930329313293232933329343293532936329373293832939329403294132942329433294432945329463294732948329493295032951329523295332954329553295632957329583295932960329613296232963329643296532966329673296832969329703297132972329733297432975329763297732978329793298032981329823298332984329853298632987329883298932990329913299232993329943299532996329973299832999330003300133002330033300433005330063300733008330093301033011330123301333014330153301633017330183301933020330213302233023330243302533026330273302833029330303303133032330333303433035330363303733038330393304033041330423304333044330453304633047330483304933050330513305233053330543305533056330573305833059330603306133062330633306433065330663306733068330693307033071330723307333074330753307633077330783307933080330813308233083330843308533086330873308833089330903309133092330933309433095330963309733098330993310033101331023310333104331053310633107331083310933110331113311233113331143311533116331173311833119331203312133122331233312433125331263312733128331293313033131331323313333134331353313633137331383313933140331413314233143331443314533146331473314833149331503315133152331533315433155331563315733158331593316033161331623316333164331653316633167331683316933170331713317233173331743317533176331773317833179331803318133182331833318433185331863318733188331893319033191331923319333194331953319633197331983319933200332013320233203332043320533206332073320833209332103321133212332133321433215332163321733218332193322033221332223322333224332253322633227332283322933230332313323233233332343323533236332373323833239332403324133242332433324433245332463324733248332493325033251332523325333254332553325633257332583325933260332613326233263332643326533266332673326833269332703327133272332733327433275332763327733278332793328033281332823328333284332853328633287332883328933290332913329233293332943329533296332973329833299333003330133302333033330433305333063330733308333093331033311333123331333314333153331633317333183331933320333213332233323333243332533326333273332833329333303333133332333333333433335333363333733338333393334033341333423334333344333453334633347333483334933350333513335233353333543335533356333573335833359333603336133362333633336433365333663336733368333693337033371333723337333374333753337633377333783337933380333813338233383333843338533386333873338833389333903339133392333933339433395333963339733398333993340033401334023340333404334053340633407334083340933410334113341233413334143341533416334173341833419334203342133422334233342433425334263342733428334293343033431334323343333434334353343633437334383343933440334413344233443334443344533446334473344833449334503345133452334533345433455334563345733458334593346033461334623346333464334653346633467334683346933470334713347233473334743347533476334773347833479334803348133482334833348433485334863348733488334893349033491334923349333494334953349633497334983349933500335013350233503335043350533506335073350833509335103351133512335133351433515335163351733518335193352033521335223352333524335253352633527335283352933530335313353233533335343353533536335373353833539335403354133542335433354433545335463354733548335493355033551335523355333554335553355633557335583355933560335613356233563335643356533566335673356833569335703357133572335733357433575335763357733578335793358033581335823358333584335853358633587335883358933590335913359233593335943359533596335973359833599336003360133602336033360433605336063360733608336093361033611336123361333614336153361633617336183361933620336213362233623336243362533626336273362833629336303363133632336333363433635336363363733638336393364033641336423364333644336453364633647336483364933650336513365233653336543365533656336573365833659336603366133662336633366433665336663366733668336693367033671336723367333674336753367633677336783367933680336813368233683336843368533686336873368833689336903369133692336933369433695336963369733698336993370033701337023370333704337053370633707337083370933710337113371233713337143371533716337173371833719337203372133722337233372433725337263372733728337293373033731337323373333734337353373633737337383373933740337413374233743337443374533746337473374833749337503375133752337533375433755337563375733758337593376033761337623376333764337653376633767337683376933770337713377233773337743377533776337773377833779337803378133782337833378433785337863378733788337893379033791337923379333794337953379633797337983379933800338013380233803338043380533806338073380833809338103381133812338133381433815338163381733818338193382033821338223382333824338253382633827338283382933830338313383233833338343383533836338373383833839338403384133842338433384433845338463384733848338493385033851338523385333854338553385633857338583385933860338613386233863338643386533866338673386833869338703387133872338733387433875338763387733878338793388033881338823388333884338853388633887338883388933890338913389233893338943389533896338973389833899339003390133902339033390433905339063390733908339093391033911339123391333914339153391633917339183391933920339213392233923339243392533926339273392833929339303393133932339333393433935339363393733938339393394033941339423394333944339453394633947339483394933950339513395233953339543395533956339573395833959339603396133962339633396433965339663396733968339693397033971339723397333974339753397633977339783397933980339813398233983339843398533986339873398833989339903399133992339933399433995339963399733998339993400034001340023400334004340053400634007340083400934010340113401234013340143401534016340173401834019340203402134022340233402434025340263402734028340293403034031340323403334034340353403634037340383403934040340413404234043340443404534046340473404834049340503405134052340533405434055340563405734058340593406034061340623406334064340653406634067340683406934070340713407234073340743407534076340773407834079340803408134082340833408434085340863408734088340893409034091340923409334094340953409634097340983409934100341013410234103341043410534106341073410834109341103411134112341133411434115341163411734118341193412034121341223412334124341253412634127341283412934130341313413234133341343413534136341373413834139341403414134142341433414434145341463414734148341493415034151341523415334154341553415634157341583415934160341613416234163341643416534166341673416834169341703417134172341733417434175341763417734178341793418034181341823418334184341853418634187341883418934190341913419234193341943419534196341973419834199342003420134202342033420434205342063420734208342093421034211342123421334214342153421634217342183421934220342213422234223342243422534226342273422834229342303423134232342333423434235342363423734238342393424034241342423424334244342453424634247342483424934250342513425234253342543425534256342573425834259342603426134262342633426434265342663426734268342693427034271342723427334274342753427634277342783427934280342813428234283342843428534286342873428834289342903429134292342933429434295342963429734298342993430034301343023430334304343053430634307343083430934310343113431234313343143431534316343173431834319343203432134322343233432434325343263432734328343293433034331343323433334334343353433634337343383433934340343413434234343343443434534346343473434834349343503435134352343533435434355343563435734358343593436034361343623436334364343653436634367343683436934370343713437234373343743437534376343773437834379343803438134382343833438434385343863438734388343893439034391343923439334394343953439634397343983439934400344013440234403344043440534406344073440834409344103441134412344133441434415344163441734418344193442034421344223442334424344253442634427344283442934430344313443234433344343443534436344373443834439344403444134442344433444434445344463444734448344493445034451344523445334454344553445634457344583445934460344613446234463344643446534466344673446834469344703447134472344733447434475344763447734478344793448034481344823448334484344853448634487344883448934490344913449234493344943449534496344973449834499345003450134502345033450434505345063450734508345093451034511345123451334514345153451634517345183451934520345213452234523345243452534526345273452834529345303453134532345333453434535345363453734538345393454034541345423454334544345453454634547345483454934550345513455234553345543455534556345573455834559345603456134562345633456434565345663456734568345693457034571345723457334574345753457634577345783457934580345813458234583345843458534586345873458834589345903459134592345933459434595345963459734598345993460034601346023460334604346053460634607346083460934610346113461234613346143461534616346173461834619346203462134622346233462434625346263462734628346293463034631346323463334634346353463634637346383463934640346413464234643346443464534646346473464834649346503465134652346533465434655346563465734658346593466034661346623466334664346653466634667346683466934670346713467234673346743467534676346773467834679346803468134682346833468434685346863468734688346893469034691346923469334694346953469634697346983469934700347013470234703347043470534706347073470834709347103471134712347133471434715347163471734718347193472034721347223472334724347253472634727347283472934730347313473234733347343473534736347373473834739347403474134742347433474434745347463474734748347493475034751347523475334754347553475634757347583475934760347613476234763347643476534766347673476834769347703477134772347733477434775347763477734778347793478034781347823478334784347853478634787347883478934790347913479234793347943479534796347973479834799348003480134802348033480434805348063480734808348093481034811348123481334814348153481634817348183481934820348213482234823348243482534826348273482834829348303483134832348333483434835348363483734838348393484034841348423484334844348453484634847348483484934850348513485234853348543485534856348573485834859348603486134862348633486434865348663486734868348693487034871348723487334874348753487634877348783487934880348813488234883348843488534886348873488834889348903489134892348933489434895348963489734898348993490034901349023490334904349053490634907349083490934910349113491234913349143491534916349173491834919349203492134922349233492434925349263492734928349293493034931349323493334934349353493634937349383493934940349413494234943349443494534946349473494834949349503495134952349533495434955349563495734958349593496034961349623496334964349653496634967349683496934970349713497234973349743497534976349773497834979349803498134982349833498434985349863498734988349893499034991349923499334994349953499634997349983499935000350013500235003350043500535006350073500835009350103501135012350133501435015350163501735018350193502035021350223502335024350253502635027350283502935030350313503235033350343503535036350373503835039350403504135042350433504435045350463504735048350493505035051350523505335054350553505635057350583505935060350613506235063350643506535066350673506835069350703507135072350733507435075350763507735078350793508035081350823508335084350853508635087350883508935090350913509235093350943509535096350973509835099351003510135102351033510435105351063510735108351093511035111351123511335114351153511635117351183511935120351213512235123351243512535126351273512835129351303513135132351333513435135351363513735138351393514035141351423514335144351453514635147351483514935150351513515235153351543515535156351573515835159351603516135162351633516435165351663516735168351693517035171351723517335174351753517635177351783517935180351813518235183351843518535186351873518835189351903519135192351933519435195351963519735198351993520035201352023520335204352053520635207352083520935210352113521235213352143521535216352173521835219352203522135222352233522435225352263522735228352293523035231352323523335234352353523635237352383523935240352413524235243352443524535246352473524835249352503525135252352533525435255352563525735258352593526035261352623526335264352653526635267352683526935270352713527235273352743527535276352773527835279352803528135282352833528435285352863528735288352893529035291352923529335294352953529635297352983529935300353013530235303353043530535306353073530835309353103531135312353133531435315353163531735318353193532035321353223532335324353253532635327353283532935330353313533235333353343533535336353373533835339353403534135342353433534435345353463534735348353493535035351353523535335354353553535635357353583535935360353613536235363353643536535366353673536835369353703537135372353733537435375353763537735378353793538035381353823538335384353853538635387353883538935390353913539235393353943539535396353973539835399354003540135402354033540435405354063540735408354093541035411354123541335414354153541635417354183541935420354213542235423354243542535426354273542835429354303543135432354333543435435354363543735438354393544035441354423544335444354453544635447354483544935450354513545235453354543545535456354573545835459354603546135462354633546435465354663546735468354693547035471354723547335474354753547635477354783547935480354813548235483354843548535486354873548835489354903549135492354933549435495354963549735498354993550035501355023550335504355053550635507355083550935510355113551235513355143551535516355173551835519355203552135522355233552435525355263552735528355293553035531355323553335534355353553635537355383553935540355413554235543355443554535546355473554835549355503555135552355533555435555355563555735558355593556035561355623556335564355653556635567355683556935570355713557235573355743557535576355773557835579355803558135582355833558435585355863558735588355893559035591355923559335594355953559635597355983559935600356013560235603356043560535606356073560835609356103561135612356133561435615356163561735618356193562035621356223562335624356253562635627356283562935630356313563235633356343563535636356373563835639356403564135642356433564435645356463564735648356493565035651356523565335654356553565635657356583565935660356613566235663356643566535666356673566835669356703567135672356733567435675356763567735678356793568035681356823568335684356853568635687356883568935690356913569235693356943569535696356973569835699357003570135702357033570435705357063570735708357093571035711
  1. package sg
  2. import (
  3. "archive/zip"
  4. "bytes"
  5. "encoding/base64"
  6. //"github.com/jung-kurt/gofpdf"
  7. //"github.com/tjfoc/gmsm/sm3"
  8. "math"
  9. //"crypto/x509/pkix"
  10. "encoding/json"
  11. "fmt"
  12. "gdyb/controllers"
  13. "gdyb/enums"
  14. "gdyb/models"
  15. "gdyb/service"
  16. "gdyb/utils"
  17. "github.com/astaxie/beego"
  18. "github.com/axgle/mahonia"
  19. "github.com/gorilla/websocket"
  20. "github.com/jinzhu/gorm"
  21. "github.com/shopspring/decimal"
  22. "github.com/go-ole/go-ole"
  23. "github.com/go-ole/go-ole/oleutil"
  24. "io"
  25. "io/ioutil"
  26. //"math"
  27. "math/rand"
  28. "net/http"
  29. "net/url"
  30. "os"
  31. "path/filepath"
  32. "regexp"
  33. "strconv"
  34. "strings"
  35. "syscall"
  36. "time"
  37. "unsafe"
  38. )
  39. type HisApiController struct {
  40. controllers.BaseAuthAPIController
  41. }
  42. func HisManagerApiRegistRouters() {
  43. //挂号
  44. beego.Router("/api/register/get", &HisApiController{}, "get:GetRegisterInfo")
  45. //上传就诊信息-上传明细-结算
  46. beego.Router("/api/upload/get", &HisApiController{}, "get:GetUploadInfo")
  47. //查询
  48. beego.Router("/api/settle/query", &HisApiController{}, "get:GetSettleAccounts")
  49. //对总账
  50. beego.Router("/api/checkaccount/get", &HisApiController{}, "get:GetCheckAccount")
  51. //对明细
  52. beego.Router("/api/checkdetailaccount/get", &HisApiController{}, "get:GetCheckDetailAccount")
  53. //退费,退明细
  54. beego.Router("/api/refund/post", &HisApiController{}, "get:Refund")
  55. //退号
  56. beego.Router("/api/refundnumber/post", &HisApiController{}, "get:RefundNumber")
  57. //退明细
  58. beego.Router("/api/refunddetail/post", &HisApiController{}, "get:RefundDetail")
  59. //上传就诊信息-上传明细-预结算
  60. beego.Router("/api/presettle/get", &HisApiController{}, "get:GetPreUploadInfo")
  61. //beego.Router("/api/treatment/check", &HisApiController{}, "get:CheckTreatment")
  62. beego.Router("/api/org/info", &HisApiController{}, "get:GetOrgInfo")
  63. beego.Router("/api/readcard", &HisApiController{}, "get:ReadCard")
  64. beego.Router("/api/310", &HisApiController{}, "get:Check310")
  65. beego.Router("/api/390", &HisApiController{}, "get:Check390")
  66. beego.Router("/api/patient/info", &HisApiController{}, "get:GetPatientInfo")
  67. beego.Router("/api/checkcode/get", &HisApiController{}, "get:GetCheckCode")
  68. beego.Router("/api/uncheckcode/get", &HisApiController{}, "get:UnCheckCode")
  69. beego.Router("/api/psn/putonrecord", &HisApiController{}, "get:PsnPutOnRecord")
  70. beego.Router("/api/psn/unputonrecord", &HisApiController{}, "get:PsnUnPutOnRecord")
  71. beego.Router("/api/psn/ncds/putonrecord", &HisApiController{}, "get:PsnPutNCDSOnRecord")
  72. beego.Router("/api/psn/ncds/unputonrecord", &HisApiController{}, "get:PsnPutUnNCDSOnRecord")
  73. beego.Router("/api/reversal", &HisApiController{}, "get:ReversalData")
  74. beego.Router("/api/reversal/other", &HisApiController{}, "get:ReversalOtherData")
  75. beego.Router("/api/settlelist/get", &HisApiController{}, "get:GetSettleList")
  76. beego.Router("/api/settlelisthosptial/get", &HisApiController{}, "get:GetSettleListHospital")
  77. beego.Router("/api/pwd/check", &HisApiController{}, "get:CheckCardPWD")
  78. beego.Router("/api/insutype/check", &HisApiController{}, "get:CheckInsutype")
  79. //beego.Router("/api/batchsettlelist/get", &HisApiController{}, "get:GetBatchSettleList")
  80. beego.Router("/api/psn/info", &HisApiController{}, "get:GetPsnNcdsInfo")
  81. beego.Router("/api/allopatry/refund", &HisApiController{}, "post:RefundAllopatry")
  82. beego.Router("/api/check", &HisApiController{}, "get:Check")
  83. //beego.Router("/api/check3101", &HisApiController{}, "get:Check3101")
  84. //beego.Router("/api/check3102", &HisApiController{}, "get:Check3102")
  85. beego.Router("/90990", &HisApiController{}, "get:CheckCardPWDTwo")
  86. beego.Router("/9001", &HisApiController{}, "get:Get9001")
  87. //beego.Router("/api/readelecard", &HisApiController{}, "get:ReadEleCard")
  88. beego.Router("/api/3202", &HisApiController{}, "get:Post3202")
  89. beego.Router("/api/3202b", &HisApiController{}, "get:Post3202b")
  90. beego.Router("/api/1608", &HisApiController{}, "get:Post1608")
  91. beego.Router("/api/5302", &HisApiController{}, "get:Post5302")
  92. beego.Router("/api/3501", &HisApiController{}, "post:Post3501")
  93. beego.Router("/api/readele", &HisApiController{}, "get:ReadEleToken")
  94. beego.Router("/api/2505", &HisApiController{}, "get:Get2505")
  95. beego.Router("/api/4201A", &HisApiController{}, "get:Get4201A")
  96. beego.Router("/api/4202", &HisApiController{}, "get:Get4202")
  97. beego.Router("/api/4203", &HisApiController{}, "get:Get4203")
  98. beego.Router("/api/4205", &HisApiController{}, "get:Get4205")
  99. beego.Router("/api/4207", &HisApiController{}, "get:Get4207")
  100. beego.Router("/api/4208", &HisApiController{}, "get:Get4208")
  101. beego.Router("/api/4209", &HisApiController{}, "get:Get4209")
  102. beego.Router("/api/allopatry/get", &HisApiController{}, "get:GetAllopatry")
  103. //beego.Router("/api/comfirmallopatry/post", &HisApiController{}, "post:ComfirmAllopatry")
  104. beego.Router("/api/allopatry/refund", &HisApiController{}, "get:RefundAllopatry")
  105. beego.Router("/api/settle/query/batch", &HisApiController{}, "get:GetBatchSettleAccounts")
  106. beego.Router("/api/bl4201A", &HisApiController{}, "get:GetBL4201A")
  107. beego.Router("/api/bl4201A", &HisApiController{}, "get:GetBL4201A")
  108. beego.Router("/api/CFYLJG001", &HisApiController{}, "get:GetCFYLJG001")
  109. beego.Router("/api/CFYLJG002", &HisApiController{}, "get:GetCFYLJG002")
  110. beego.Router("/api/CFYLJG003", &HisApiController{}, "get:GetCFYLJG003")
  111. beego.Router("/api/CFYLJG004", &HisApiController{}, "get:GetCFYLJG004")
  112. beego.Router("/api/CFYLJG005", &HisApiController{}, "get:GetCFYLJG005")
  113. beego.Router("/api/CFYLJG006", &HisApiController{}, "get:GetCFYLJG006")
  114. beego.Router("/api/CFYLJG007", &HisApiController{}, "get:GetCFYLJG007")
  115. beego.Router("/api/CFYLJG008", &HisApiController{}, "get:GetCFYLJG008")
  116. //beego.Router("/api/CFYLJG009", &HisApiController{}, "get:GetCFYLJG009")
  117. //beego.Router("/api/2205", &HisApiController{}, "get:Get2205")
  118. beego.Router("/api/3260", &HisApiController{}, "get:Get3260")
  119. beego.Router("/api/3261", &HisApiController{}, "get:Get3261")
  120. beego.Router("/api/3262", &HisApiController{}, "get:Get3262")
  121. beego.Router("/api/3263", &HisApiController{}, "get:Get3263")
  122. beego.Router("/api/3264", &HisApiController{}, "get:Get3264")
  123. beego.Router("/api/3265", &HisApiController{}, "get:Get3265")
  124. beego.Router("/api/3266", &HisApiController{}, "get:Get3266")
  125. beego.Router("/api/3267", &HisApiController{}, "get:Get3267")
  126. beego.Router("/api/3268", &HisApiController{}, "get:Get3268")
  127. beego.Router("/api/3269", &HisApiController{}, "get:Get3269")
  128. beego.Router("/api/3270", &HisApiController{}, "get:Get3270")
  129. beego.Router("/api/3271", &HisApiController{}, "get:Get3271")
  130. beego.Router("/api/3272", &HisApiController{}, "get:Get3272")
  131. beego.Router("/api/3273", &HisApiController{}, "get:Get3273")
  132. beego.Router("/api/3274", &HisApiController{}, "get:Get3274")
  133. beego.Router("/api/3275", &HisApiController{}, "get:Get3275")
  134. beego.Router("/api/3276", &HisApiController{}, "get:Get3276")
  135. beego.Router("/api/3277", &HisApiController{}, "get:Get3277")
  136. beego.Router("/api/comfirm/upload", &HisApiController{}, "get:Get4102")
  137. beego.Router("/api/batch/check_drug", &HisApiController{}, "get:Drugscheck")
  138. beego.Router("/api/batch/check_good", &HisApiController{}, "get:Goodcheck")
  139. beego.Router("/api/batch/check_project", &HisApiController{}, "get:Projectcheck")
  140. beego.Router("/api/querydata", &HisApiController{}, "get:Getquerydata")
  141. //beego.Router("/api/5267", &HisApiController{}, "get:Get5267")
  142. //beego.Router("/api/1312a", &HisApiController{}, "get:Get1312a")
  143. //beego.Router("/api/cancledia/get", &HisApiController{}, "get:CancleDia")
  144. beego.Router("/api/4105", &HisApiController{}, "get:Get4105")
  145. beego.Router("/api/4104", &HisApiController{}, "get:Get4104")
  146. beego.Router("/api/2406", &HisApiController{}, "get:Get2406")
  147. beego.Router("/api/2503", &HisApiController{}, "get:Get2503")
  148. beego.Router("/api/1318", &HisApiController{}, "get:Get1318")
  149. beego.Router("/api/readelebyface", &HisApiController{}, "get:ReadEleFace")
  150. beego.Router("/api/settlelist/get/batch", &HisApiController{}, "get:GetbatchSettleList")
  151. //库盘和变更
  152. beego.Router("/api/pc_bg", &HisApiController{}, "get:FJ3501AND3502")
  153. //删除库盘和变更
  154. beego.Router("/api/delete_pc_bg", &HisApiController{}, "get:DeletePCandBG")
  155. beego.Router("/api/delete_xs_bg", &HisApiController{}, "get:DeleteXSandBG")
  156. //药品变更
  157. beego.Router("/api/changedrug", &HisApiController{}, "get:ChangeDrug")
  158. beego.Router("/api/3508", &HisApiController{}, "get:Get3508")
  159. beego.Router("/api/3509", &HisApiController{}, "get:Get3509")
  160. beego.Router("/api/3510", &HisApiController{}, "get:Get3510")
  161. beego.Router("/api/3511", &HisApiController{}, "get:Get3511")
  162. beego.Router("/api/3512", &HisApiController{}, "get:Get3512")
  163. beego.Router("/api/3513", &HisApiController{}, "get:Get3513")
  164. beego.Router("/api/35081", &HisApiController{}, "get:Get35081")
  165. beego.Router("/api/35082", &HisApiController{}, "get:Get35082")
  166. }
  167. func (c *HisApiController) Get3508() {
  168. admin_user_id, _ := c.GetInt64("admin_user_id")
  169. drug_id, _ := c.GetInt64("id")
  170. start_time := c.GetString("start_time")
  171. end_time := c.GetString("end_time")
  172. adminUser := c.GetAdminUserInfo()
  173. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  174. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  175. drug, _ := service.GetDrugByID(drug_id)
  176. var struct3508 models.Struct3508
  177. struct3508.OrgName = miConfig.OrgName
  178. struct3508.FixmedinsCode = miConfig.Code
  179. struct3508.AccessKey = miConfig.AccessKey
  180. struct3508.Opter = curRoles.UserName
  181. struct3508.RequestUrl = miConfig.Url
  182. struct3508.Url = miConfig.Url
  183. struct3508.AppId = miConfig.Cainfo
  184. struct3508.AppSecret = miConfig.AppSecret
  185. struct3508.Enckey = miConfig.EncKey
  186. struct3508.SignKey = miConfig.SignKey
  187. struct3508.SecretKey = miConfig.SecretKey
  188. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  189. struct3508.Begndate = start_time
  190. struct3508.Enddate = end_time
  191. result1, result2, _ := service.FJyb3508(struct3508)
  192. saveLog(result1, result2, "3508", "3508")
  193. var res models.Result3508
  194. var respJSON2 map[string]interface{}
  195. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  196. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  197. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  198. return
  199. }
  200. userJSONBytes2, _ := json.Marshal(respJSON2)
  201. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  202. utils.ErrorLog("解析失败:%v", err)
  203. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  204. return
  205. }
  206. if res.Infcode == -1 {
  207. c.ServeSuccessJSON(map[string]interface{}{
  208. "failed_code": -10,
  209. "msg": res.ErrMsg,
  210. })
  211. } else {
  212. c.ServeSuccessJSON(map[string]interface{}{
  213. "info": res.Output,
  214. })
  215. }
  216. }
  217. func (c *HisApiController) Get3509() {
  218. admin_user_id, _ := c.GetInt64("admin_user_id")
  219. drug_id, _ := c.GetInt64("id")
  220. start_time := c.GetString("start_time")
  221. end_time := c.GetString("end_time")
  222. adminUser := c.GetAdminUserInfo()
  223. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  224. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  225. drug, _ := service.GetDrugByID(drug_id)
  226. var struct3508 models.Struct3509
  227. struct3508.OrgName = miConfig.OrgName
  228. struct3508.FixmedinsCode = miConfig.Code
  229. struct3508.AccessKey = miConfig.AccessKey
  230. struct3508.Opter = curRoles.UserName
  231. struct3508.RequestUrl = miConfig.Url
  232. struct3508.Url = miConfig.Url
  233. struct3508.AppId = miConfig.Cainfo
  234. struct3508.AppSecret = miConfig.AppSecret
  235. struct3508.Enckey = miConfig.EncKey
  236. struct3508.SignKey = miConfig.SignKey
  237. struct3508.SecretKey = miConfig.SecretKey
  238. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  239. struct3508.Begndate = start_time
  240. struct3508.Enddate = end_time
  241. result1, result2, _ := service.FJyb3509(struct3508)
  242. saveLog(result1, result2, "3509", "3509")
  243. var res models.Result3509
  244. var respJSON2 map[string]interface{}
  245. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  246. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  247. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  248. return
  249. }
  250. userJSONBytes2, _ := json.Marshal(respJSON2)
  251. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  252. utils.ErrorLog("解析失败:%v", err)
  253. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  254. return
  255. }
  256. if res.Infcode == -1 {
  257. c.ServeSuccessJSON(map[string]interface{}{
  258. "failed_code": -10,
  259. "msg": res.ErrMsg,
  260. })
  261. } else {
  262. c.ServeSuccessJSON(map[string]interface{}{
  263. "info": res.Output,
  264. })
  265. }
  266. }
  267. func (c *HisApiController) Get3510() {
  268. admin_user_id, _ := c.GetInt64("admin_user_id")
  269. drug_id, _ := c.GetInt64("id")
  270. start_time := c.GetString("start_time")
  271. end_time := c.GetString("end_time")
  272. adminUser := c.GetAdminUserInfo()
  273. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  274. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  275. drug, _ := service.GetDrugByID(drug_id)
  276. var struct3508 models.Struct3510
  277. struct3508.FixmedinsCode = miConfig.Code
  278. struct3508.OrgName = miConfig.OrgName
  279. struct3508.AccessKey = miConfig.AccessKey
  280. struct3508.Opter = curRoles.UserName
  281. struct3508.RequestUrl = miConfig.Url
  282. struct3508.Url = miConfig.Url
  283. struct3508.AppId = miConfig.Cainfo
  284. struct3508.AppSecret = miConfig.AppSecret
  285. struct3508.Enckey = miConfig.EncKey
  286. struct3508.SignKey = miConfig.SignKey
  287. struct3508.SecretKey = miConfig.SecretKey
  288. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  289. struct3508.Begndate = start_time
  290. struct3508.Enddate = end_time
  291. result1, result2, _ := service.FJyb3510(struct3508)
  292. saveLog(result1, result2, "3510", "3510")
  293. var res models.Result3510
  294. var respJSON2 map[string]interface{}
  295. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  296. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  297. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  298. return
  299. }
  300. userJSONBytes2, _ := json.Marshal(respJSON2)
  301. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  302. utils.ErrorLog("解析失败:%v", err)
  303. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  304. return
  305. }
  306. if res.Infcode == -1 {
  307. c.ServeSuccessJSON(map[string]interface{}{
  308. "failed_code": -10,
  309. "msg": res.ErrMsg,
  310. })
  311. } else {
  312. c.ServeSuccessJSON(map[string]interface{}{
  313. "info": res.Output,
  314. })
  315. }
  316. }
  317. func (c *HisApiController) Get3511() {
  318. admin_user_id, _ := c.GetInt64("admin_user_id")
  319. drug_id, _ := c.GetInt64("id")
  320. start_time := c.GetString("start_time")
  321. end_time := c.GetString("end_time")
  322. adminUser := c.GetAdminUserInfo()
  323. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  324. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  325. drug, _ := service.GetDrugByID(drug_id)
  326. var struct3508 models.Struct3511
  327. struct3508.FixmedinsCode = miConfig.Code
  328. struct3508.OrgName = miConfig.OrgName
  329. struct3508.AccessKey = miConfig.AccessKey
  330. struct3508.Opter = curRoles.UserName
  331. struct3508.RequestUrl = miConfig.Url
  332. struct3508.Url = miConfig.Url
  333. struct3508.AppId = miConfig.Cainfo
  334. struct3508.AppSecret = miConfig.AppSecret
  335. struct3508.Enckey = miConfig.EncKey
  336. struct3508.SignKey = miConfig.SignKey
  337. struct3508.SecretKey = miConfig.SecretKey
  338. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  339. struct3508.Begndate = start_time
  340. struct3508.Enddate = end_time
  341. result1, result2, _ := service.FJyb3511(struct3508)
  342. saveLog(result1, result2, "3511", "3511")
  343. var res models.Result3511
  344. var respJSON2 map[string]interface{}
  345. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  346. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  347. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  348. return
  349. }
  350. userJSONBytes2, _ := json.Marshal(respJSON2)
  351. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  352. utils.ErrorLog("解析失败:%v", err)
  353. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  354. return
  355. }
  356. if res.Infcode == -1 {
  357. c.ServeSuccessJSON(map[string]interface{}{
  358. "failed_code": -10,
  359. "msg": res.ErrMsg,
  360. })
  361. } else {
  362. c.ServeSuccessJSON(map[string]interface{}{
  363. "info": res.Output,
  364. })
  365. }
  366. }
  367. func (c *HisApiController) Get3512() {
  368. admin_user_id, _ := c.GetInt64("admin_user_id")
  369. drug_id, _ := c.GetInt64("id")
  370. start_time := c.GetString("start_time")
  371. end_time := c.GetString("end_time")
  372. adminUser := c.GetAdminUserInfo()
  373. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  374. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  375. drug, _ := service.GetDrugByID(drug_id)
  376. var struct3508 models.Struct3512
  377. struct3508.FixmedinsCode = miConfig.Code
  378. struct3508.OrgName = miConfig.OrgName
  379. struct3508.AccessKey = miConfig.AccessKey
  380. struct3508.Opter = curRoles.UserName
  381. struct3508.RequestUrl = miConfig.Url
  382. struct3508.Url = miConfig.Url
  383. struct3508.AppId = miConfig.Cainfo
  384. struct3508.AppSecret = miConfig.AppSecret
  385. struct3508.Enckey = miConfig.EncKey
  386. struct3508.SignKey = miConfig.SignKey
  387. struct3508.SecretKey = miConfig.SecretKey
  388. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  389. struct3508.Begndate = start_time
  390. struct3508.Enddate = end_time
  391. result1, result2, _ := service.FJyb3512(struct3508)
  392. saveLog(result1, result2, "3512", "3512")
  393. var res models.Result3512
  394. var respJSON2 map[string]interface{}
  395. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  396. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  397. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  398. return
  399. }
  400. userJSONBytes2, _ := json.Marshal(respJSON2)
  401. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  402. utils.ErrorLog("解析失败:%v", err)
  403. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  404. return
  405. }
  406. if res.Infcode == -1 {
  407. c.ServeSuccessJSON(map[string]interface{}{
  408. "failed_code": -10,
  409. "msg": res.ErrMsg,
  410. })
  411. } else {
  412. c.ServeSuccessJSON(map[string]interface{}{
  413. "info": res.Output,
  414. })
  415. }
  416. }
  417. func (c *HisApiController) Get3513() {
  418. admin_user_id, _ := c.GetInt64("admin_user_id")
  419. drug_id, _ := c.GetInt64("id")
  420. start_time := c.GetString("start_time")
  421. end_time := c.GetString("end_time")
  422. adminUser := c.GetAdminUserInfo()
  423. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  424. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  425. drug, _ := service.GetDrugByID(drug_id)
  426. var struct3508 models.Struct3513
  427. struct3508.FixmedinsCode = miConfig.Code
  428. struct3508.OrgName = miConfig.OrgName
  429. struct3508.AccessKey = miConfig.AccessKey
  430. struct3508.Opter = curRoles.UserName
  431. struct3508.RequestUrl = miConfig.Url
  432. struct3508.Url = miConfig.Url
  433. struct3508.AppId = miConfig.Cainfo
  434. struct3508.AppSecret = miConfig.AppSecret
  435. struct3508.Enckey = miConfig.EncKey
  436. struct3508.SignKey = miConfig.SignKey
  437. struct3508.SecretKey = miConfig.SecretKey
  438. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  439. struct3508.Begndate = start_time
  440. struct3508.Enddate = end_time
  441. result1, result2, _ := service.FJyb3513(struct3508)
  442. saveLog(result1, result2, "3513", "3513")
  443. var res models.Result3513
  444. var respJSON2 map[string]interface{}
  445. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  446. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  447. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  448. return
  449. }
  450. userJSONBytes2, _ := json.Marshal(respJSON2)
  451. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  452. utils.ErrorLog("解析失败:%v", err)
  453. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  454. return
  455. }
  456. if res.Infcode == -1 {
  457. c.ServeSuccessJSON(map[string]interface{}{
  458. "failed_code": -10,
  459. "msg": res.ErrMsg,
  460. })
  461. } else {
  462. c.ServeSuccessJSON(map[string]interface{}{
  463. "info": res.Output,
  464. })
  465. }
  466. }
  467. func (c *HisApiController) Get35081() {
  468. admin_user_id, _ := c.GetInt64("admin_user_id")
  469. drug_id, _ := c.GetInt64("id")
  470. //start_time := c.GetString("start_time")
  471. //end_time := c.GetString("end_time")
  472. page, _ := c.GetInt("page")
  473. adminUser := c.GetAdminUserInfo()
  474. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  475. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  476. drug, _ := service.GetDrugByID(drug_id)
  477. var struct3508 models.Struct35081
  478. struct3508.FixmedinsCode = miConfig.Code
  479. struct3508.OrgName = miConfig.OrgName
  480. struct3508.AccessKey = miConfig.AccessKey
  481. struct3508.Opter = curRoles.UserName
  482. struct3508.RequestUrl = miConfig.Url
  483. struct3508.Url = miConfig.Url
  484. struct3508.AppId = miConfig.Cainfo
  485. struct3508.AppSecret = miConfig.AppSecret
  486. struct3508.Enckey = miConfig.EncKey
  487. struct3508.SignKey = miConfig.SignKey
  488. struct3508.SecretKey = miConfig.SecretKey
  489. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  490. struct3508.PageNum = page
  491. struct3508.PageSize = 10
  492. result1, result2, _ := service.FJyb35081(struct3508)
  493. saveLog(result1, result2, "35081", "35081")
  494. var res models.Result35081
  495. var respJSON2 map[string]interface{}
  496. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  497. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  498. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  499. return
  500. }
  501. userJSONBytes2, _ := json.Marshal(respJSON2)
  502. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  503. utils.ErrorLog("解析失败:%v", err)
  504. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  505. return
  506. }
  507. if res.Infcode == -1 {
  508. c.ServeSuccessJSON(map[string]interface{}{
  509. "failed_code": -10,
  510. "msg": res.ErrMsg,
  511. })
  512. } else {
  513. c.ServeSuccessJSON(map[string]interface{}{
  514. "info": res.Output,
  515. })
  516. }
  517. }
  518. func (c *HisApiController) Get35082() {
  519. admin_user_id, _ := c.GetInt64("admin_user_id")
  520. drug_id, _ := c.GetInt64("id")
  521. //start_time := c.GetString("start_time")
  522. //end_time := c.GetString("end_time")
  523. page, _ := c.GetInt("page")
  524. adminUser := c.GetAdminUserInfo()
  525. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  526. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  527. drug, _ := service.GetDrugByID(drug_id)
  528. var struct3508 models.Struct35082
  529. struct3508.FixmedinsCode = miConfig.Code
  530. struct3508.OrgName = miConfig.OrgName
  531. struct3508.AccessKey = miConfig.AccessKey
  532. struct3508.Opter = curRoles.UserName
  533. struct3508.RequestUrl = miConfig.Url
  534. struct3508.Url = miConfig.Url
  535. struct3508.AppId = miConfig.Cainfo
  536. struct3508.AppSecret = miConfig.AppSecret
  537. struct3508.Enckey = miConfig.EncKey
  538. struct3508.SignKey = miConfig.SignKey
  539. struct3508.SecretKey = miConfig.SecretKey
  540. struct3508.MedListCodg = drug.MedicalInsuranceNumber
  541. struct3508.PageNum = page
  542. struct3508.PageSize = 10
  543. result1, result2, _ := service.FJyb35082(struct3508)
  544. saveLog(result1, result2, "35082", "35082")
  545. var res models.Result35082
  546. var respJSON2 map[string]interface{}
  547. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  548. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  549. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  550. return
  551. }
  552. userJSONBytes2, _ := json.Marshal(respJSON2)
  553. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  554. utils.ErrorLog("解析失败:%v", err)
  555. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  556. return
  557. }
  558. if res.Infcode == -1 {
  559. c.ServeSuccessJSON(map[string]interface{}{
  560. "failed_code": -10,
  561. "msg": res.ErrMsg,
  562. })
  563. } else {
  564. c.ServeSuccessJSON(map[string]interface{}{
  565. "info": res.Output,
  566. })
  567. }
  568. }
  569. func (c *HisApiController) FJ3501AND3502() {
  570. ids := c.GetString("ids")
  571. admin_user_id, _ := c.GetInt64("admin_user_id")
  572. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  573. id_arr := strings.Split(ids, ",")
  574. drugs, _ := service.GetNewDrugWarehouseInfo(id_arr)
  575. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  576. //库盘
  577. var errs []string
  578. for _, drug := range drugs {
  579. if drug.IsPc == 0 && drug.IsBg == 0 {
  580. var res2 ResultSix
  581. var res3 ResultSix
  582. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(drug.ID, 10) + "-" + "3501"
  583. var struct3501 models.Struct3501
  584. struct3501.OrgName = miConfig.OrgName
  585. struct3501.AccessKey = miConfig.AccessKey
  586. struct3501.Opter = roles.UserName
  587. struct3501.RequestUrl = miConfig.Url
  588. struct3501.Url = miConfig.Url
  589. struct3501.AppId = miConfig.Cainfo
  590. struct3501.AppSecret = miConfig.AppSecret
  591. struct3501.Enckey = miConfig.EncKey
  592. struct3501.SignKey = miConfig.SignKey
  593. struct3501.SecretKey = miConfig.SecretKey
  594. struct3501.MedListCodg = drug.BaseDrugLib.MedicalInsuranceNumber
  595. struct3501.FixmedinsHilistId = miConfig.Code
  596. struct3501.FixmedinsHilistName = miConfig.OrgName
  597. struct3501.RxFlag = "0"
  598. struct3501.Invdate = time.Unix(drug.Ctime, 0).Format("2006-01-02")
  599. struct3501.ManuDate = time.Unix(drug.ProductDate, 0).Format("2006-01-02")
  600. struct3501.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  601. struct3501.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  602. struct3501.InvCnt = strconv.FormatInt(drug.StockMaxNumber, 10)
  603. struct3501.ExpyEnd = time.Unix(drug.ExpiryDate, 0).Format("2006-01-02")
  604. struct3501.FixmedinsBchno = number
  605. memo := make(map[string]interface{})
  606. memo["pric"] = drug.Price
  607. bytesData, _ := json.Marshal(memo)
  608. struct3501.Memo = string(bytesData)
  609. result1, result2, _ := service.FJyb3501(struct3501)
  610. saveLog(result1, result2, "3501", "3501")
  611. //saveLog(result, requestLog, "2201", "挂号")
  612. var respJSON2 map[string]interface{}
  613. if err := json.Unmarshal([]byte(string(result1)), &respJSON2); err != nil {
  614. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  615. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  616. return
  617. }
  618. userJSONBytes2, _ := json.Marshal(respJSON2)
  619. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  620. utils.ErrorLog("解析失败:%v", err)
  621. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  622. return
  623. }
  624. if res2.Infcode != -1 {
  625. drug.IsPc = 1
  626. drug.Bchno = number
  627. drug.PcDate = time.Now().Format("2006-01-02")
  628. err := service.SaveW(drug)
  629. if err == nil {
  630. var struct3502 models.Struct3502
  631. struct3502.MedListCodg = drug.BaseDrugLib.MedicalInsuranceNumber
  632. struct3502.FixmedinsHilistId = miConfig.Code
  633. struct3502.FixmedinsHilistName = miConfig.OrgName
  634. struct3502.FixmedinsCode = miConfig.Code
  635. struct3502.RxFlag = "0"
  636. struct3502.InvChgTime = time.Now().Format("2006-01-02")
  637. struct3502.OrgName = miConfig.OrgName
  638. struct3502.Opter = roles.UserName
  639. struct3502.AccessKey = miConfig.AccessKey
  640. struct3502.RequestUrl = miConfig.Url
  641. struct3502.SecretKey = miConfig.SecretKey
  642. struct3502.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  643. struct3502.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  644. struct3502.Url = miConfig.Url
  645. struct3502.AppId = miConfig.Cainfo
  646. struct3502.AppSecret = miConfig.AppSecret
  647. struct3502.Enckey = miConfig.EncKey
  648. struct3502.SignKey = miConfig.SignKey
  649. struct3502.SecretKey = miConfig.SecretKey
  650. struct3502.Memo = ""
  651. struct3502.InvChgType = "108"
  652. struct3502.FixmedinsBchno = drug.Bchno
  653. struct3502.Cnt = strconv.FormatInt(drug.WarehousingCount, 10)
  654. struct3502.Pric = fmt.Sprintf("%.2f", drug.BaseDrugLib.RetailPrice)
  655. result11, result22, _ := service.FJyb3502(struct3502)
  656. saveLog(result11, result22, "3502", "3502")
  657. var respJSON3 map[string]interface{}
  658. if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  659. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  660. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  661. return
  662. }
  663. userJSONBytes3, _ := json.Marshal(respJSON3)
  664. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  665. utils.ErrorLog("解析失败:%v", err)
  666. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  667. return
  668. }
  669. if res3.Infcode == -1 {
  670. errs = append(errs, "变更"+drug.BaseDrugLib.DrugName+",出错:"+res3.ErrMsg)
  671. c.ServeSuccessJSON(map[string]interface{}{
  672. "failed_code": -10,
  673. "msg": res3.ErrMsg,
  674. })
  675. } else {
  676. drug.IsBg = 1
  677. service.SaveW(drug)
  678. }
  679. }
  680. } else {
  681. errs = append(errs, "盘存"+drug.BaseDrugLib.DrugName+",出错:"+res2.ErrMsg)
  682. }
  683. }
  684. //变更
  685. if drug.IsPc == 1 && drug.IsBg == 0 {
  686. var res3 ResultSix
  687. var struct3502 models.Struct3502
  688. struct3502.MedListCodg = drug.BaseDrugLib.MedicalInsuranceNumber
  689. struct3502.FixmedinsHilistId = miConfig.Code
  690. struct3502.FixmedinsHilistName = miConfig.OrgName
  691. struct3502.FixmedinsCode = miConfig.Code
  692. struct3502.Opter = roles.UserName
  693. struct3502.RxFlag = "0"
  694. struct3502.InvChgTime = time.Now().Format("2006-01-02")
  695. struct3502.OrgName = miConfig.OrgName
  696. struct3502.AccessKey = miConfig.AccessKey
  697. struct3502.RequestUrl = miConfig.Url
  698. struct3502.SecretKey = miConfig.SecretKey
  699. struct3502.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  700. struct3502.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  701. struct3502.InvChgType = "108"
  702. struct3502.Url = miConfig.Url
  703. struct3502.AppId = miConfig.Cainfo
  704. struct3502.AppSecret = miConfig.AppSecret
  705. struct3502.Enckey = miConfig.EncKey
  706. struct3502.SignKey = miConfig.SignKey
  707. struct3502.SecretKey = miConfig.SecretKey
  708. struct3502.FixmedinsBchno = drug.Bchno
  709. struct3502.Cnt = strconv.FormatInt(drug.WarehousingCount, 10)
  710. struct3502.Pric = fmt.Sprintf("%.2f", drug.BaseDrugLib.RetailPrice)
  711. result1, result2, _ := service.FJyb3502(struct3502)
  712. saveLog(result1, result2, "3502", "3502")
  713. var respJSON3 map[string]interface{}
  714. if err := json.Unmarshal([]byte(string(result1)), &respJSON3); err != nil {
  715. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  716. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  717. return
  718. }
  719. userJSONBytes3, _ := json.Marshal(respJSON3)
  720. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  721. utils.ErrorLog("解析失败:%v", err)
  722. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  723. return
  724. }
  725. if res3.Infcode == -1 {
  726. errs = append(errs, "变更"+drug.BaseDrugLib.DrugName+",出错:"+res3.ErrMsg)
  727. } else {
  728. drug.IsBg = 1
  729. //drug.Bchno = number
  730. //drug.PcDate = time.Now().Format("2006-01-02")
  731. service.SaveW(drug)
  732. }
  733. }
  734. }
  735. if len(errs) == 0 {
  736. c.ServeSuccessJSON(map[string]interface{}{
  737. "msg": "盘存变更成功",
  738. })
  739. } else {
  740. c.ServeSuccessJSON(map[string]interface{}{
  741. "failed_code": -10,
  742. "msg": errs,
  743. })
  744. }
  745. }
  746. func (c *HisApiController) DeletePCandBG() {
  747. ids := c.GetString("ids")
  748. id_arr := strings.Split(ids, ",")
  749. admin_user_id, _ := c.GetInt64("admin_user_id")
  750. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  751. drugs, _ := service.GetNewDrugWarehouseInfo(id_arr)
  752. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  753. var err []string
  754. for _, item := range drugs {
  755. if item.IsPc == 1 && item.IsBg == 1 {
  756. var res FJ3507Result
  757. var res2 FJ3507Result
  758. var struct3507 models.Struct3507
  759. struct3507.FixmedinsBchno = item.Bchno
  760. struct3507.InvDataType = "1"
  761. struct3507.Opter = roles.UserName
  762. struct3507.OrgName = miConfig.OrgName
  763. struct3507.AccessKey = miConfig.AccessKey
  764. struct3507.RequestUrl = miConfig.Url
  765. struct3507.FixmedinsCode = miConfig.Code
  766. struct3507.SecretKey = miConfig.SecretKey
  767. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  768. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  769. struct3507.Url = miConfig.Url
  770. struct3507.AppId = miConfig.Cainfo
  771. struct3507.AppSecret = miConfig.AppSecret
  772. struct3507.Enckey = miConfig.EncKey
  773. struct3507.SignKey = miConfig.SignKey
  774. struct3507.SecretKey = miConfig.SecretKey
  775. result, result1, _ := service.FJyb3507(struct3507)
  776. saveLog(result, result1, "3507", "3507")
  777. var respJSON2 map[string]interface{}
  778. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  779. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  780. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  781. return
  782. }
  783. userJSONBytes2, _ := json.Marshal(respJSON2)
  784. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  785. utils.ErrorLog("解析失败:%v", err)
  786. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  787. return
  788. }
  789. if res.Infcode != -1 {
  790. item.IsPc = 0
  791. err2 := service.SaveW(item)
  792. if err2 == nil {
  793. var struct3507_2 models.Struct3507
  794. struct3507_2.OrgName = miConfig.OrgName
  795. struct3507_2.AccessKey = miConfig.AccessKey
  796. struct3507_2.RequestUrl = miConfig.Url
  797. struct3507_2.Opter = roles.UserName
  798. struct3507_2.FixmedinsCode = miConfig.Code
  799. struct3507_2.SecretKey = miConfig.SecretKey
  800. struct3507_2.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  801. struct3507_2.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  802. struct3507_2.Url = miConfig.Url
  803. struct3507_2.AppId = miConfig.Cainfo
  804. struct3507_2.AppSecret = miConfig.AppSecret
  805. struct3507_2.Enckey = miConfig.EncKey
  806. struct3507_2.SignKey = miConfig.SignKey
  807. struct3507_2.SecretKey = miConfig.SecretKey
  808. struct3507_2.FixmedinsBchno = item.Bchno
  809. struct3507_2.InvDataType = "2"
  810. result11, result22, _ := service.FJyb3507(struct3507_2)
  811. saveLog(result11, result22, "3507", "3507")
  812. var respJSON3 map[string]interface{}
  813. if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  814. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  815. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  816. return
  817. }
  818. userJSONBytes3, _ := json.Marshal(respJSON3)
  819. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  820. utils.ErrorLog("解析失败:%v", err)
  821. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  822. return
  823. }
  824. if res2.Infcode != -1 {
  825. item.IsBg = 0
  826. item.Bchno = ""
  827. item.PcDate = ""
  828. service.SaveW(item)
  829. } else {
  830. err = append(err, "删除"+item.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  831. }
  832. }
  833. } else {
  834. err = append(err, "删除"+item.BaseDrugLib.DrugName+"盘存失败,失败原因:"+res.ErrMsg)
  835. }
  836. }
  837. if item.IsPc == 1 && item.IsBg == 0 {
  838. var res FJ3507Result
  839. var struct3507 models.Struct3507
  840. struct3507.FixmedinsBchno = item.Bchno
  841. struct3507.InvDataType = "2"
  842. struct3507.Opter = roles.UserName
  843. struct3507.FixmedinsCode = miConfig.Code
  844. struct3507.OrgName = miConfig.OrgName
  845. struct3507.AccessKey = miConfig.AccessKey
  846. struct3507.RequestUrl = miConfig.Url
  847. struct3507.SecretKey = miConfig.SecretKey
  848. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  849. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  850. struct3507.Url = miConfig.Url
  851. struct3507.AppId = miConfig.Cainfo
  852. struct3507.AppSecret = miConfig.AppSecret
  853. struct3507.Enckey = miConfig.EncKey
  854. struct3507.SignKey = miConfig.SignKey
  855. struct3507.SecretKey = miConfig.SecretKey
  856. result, result1, _ := service.FJyb3507(struct3507)
  857. saveLog(result, result1, "3507", "3507")
  858. var respJSON3 map[string]interface{}
  859. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  860. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  861. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  862. return
  863. }
  864. userJSONBytes3, _ := json.Marshal(respJSON3)
  865. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  866. utils.ErrorLog("解析失败:%v", err)
  867. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  868. return
  869. }
  870. if res.Infcode != -1 {
  871. item.IsBg = 0
  872. item.Bchno = ""
  873. item.PcDate = ""
  874. service.SaveW(item)
  875. } else {
  876. err = append(err, "删除"+item.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  877. }
  878. }
  879. }
  880. if len(err) == 0 {
  881. c.ServeSuccessJSON(map[string]interface{}{
  882. "msg": "删除盘存变更成功",
  883. })
  884. } else {
  885. c.ServeSuccessJSON(map[string]interface{}{
  886. "failed_code": -10,
  887. "msg": err,
  888. })
  889. }
  890. }
  891. func (c *HisApiController) DeleteXSandBG() {
  892. ids := c.GetString("ids")
  893. id_arr := strings.Split(ids, ",")
  894. admin_user_id, _ := c.GetInt64("admin_user_id")
  895. flows, _ := service.GetNewDrugFlowInfo(id_arr)
  896. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  897. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  898. var err []string
  899. for _, item := range flows {
  900. if item.IsSale == 1 && item.IsChange == 1 {
  901. var res FJ3507Result
  902. var res2 FJ3507Result
  903. var struct3507 models.Struct3507
  904. struct3507.FixmedinsBchno = item.Bchno
  905. struct3507.InvDataType = "4"
  906. struct3507.Opter = roles.UserName
  907. struct3507.OrgName = miConfig.OrgName
  908. struct3507.AccessKey = miConfig.AccessKey
  909. struct3507.RequestUrl = miConfig.Url
  910. struct3507.FixmedinsCode = miConfig.Code
  911. struct3507.SecretKey = miConfig.SecretKey
  912. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  913. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  914. struct3507.Url = miConfig.Url
  915. struct3507.AppId = miConfig.Cainfo
  916. struct3507.AppSecret = miConfig.AppSecret
  917. struct3507.Enckey = miConfig.EncKey
  918. struct3507.SignKey = miConfig.SignKey
  919. struct3507.SecretKey = miConfig.SecretKey
  920. result, result1, _ := service.FJyb3507(struct3507)
  921. saveLog(result, result1, "3507", "3507")
  922. var respJSON2 map[string]interface{}
  923. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  924. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  925. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  926. return
  927. }
  928. userJSONBytes2, _ := json.Marshal(respJSON2)
  929. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  930. utils.ErrorLog("解析失败:%v", err)
  931. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  932. return
  933. }
  934. if res.Infcode != -1 {
  935. item.IsSale = 0
  936. item.SaleDate = ""
  937. err2 := service.SaveDF(item)
  938. if err2 == nil {
  939. var struct3507_2 models.Struct3507
  940. struct3507_2.OrgName = miConfig.OrgName
  941. struct3507_2.AccessKey = miConfig.AccessKey
  942. struct3507_2.RequestUrl = miConfig.Url
  943. struct3507_2.Opter = roles.UserName
  944. struct3507_2.FixmedinsCode = miConfig.Code
  945. struct3507_2.SecretKey = miConfig.SecretKey
  946. struct3507_2.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  947. struct3507_2.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  948. struct3507_2.Url = miConfig.Url
  949. struct3507_2.AppId = miConfig.Cainfo
  950. struct3507_2.AppSecret = miConfig.AppSecret
  951. struct3507_2.Enckey = miConfig.EncKey
  952. struct3507_2.SignKey = miConfig.SignKey
  953. struct3507_2.SecretKey = miConfig.SecretKey
  954. struct3507_2.FixmedinsBchno = item.Bchno
  955. struct3507_2.InvDataType = "2"
  956. result11, result22, _ := service.FJyb3507(struct3507_2)
  957. saveLog(result11, result22, "3507", "3507")
  958. var respJSON3 map[string]interface{}
  959. if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  960. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  961. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  962. return
  963. }
  964. userJSONBytes3, _ := json.Marshal(respJSON3)
  965. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  966. utils.ErrorLog("解析失败:%v", err)
  967. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  968. return
  969. }
  970. if res2.Infcode != -1 {
  971. item.IsChange = 0
  972. item.Bchno = ""
  973. service.SaveDF2(item)
  974. } else {
  975. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  976. }
  977. }
  978. } else {
  979. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"盘存失败,失败原因:"+res.ErrMsg)
  980. }
  981. }
  982. if item.IsSale == 2 && item.IsChange == 1 {
  983. var res FJ3507Result
  984. var res2 FJ3507Result
  985. var struct3507 models.Struct3507
  986. struct3507.FixmedinsBchno = item.Bchno
  987. struct3507.InvDataType = "4"
  988. struct3507.Opter = roles.UserName
  989. struct3507.OrgName = miConfig.OrgName
  990. struct3507.AccessKey = miConfig.AccessKey
  991. struct3507.RequestUrl = miConfig.Url
  992. struct3507.FixmedinsCode = miConfig.Code
  993. struct3507.SecretKey = miConfig.SecretKey
  994. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  995. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  996. struct3507.Url = miConfig.Url
  997. struct3507.AppId = miConfig.Cainfo
  998. struct3507.AppSecret = miConfig.AppSecret
  999. struct3507.Enckey = miConfig.EncKey
  1000. struct3507.SignKey = miConfig.SignKey
  1001. struct3507.SecretKey = miConfig.SecretKey
  1002. result, result1, _ := service.FJyb3507(struct3507)
  1003. saveLog(result, result1, "3507", "3507")
  1004. var respJSON2 map[string]interface{}
  1005. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1006. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1007. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1008. return
  1009. }
  1010. userJSONBytes2, _ := json.Marshal(respJSON2)
  1011. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  1012. utils.ErrorLog("解析失败:%v", err)
  1013. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1014. return
  1015. }
  1016. if res.Infcode != -1 {
  1017. item.IsSale = 0
  1018. item.SaleDate = ""
  1019. err2 := service.SaveDF(item)
  1020. if err2 == nil {
  1021. var struct3507_2 models.Struct3507
  1022. struct3507_2.OrgName = miConfig.OrgName
  1023. struct3507_2.AccessKey = miConfig.AccessKey
  1024. struct3507_2.RequestUrl = miConfig.Url
  1025. struct3507_2.Opter = roles.UserName
  1026. struct3507_2.FixmedinsCode = miConfig.Code
  1027. struct3507_2.SecretKey = miConfig.SecretKey
  1028. struct3507_2.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1029. struct3507_2.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1030. struct3507_2.Url = miConfig.Url
  1031. struct3507_2.AppId = miConfig.Cainfo
  1032. struct3507_2.AppSecret = miConfig.AppSecret
  1033. struct3507_2.Enckey = miConfig.EncKey
  1034. struct3507_2.SignKey = miConfig.SignKey
  1035. struct3507_2.SecretKey = miConfig.SecretKey
  1036. struct3507_2.FixmedinsBchno = item.Bchno
  1037. struct3507_2.InvDataType = "2"
  1038. result11, result22, _ := service.FJyb3507(struct3507_2)
  1039. saveLog(result11, result22, "3507", "3507")
  1040. var respJSON3 map[string]interface{}
  1041. if err := json.Unmarshal([]byte(string(result11)), &respJSON3); err != nil {
  1042. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1043. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1044. return
  1045. }
  1046. userJSONBytes3, _ := json.Marshal(respJSON3)
  1047. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  1048. utils.ErrorLog("解析失败:%v", err)
  1049. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1050. return
  1051. }
  1052. if res2.Infcode != -1 {
  1053. item.IsChange = 0
  1054. item.Bchno = ""
  1055. service.SaveDF2(item)
  1056. } else {
  1057. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  1058. }
  1059. }
  1060. } else {
  1061. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"盘存失败,失败原因:"+res.ErrMsg)
  1062. }
  1063. }
  1064. if item.IsSale == 1 && item.IsChange == 0 {
  1065. var res FJ3507Result
  1066. var struct3507 models.Struct3507
  1067. struct3507.FixmedinsBchno = item.Bchno
  1068. struct3507.InvDataType = "4"
  1069. struct3507.Opter = roles.UserName
  1070. struct3507.FixmedinsCode = miConfig.Code
  1071. struct3507.OrgName = miConfig.OrgName
  1072. struct3507.AccessKey = miConfig.AccessKey
  1073. struct3507.RequestUrl = miConfig.Url
  1074. struct3507.SecretKey = miConfig.SecretKey
  1075. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1076. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1077. struct3507.Url = miConfig.Url
  1078. struct3507.AppId = miConfig.Cainfo
  1079. struct3507.AppSecret = miConfig.AppSecret
  1080. struct3507.Enckey = miConfig.EncKey
  1081. struct3507.SignKey = miConfig.SignKey
  1082. struct3507.SecretKey = miConfig.SecretKey
  1083. result, result1, _ := service.FJyb3507(struct3507)
  1084. saveLog(result, result1, "3507", "3507")
  1085. var respJSON3 map[string]interface{}
  1086. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  1087. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1088. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1089. return
  1090. }
  1091. userJSONBytes3, _ := json.Marshal(respJSON3)
  1092. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  1093. utils.ErrorLog("解析失败:%v", err)
  1094. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1095. return
  1096. }
  1097. if res.Infcode != -1 {
  1098. item.IsSale = 0
  1099. item.SaleDate = ""
  1100. service.SaveDF(item)
  1101. } else {
  1102. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  1103. }
  1104. }
  1105. if item.IsSale == 2 && item.IsChange == 0 {
  1106. var res FJ3507Result
  1107. var struct3507 models.Struct3507
  1108. struct3507.FixmedinsBchno = item.Bchno
  1109. struct3507.InvDataType = "4"
  1110. struct3507.Opter = roles.UserName
  1111. struct3507.FixmedinsCode = miConfig.Code
  1112. struct3507.OrgName = miConfig.OrgName
  1113. struct3507.AccessKey = miConfig.AccessKey
  1114. struct3507.RequestUrl = miConfig.Url
  1115. struct3507.SecretKey = miConfig.SecretKey
  1116. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1117. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1118. struct3507.Url = miConfig.Url
  1119. struct3507.AppId = miConfig.Cainfo
  1120. struct3507.AppSecret = miConfig.AppSecret
  1121. struct3507.Enckey = miConfig.EncKey
  1122. struct3507.SignKey = miConfig.SignKey
  1123. struct3507.SecretKey = miConfig.SecretKey
  1124. result, result1, _ := service.FJyb3507(struct3507)
  1125. saveLog(result, result1, "3507", "3507")
  1126. var respJSON3 map[string]interface{}
  1127. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  1128. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1129. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1130. return
  1131. }
  1132. userJSONBytes3, _ := json.Marshal(respJSON3)
  1133. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  1134. utils.ErrorLog("解析失败:%v", err)
  1135. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1136. return
  1137. }
  1138. if res.Infcode != -1 {
  1139. item.IsSale = 0
  1140. item.SaleDate = ""
  1141. service.SaveDF(item)
  1142. } else {
  1143. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  1144. }
  1145. }
  1146. if item.IsSale == 0 && item.IsChange == 1 {
  1147. var res FJ3507Result
  1148. var struct3507 models.Struct3507
  1149. struct3507.FixmedinsBchno = item.Bchno
  1150. struct3507.InvDataType = "2"
  1151. struct3507.Opter = roles.UserName
  1152. struct3507.FixmedinsCode = miConfig.Code
  1153. struct3507.OrgName = miConfig.OrgName
  1154. struct3507.AccessKey = miConfig.AccessKey
  1155. struct3507.RequestUrl = miConfig.Url
  1156. struct3507.SecretKey = miConfig.SecretKey
  1157. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1158. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1159. struct3507.Url = miConfig.Url
  1160. struct3507.AppId = miConfig.Cainfo
  1161. struct3507.AppSecret = miConfig.AppSecret
  1162. struct3507.Enckey = miConfig.EncKey
  1163. struct3507.SignKey = miConfig.SignKey
  1164. struct3507.SecretKey = miConfig.SecretKey
  1165. result, result1, _ := service.FJyb3507(struct3507)
  1166. saveLog(result, result1, "3507", "3507")
  1167. var respJSON3 map[string]interface{}
  1168. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  1169. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1170. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1171. return
  1172. }
  1173. userJSONBytes3, _ := json.Marshal(respJSON3)
  1174. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  1175. utils.ErrorLog("解析失败:%v", err)
  1176. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1177. return
  1178. }
  1179. if res.Infcode != -1 {
  1180. item.IsChange = 0
  1181. item.Bchno = ""
  1182. service.SaveDF2(item)
  1183. } else {
  1184. err = append(err, "删除"+item.HisDoctorAdviceInfo.BaseDrugLib.DrugName+"变更失败,失败原因:"+res.ErrMsg)
  1185. }
  1186. }
  1187. }
  1188. if len(err) == 0 {
  1189. c.ServeSuccessJSON(map[string]interface{}{
  1190. "msg": "删除销售变更成功",
  1191. })
  1192. } else {
  1193. c.ServeSuccessJSON(map[string]interface{}{
  1194. "failed_code": -10,
  1195. "msg": err,
  1196. })
  1197. }
  1198. }
  1199. func (c *HisApiController) ChangeDrug() {
  1200. ids := c.GetString("ids")
  1201. id_arr := strings.Split(ids, ",")
  1202. flows, _ := service.GetNewDrugFlowInfo(id_arr)
  1203. admin_user_id, _ := c.GetInt64("admin_user_id")
  1204. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1205. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1206. var err []string
  1207. for _, item := range flows {
  1208. var res3 ResultSix
  1209. if item.ConsumableType == 3 { //3为自动出库 7为自动退库
  1210. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(item.ID, 10) + "-" + "3507"
  1211. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  1212. if prescription.OrderStatus == 2 {
  1213. //已经结算
  1214. //判断是否已经销售
  1215. if item.IsSale == 1 { //是否已经销售,1是 0否
  1216. //是否已经变更 1是 0否
  1217. if item.IsChange == 0 { //没变更,进行变更操作
  1218. result, result2 := ChangeStock(item.Count, item, miConfig, "107", roles)
  1219. saveLog(result, result2, "3502", "自动出库,已经销售,未变更3502")
  1220. var respJSON3 map[string]interface{}
  1221. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  1222. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1223. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1224. return
  1225. }
  1226. userJSONBytes3, _ := json.Marshal(respJSON3)
  1227. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  1228. utils.ErrorLog("解析失败:%v", err)
  1229. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1230. return
  1231. }
  1232. if res3.Infcode != -1 {
  1233. item.IsChange = 1
  1234. item.Bchno = item.NewDrugWarehouseInfo.Bchno
  1235. service.SaveDF2(item)
  1236. } else {
  1237. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  1238. }
  1239. }
  1240. } else { //没销售,
  1241. var res FJ3507Result
  1242. //进行商品销售接口
  1243. result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles)
  1244. saveLog(result3, result4, "3505", "自动出库,未销售进行销售行为,3505")
  1245. var respJSON3 map[string]interface{}
  1246. if err := json.Unmarshal([]byte(string(result3)), &respJSON3); err != nil {
  1247. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1248. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1249. return
  1250. }
  1251. userJSONBytes3, _ := json.Marshal(respJSON3)
  1252. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  1253. utils.ErrorLog("解析失败:%v", err)
  1254. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1255. return
  1256. }
  1257. if res.Infcode != -1 {
  1258. item.IsSale = 1
  1259. item.SaleDate = time.Now().Format("2006-01-02")
  1260. err5 := service.SaveDF(item)
  1261. if err5 == nil {
  1262. if item.IsChange == 0 { //没变更,进行变更操作
  1263. result, result2 := ChangeStock(item.Count, item, miConfig, "107", roles)
  1264. saveLog(result, result2, "3502", "自动出库,没销售,未变更3502")
  1265. var respJSON3 map[string]interface{}
  1266. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  1267. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1268. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1269. return
  1270. }
  1271. userJSONBytes3, _ := json.Marshal(respJSON3)
  1272. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  1273. utils.ErrorLog("解析失败:%v", err)
  1274. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1275. return
  1276. }
  1277. if res3.Infcode != -1 {
  1278. item.IsChange = 1
  1279. item.Bchno = item.NewDrugWarehouseInfo.Bchno
  1280. service.SaveDF2(item)
  1281. } else {
  1282. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  1283. }
  1284. }
  1285. }
  1286. } else {
  1287. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售失败:"+res.ErrMsg)
  1288. }
  1289. }
  1290. } else { //还没结算
  1291. if item.IsChange == 0 { //没变更,进行变更操作
  1292. result, result2 := ChangeStock(item.Count, item, miConfig, "107", roles)
  1293. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  1294. var respJSON3 map[string]interface{}
  1295. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  1296. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1297. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1298. return
  1299. }
  1300. userJSONBytes3, _ := json.Marshal(respJSON3)
  1301. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  1302. utils.ErrorLog("解析失败:%v", err)
  1303. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1304. return
  1305. }
  1306. if res3.Infcode != -1 {
  1307. item.IsChange = 1
  1308. item.Bchno = item.NewDrugWarehouseInfo.Bchno
  1309. service.SaveDF2(item)
  1310. } else {
  1311. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  1312. }
  1313. }
  1314. }
  1315. } else if item.ConsumableType == 7 {
  1316. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  1317. order := service.GetHisOrderByNumber(prescription.BatchNumber)
  1318. if order.OrderStatus == 2 || order.OrderStatus == 1 { //已经结算
  1319. //判断是否已经销售
  1320. if item.IsSale == 2 { //是否已经销售,1是 0否
  1321. //是否已经变更 1是 0否
  1322. if item.IsChange == 0 { //没变更,进行变更操作
  1323. result, result2 := ChangeStock(item.Count, item, miConfig, "107", roles)
  1324. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  1325. var respJSON3 map[string]interface{}
  1326. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  1327. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1328. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1329. return
  1330. }
  1331. userJSONBytes3, _ := json.Marshal(respJSON3)
  1332. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  1333. utils.ErrorLog("解析失败:%v", err)
  1334. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1335. return
  1336. }
  1337. if res3.Infcode != -1 {
  1338. item.IsChange = 1
  1339. item.Bchno = item.NewDrugWarehouseInfo.Bchno
  1340. service.SaveDF2(item)
  1341. } else {
  1342. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  1343. }
  1344. }
  1345. } else { //没销售,
  1346. //进行商品销售退货接口
  1347. result111, result222 := CancleSaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles)
  1348. saveLog(result111, result222, "3506", "销售退货")
  1349. var res7 FJ3507Result
  1350. //进行商品销售接口
  1351. result3, result4 := SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item, miConfig, "", roles)
  1352. saveLog(result3, result4, "3506", "自动退库,未销售退货进行销售退货行为,3505")
  1353. var respJSON3 map[string]interface{}
  1354. if err := json.Unmarshal([]byte(string(result111)), &respJSON3); err != nil {
  1355. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1356. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1357. return
  1358. }
  1359. userJSONBytes3, _ := json.Marshal(respJSON3)
  1360. if err := json.Unmarshal(userJSONBytes3, &res7); err != nil {
  1361. utils.ErrorLog("解析失败:%v", err)
  1362. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1363. return
  1364. }
  1365. if res7.Infcode != -1 {
  1366. item.IsSale = 2
  1367. item.SaleDate = item.SaleDate
  1368. service.SaveDF(item)
  1369. if item.IsChange == 0 { //没变更,进行变更操作
  1370. result, result2 := ChangeStock(item.Count, item, miConfig, "107", roles)
  1371. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  1372. var respJSON3 map[string]interface{}
  1373. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  1374. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1375. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1376. return
  1377. }
  1378. userJSONBytes3, _ := json.Marshal(respJSON3)
  1379. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  1380. utils.ErrorLog("解析失败:%v", err)
  1381. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1382. return
  1383. }
  1384. if res3.Infcode != -1 {
  1385. item.IsChange = 1
  1386. item.Bchno = item.NewDrugWarehouseInfo.Bchno
  1387. service.SaveDF2(item)
  1388. } else {
  1389. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  1390. }
  1391. }
  1392. } else {
  1393. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res7.ErrMsg)
  1394. }
  1395. }
  1396. } else { //还没结算
  1397. if item.IsChange == 0 { //没变更,进行变更操作
  1398. result, result2 := ChangeStock(item.Count, item, miConfig, "107", roles)
  1399. saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  1400. var respJSON3 map[string]interface{}
  1401. if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  1402. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1403. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1404. return
  1405. }
  1406. userJSONBytes3, _ := json.Marshal(respJSON3)
  1407. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  1408. utils.ErrorLog("解析失败:%v", err)
  1409. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1410. return
  1411. }
  1412. if res3.Infcode != -1 {
  1413. item.IsChange = 1
  1414. item.Bchno = item.NewDrugWarehouseInfo.Bchno
  1415. service.SaveDF2(item)
  1416. } else {
  1417. err = append(err, item.HisDoctorAdviceInfo.AdviceName+",销售变更失败:"+res3.ErrMsg)
  1418. }
  1419. }
  1420. }
  1421. }
  1422. //else { //其他方式
  1423. // //if item.IsChange == 0 { //没变更,进行变更操作
  1424. // // result, result2 := ChangeStock(item.Count, item, miConfig, "107", roles)
  1425. // // saveLog(result, result2, "3502", "自动出库,未销售,未变更3502")
  1426. // //
  1427. // // var respJSON3 map[string]interface{}
  1428. // // if err := json.Unmarshal([]byte(string(result)), &respJSON3); err != nil {
  1429. // // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1430. // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1431. // // return
  1432. // // }
  1433. // // userJSONBytes3, _ := json.Marshal(respJSON3)
  1434. // // if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  1435. // // utils.ErrorLog("解析失败:%v", err)
  1436. // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1437. // // return
  1438. // // }
  1439. // // if res3.Infcode != -1{
  1440. // // item.IsChange = 1
  1441. // // item.Bchno = item.NewDrugWarehouseInfo.Bchno
  1442. // // service.SaveDF2(item)
  1443. // // }else{
  1444. // // err = append(err,item.HisDoctorAdviceInfo.AdviceName +",销售变更失败:"+res3.ErrMsg)
  1445. // // }
  1446. // //}
  1447. //}
  1448. }
  1449. if len(err) == 0 {
  1450. c.ServeSuccessJSON(map[string]interface{}{
  1451. "msg": "销售变更成功",
  1452. })
  1453. } else {
  1454. c.ServeSuccessJSON(map[string]interface{}{
  1455. "failed_code": -10,
  1456. "msg": err,
  1457. })
  1458. }
  1459. }
  1460. func ChangeStock(count int64, drug *models.DrugFlow, miConfig models.MedicalInsuranceOrgConfig, chgType string, role models.UserAdminRole) (string, string) {
  1461. var struct3502 models.Struct3502
  1462. struct3502.MedListCodg = drug.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  1463. struct3502.FixmedinsHilistId = miConfig.Code
  1464. struct3502.FixmedinsHilistName = miConfig.OrgName
  1465. struct3502.FixmedinsCode = miConfig.Code
  1466. struct3502.Opter = role.UserName
  1467. struct3502.RxFlag = "0"
  1468. struct3502.InvChgTime = time.Now().Format("2006-01-02")
  1469. struct3502.OrgName = miConfig.OrgName
  1470. struct3502.AccessKey = miConfig.AccessKey
  1471. struct3502.RequestUrl = miConfig.Url
  1472. struct3502.SecretKey = miConfig.SecretKey
  1473. struct3502.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1474. struct3502.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1475. struct3502.Url = miConfig.Url
  1476. struct3502.AppId = miConfig.Cainfo
  1477. struct3502.AppSecret = miConfig.AppSecret
  1478. struct3502.Enckey = miConfig.EncKey
  1479. struct3502.SignKey = miConfig.SignKey
  1480. struct3502.SecretKey = miConfig.SecretKey
  1481. struct3502.InvChgType = chgType
  1482. struct3502.FixmedinsBchno = drug.NewDrugWarehouseInfo.Bchno
  1483. struct3502.Cnt = strconv.FormatInt(count, 10)
  1484. struct3502.Pric = fmt.Sprintf("%.2f", drug.Price)
  1485. result1, result2, _ := service.FJyb3502(struct3502)
  1486. return result1, result2
  1487. }
  1488. func SaleStock(org_id int64, pre models.HisPrescription, drug *models.DrugFlow, miConfig models.MedicalInsuranceOrgConfig, chgType string, role models.UserAdminRole) (string, string) {
  1489. var struct3505 models.Struct3505
  1490. struct3505.MedListCodg = drug.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  1491. struct3505.FixmedinsHilistId = miConfig.Code
  1492. struct3505.FixmedinsHilistName = miConfig.OrgName
  1493. struct3505.FixmedinsBchno = drug.NewDrugWarehouseInfo.Bchno
  1494. struct3505.Opter = role.UserName
  1495. struct3505.FixmedinsCode = miConfig.Code
  1496. roles, _ := service.GetAdminUserInfoByID(org_id, pre.Creator)
  1497. struct3505.PrscDrName = roles.UserName
  1498. struct3505.PharName = "刘水山"
  1499. struct3505.PharPracCertNo = "2015026350260000002611351127"
  1500. order := service.GetHisOrderByNumber(pre.BatchNumber)
  1501. struct3505.SetlId = order.SetlId
  1502. struct3505.MdtrtSn = order.MdtrtId
  1503. struct3505.ManuLotnum = drug.Number
  1504. struct3505.ManuDate = time.Unix(drug.ProductDate, 0).Format("2006-01-02")
  1505. struct3505.ExpyEnd = ""
  1506. struct3505.RxFlag = "0"
  1507. struct3505.TrdnFlag = "1"
  1508. struct3505.RtalDocno = order.Number
  1509. struct3505.Url = miConfig.Url
  1510. struct3505.AppId = miConfig.Cainfo
  1511. struct3505.AppSecret = miConfig.AppSecret
  1512. struct3505.Enckey = miConfig.EncKey
  1513. struct3505.SignKey = miConfig.SignKey
  1514. struct3505.SecretKey = miConfig.SecretKey
  1515. strValue := fmt.Sprintf("%.2f", drug.HisDoctorAdviceInfo.PrescribingNumber)
  1516. struct3505.SelRetnCnt = strValue
  1517. struct3505.SelRetnTime = time.Unix(drug.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  1518. struct3505.SelRetnOpterName = role.UserName
  1519. if order.IsMedicineInsurance == 1 {
  1520. struct3505.MdtrtSetlType = "1"
  1521. } else {
  1522. struct3505.MdtrtSetlType = "2"
  1523. }
  1524. struct3505.OrgName = miConfig.OrgName
  1525. struct3505.AccessKey = miConfig.AccessKey
  1526. struct3505.RequestUrl = miConfig.Url
  1527. struct3505.SecretKey = miConfig.SecretKey
  1528. struct3505.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1529. struct3505.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1530. result1, result2, _ := service.FJyb3505(struct3505)
  1531. return result1, result2
  1532. }
  1533. func CancleSaleStock(org_id int64, pre models.HisPrescription, drug *models.DrugFlow, miConfig models.MedicalInsuranceOrgConfig, chgType string, role models.UserAdminRole) (string, string) {
  1534. var struct3506 models.Struct3506
  1535. struct3506.MedListCodg = drug.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  1536. struct3506.FixmedinsHilistId = miConfig.Code
  1537. struct3506.FixmedinsHilistName = miConfig.OrgName
  1538. struct3506.FixmedinsCode = miConfig.Code
  1539. struct3506.FixmedinsBchno = drug.NewDrugWarehouseInfo.Bchno
  1540. struct3506.Opter = role.UserName
  1541. order := service.GetHisOrderByNumber(pre.BatchNumber)
  1542. struct3506.ManuLotnum = drug.NewDrugWarehouseInfo.Number
  1543. struct3506.ManuDate = time.Unix(drug.ProductDate, 0).Format("2006-01-02")
  1544. struct3506.MdtrtSn = order.MdtrtId
  1545. struct3506.ExpyEnd = ""
  1546. struct3506.RxFlag = "0"
  1547. struct3506.TrdnFlag = "1"
  1548. strValue := fmt.Sprintf("%.2f", drug.HisDoctorAdviceInfo.PrescribingNumber)
  1549. struct3506.SelRetnCnt = strValue
  1550. struct3506.SelRetnTime = time.Unix(drug.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  1551. //roles_two, _ := service.GetAdminUserInfoByID(org_id, order.Creator)
  1552. struct3506.SelRetnOpterName = role.UserName
  1553. struct3506.OrgName = miConfig.OrgName
  1554. struct3506.AccessKey = miConfig.AccessKey
  1555. struct3506.RequestUrl = miConfig.Url
  1556. struct3506.SecretKey = miConfig.SecretKey
  1557. struct3506.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1558. struct3506.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1559. struct3506.Url = miConfig.Url
  1560. struct3506.AppId = miConfig.Cainfo
  1561. struct3506.AppSecret = miConfig.AppSecret
  1562. struct3506.Enckey = miConfig.EncKey
  1563. struct3506.SignKey = miConfig.SignKey
  1564. struct3506.SecretKey = miConfig.SecretKey
  1565. result1, result2, _ := service.FJyb3506(struct3506)
  1566. return result1, result2
  1567. }
  1568. func (c *HisApiController) Get1318() {
  1569. adminUser := c.GetAdminUserInfo()
  1570. admin_user_id, _ := c.GetInt64("admin_user_id")
  1571. code := c.GetString("code")
  1572. code = ""
  1573. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  1574. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  1575. api := ""
  1576. if miConfig.MdtrtareaAdmvs == "320921" {
  1577. api = "http://192.168.2.3:9532/" + "jsyb/1318?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  1578. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&h_code=" + code
  1579. } else {
  1580. api = "http://192.168.5.251:9532/" + "jsyb/1318?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  1581. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&h_code=" + code
  1582. }
  1583. resp, requestErr := http.Get(api)
  1584. if requestErr != nil {
  1585. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1586. return
  1587. }
  1588. body, ioErr := ioutil.ReadAll(resp.Body)
  1589. if ioErr != nil {
  1590. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1591. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1592. return
  1593. }
  1594. var respJSON map[string]interface{}
  1595. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  1596. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1597. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1598. return
  1599. }
  1600. //var res Result2406
  1601. /*respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1602. result, _ := json.Marshal(respJSON)
  1603. if err := json.Unmarshal([]byte(result), &res); err != nil {
  1604. utils.ErrorLog("解析失败:%v", err)
  1605. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1606. return
  1607. }
  1608. if res.Infcode == "0" {
  1609. c.ServeSuccessJSON(map[string]interface{}{
  1610. "result": "",
  1611. })
  1612. } else {
  1613. c.ServeSuccessJSON(map[string]interface{}{
  1614. "failed_code": -10,
  1615. "msg": res.ErrMsg,
  1616. })
  1617. */return
  1618. //}
  1619. }
  1620. func (c *HisApiController) Get2503() {
  1621. adminUser := c.GetAdminUserInfo()
  1622. admin_user_id, _ := c.GetInt64("admin_user_id")
  1623. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  1624. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  1625. service.Gxyb2503(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.MdtrtareaAdmvs, miConfig.InsuplcAdmdvs, "", admin_user_id)
  1626. }
  1627. func (c *HisApiController) Get2406() {
  1628. id, _ := c.GetInt64("id")
  1629. record_time := c.GetString("record_time")
  1630. his_patient_id, _ := c.GetInt64("his_patient_id")
  1631. admin_user_id, _ := c.GetInt64("admin_user_id")
  1632. diagnosis_id := c.GetString("diagnosis")
  1633. timeLayout := "2006-01-02"
  1634. loc, _ := time.LoadLocation("Local")
  1635. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  1636. if err != nil {
  1637. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1638. return
  1639. }
  1640. recordDateTime := theTime.Unix()
  1641. adminUser := c.GetAdminUserInfo()
  1642. diagnosis_ids := strings.Split(diagnosis_id, ",")
  1643. var config []*models.HisXtDiagnoseConfig
  1644. for _, item := range diagnosis_ids {
  1645. id, _ := strconv.ParseInt(item, 10, 64)
  1646. diagnosisConfig, _ := service.FindDiagnoseById(id)
  1647. config = append(config, &diagnosisConfig)
  1648. }
  1649. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  1650. fmt.Println(his_patient_id)
  1651. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  1652. //timestamp := time.Now().Unix()
  1653. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  1654. var patientPrescription models.HisPrescriptionInfo
  1655. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  1656. if patientPrescription.ID == 0 {
  1657. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  1658. }
  1659. var res2 Result2406
  1660. if miConfig.MdtrtareaAdmvs == "341203" {
  1661. data := make(map[string]interface{})
  1662. client := &http.Client{}
  1663. data["psn_no"] = his.PsnNo
  1664. data["mdtrt_id"] = his.Number
  1665. data["operator"] = roles.UserName
  1666. data["cert_no"] = his.IdCardNo
  1667. data["org_name"] = miConfig.OrgName
  1668. data["psn_name"] = his.Name
  1669. data["ipt_otp_no"] = his.IptOtpNo
  1670. data["ipt_psn_sp_flag_type"] = "0901"
  1671. data["ipt_psn_sp_flag"] = "1"
  1672. data["fixmedins_code"] = miConfig.Code
  1673. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  1674. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  1675. data["url"] = miConfig.Url
  1676. utils.ErrorLog("接口返回数据解析JSON失败: %v", data)
  1677. bytesData, _ := json.Marshal(data)
  1678. var req *http.Request
  1679. utils.ErrorLog("接口返回数据解析JSON失败: %v", miConfig.SecretKey)
  1680. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2406", bytes.NewReader(bytesData))
  1681. resp, _ := client.Do(req)
  1682. defer resp.Body.Close()
  1683. body, ioErr := ioutil.ReadAll(resp.Body)
  1684. if ioErr != nil {
  1685. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1686. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1687. return
  1688. }
  1689. var respJSON map[string]interface{}
  1690. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1691. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1692. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1693. return
  1694. }
  1695. status := respJSON["data"].(map[string]interface{})["status"].(string)
  1696. if status == "0" {
  1697. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  1698. c.ServeSuccessJSON(map[string]interface{}{
  1699. "failed_code": -10,
  1700. "msg": err_msg,
  1701. })
  1702. return
  1703. }
  1704. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1705. userJSONBytes, _ := json.Marshal(respJSON)
  1706. fmt.Println("log")
  1707. fmt.Println(string(userJSONBytes))
  1708. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  1709. utils.ErrorLog("解析失败:%v", err)
  1710. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1711. return
  1712. }
  1713. }
  1714. if res2.Infcode != 0 {
  1715. adminUser := c.GetAdminUserInfo()
  1716. errlog := &models.HisOrderError{
  1717. UserOrgId: adminUser.CurrentOrgId,
  1718. Ctime: time.Now().Unix(),
  1719. Mtime: time.Now().Unix(),
  1720. ErrMsg: res2.ErrMsg,
  1721. Status: 1,
  1722. PatientId: id,
  1723. RecordTime: recordDateTime,
  1724. Stage: 3,
  1725. }
  1726. service.CreateErrMsgLog(errlog)
  1727. c.ServeSuccessJSON(map[string]interface{}{
  1728. "failed_code": -10,
  1729. "msg": res2.ErrMsg,
  1730. })
  1731. return
  1732. } else {
  1733. c.ServeSuccessJSON(map[string]interface{}{
  1734. "msg": "上传成功",
  1735. })
  1736. return
  1737. }
  1738. }
  1739. func (c *HisApiController) Get4105() {
  1740. }
  1741. func (c *HisApiController) Post5302() {
  1742. patient_id, _ := c.GetInt64("id")
  1743. admin_user_id, _ := c.GetInt64("admin_user_id")
  1744. p, _ := service.GetHisPatientById(patient_id)
  1745. adminUser := c.GetAdminUserInfo()
  1746. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  1747. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  1748. service.Gxyb5302(p.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  1749. }
  1750. func (c *HisApiController) Get4104() {
  1751. }
  1752. type Output struct {
  1753. CertNo string `json:"certno"`
  1754. PsnName string `json:"psn_name"`
  1755. CardNo string `json:"card_no"`
  1756. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  1757. CardSN string `json:"card_sn"`
  1758. PsnCertType string `json:"psn_cert_type"`
  1759. MdtrtCertNo string `json:"mdtrt_cert_no"`
  1760. MdtrtCertType string `json:"mdtrt_cert_type"`
  1761. QRCode string `json:"qrCode"`
  1762. EcToken string `json:"ecToken"`
  1763. }
  1764. type AHResponse struct {
  1765. Body AHBody `json:"body"`
  1766. Code int `json:"code"`
  1767. CSBCode int `json:"csbCode"`
  1768. Message string `json:"message"`
  1769. RequestID string `json:"requestId"`
  1770. State struct{} `json:"state"`
  1771. }
  1772. type AHBody struct {
  1773. ErrMsg string `json:"err_msg"`
  1774. InfRefMsgID string `json:"inf_refmsgid"`
  1775. InfCode int `json:"infcode"`
  1776. Output struct {
  1777. Result []struct {
  1778. BasMednFlag string `json:"bas_medn_flag"`
  1779. ChldMedcFlag string `json:"chld_medc_flag"`
  1780. ChrgitmLv string `json:"chrgitm_lv"`
  1781. Cnt float64 `json:"cnt"`
  1782. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  1783. DrtReimFlag string `json:"drt_reim_flag"`
  1784. FeedetlSn string `json:"feedetl_sn"`
  1785. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  1786. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  1787. InscpScpAmt float64 `json:"inscp_scp_amt"`
  1788. ListSpItemFlag string `json:"list_sp_item_flag"`
  1789. LmtUsedFlag string `json:"lmt_used_flag"`
  1790. MedChrgitmType string `json:"med_chrgitm_type"`
  1791. Memo string `json:"memo"`
  1792. OverlmtAmt float64 `json:"overlmt_amt"`
  1793. PreselfpayAmt float64 `json:"preselfpay_amt"`
  1794. Pric float64 `json:"pric"`
  1795. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  1796. SelfpayProp float64 `json:"selfpay_prop"`
  1797. } `json:"result"`
  1798. } `json:"output"`
  1799. }
  1800. type Response struct {
  1801. Output Output `json:"output"`
  1802. Infcode int `json:"infcode"`
  1803. InfRefMsgID string `json:"inf_refmsgid"`
  1804. RefMsgTime string `json:"refmsg_time"`
  1805. RespondTime string `json:"respond_time"`
  1806. ErrMsg string `json:"err_msg"`
  1807. WarnMsg string `json:"warn_msg"`
  1808. SignType string `json:"signtype"`
  1809. CAInfo string `json:"cainfo"`
  1810. }
  1811. func (c *HisApiController) Getquerydata() {
  1812. query_type, _ := c.GetInt64("type")
  1813. refd_setl_flag := c.GetString("refd_setl_flag")
  1814. med_type := c.GetString("med_type")
  1815. //admin_user_id,_ := c.GetInt64("admin_user_id")
  1816. cert_no := c.GetString("cert_no")
  1817. psn_no := c.GetString("psn_no")
  1818. start_time := c.GetString("start_time")
  1819. end_time := c.GetString("end_time")
  1820. page, _ := c.GetInt64("page")
  1821. limit, _ := c.GetInt64("limit")
  1822. var bp models.BusinessParams5262
  1823. bp.RefdSetlFlag = refd_setl_flag
  1824. bp.MedType = med_type
  1825. bp.Certno = cert_no
  1826. bp.Psnno = psn_no
  1827. bp.QBegntime = start_time
  1828. bp.QEndtime = end_time
  1829. if query_type == 1 { //本地
  1830. Post5262(c, bp, page, limit)
  1831. } else { //异地
  1832. Post5267(c, bp, page, limit)
  1833. }
  1834. }
  1835. func (c *HisApiController) Drugscheck() {
  1836. admin_user_id, _ := c.GetInt64("admin_user_id")
  1837. adminUser := c.GetAdminUserInfo()
  1838. var queryResult []QueryResult
  1839. drugs, _ := service.GetBatchDrugListtw(adminUser.CurrentOrgId)
  1840. for _, item := range drugs {
  1841. result := QueryResult{
  1842. ID: item.ID,
  1843. Name: item.DrugName,
  1844. Code: item.MedicalInsuranceNumber,
  1845. List_type_code: "101",
  1846. }
  1847. queryResult = append(queryResult, result)
  1848. }
  1849. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  1850. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  1851. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  1852. for _, item := range queryResult {
  1853. 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)
  1854. }
  1855. }
  1856. func (c *HisApiController) Goodcheck() {
  1857. admin_user_id, _ := c.GetInt64("admin_user_id")
  1858. adminUser := c.GetAdminUserInfo()
  1859. var queryResult []QueryResult
  1860. goods, _ := service.GetBatchGoodInformationListtwo(adminUser.CurrentOrgId)
  1861. for _, item := range goods {
  1862. result := QueryResult{
  1863. ID: item.ID,
  1864. Name: item.GoodName,
  1865. Code: item.SocialSecurityDirectoryCode,
  1866. List_type_code: "301",
  1867. }
  1868. queryResult = append(queryResult, result)
  1869. }
  1870. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  1871. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  1872. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  1873. for _, item := range queryResult {
  1874. 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)
  1875. //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)
  1876. }
  1877. }
  1878. func (c *HisApiController) Projectcheck() {
  1879. admin_user_id, _ := c.GetInt64("admin_user_id")
  1880. adminUser := c.GetAdminUserInfo()
  1881. var queryResult []QueryResult
  1882. projects, _ := service.GetBathchMyPorjecgListtwo(adminUser.CurrentOrgId)
  1883. for _, item := range projects {
  1884. result := QueryResult{
  1885. ID: item.ID,
  1886. Name: item.ProjectName,
  1887. Code: item.MedicalCode,
  1888. List_type_code: "201",
  1889. }
  1890. queryResult = append(queryResult, result)
  1891. }
  1892. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  1893. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  1894. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  1895. for _, item := range queryResult {
  1896. 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)
  1897. }
  1898. }
  1899. //func (c *HisApiController)CancleDia(){
  1900. //
  1901. // id, _ := c.GetInt64("id")
  1902. // record_time := c.GetString("record_time")
  1903. // his_patient_id, _ := c.GetInt64("his_patient_id")
  1904. //
  1905. // admin_user_id, _ := c.GetInt64("admin_user_id")
  1906. //
  1907. // diagnosis_id := c.GetString("diagnosis")
  1908. // sick_type, _ := c.GetInt64("sick_type")
  1909. // reg_type, _ := c.GetInt64("p_type")
  1910. // begin_time := c.GetString("begin_time")
  1911. // acct_used_flag_num, _ := c.GetInt64("acct_used_flag")
  1912. //
  1913. //
  1914. // acct_used_flag := strconv.FormatInt(acct_used_flag_num, 10)
  1915. //
  1916. // fmt.Println(acct_used_flag)
  1917. //
  1918. //
  1919. // timeLayout := "2006-01-02"
  1920. // loc, _ := time.LoadLocation("Local")
  1921. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  1922. // if err != nil {
  1923. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1924. // return
  1925. // }
  1926. // recordDateTime := theTime.Unix()
  1927. // adminUser := c.GetAdminUserInfo()
  1928. //
  1929. //
  1930. //
  1931. //
  1932. //
  1933. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  1934. // his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  1935. // var patientPrescription models.HisPrescriptionInfo
  1936. // patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  1937. // if patientPrescription.ID == 0 {
  1938. // patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  1939. // }
  1940. // //if patientPrescription.Do
  1941. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  1942. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  1943. //
  1944. // doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  1945. //
  1946. // diagnosis_ids := strings.Split(diagnosis_id, ",")
  1947. //
  1948. // var config []*models.HisXtDiagnoseConfig
  1949. // for _, item := range diagnosis_ids {
  1950. // id, _ := strconv.ParseInt(item, 10, 64)
  1951. // diagnosisConfig, _ := service.FindDiagnoseById(id)
  1952. // config = append(config, &diagnosisConfig)
  1953. // }
  1954. //
  1955. // sickConfig, _ := service.FindSickById(sick_type)
  1956. //
  1957. //
  1958. // data := make(map[string]interface{})
  1959. // client := &http.Client{}
  1960. // data["psn_no"] = his.PsnNo
  1961. // data["mdtrt_id"] = his.Number
  1962. // data["doctor"] = roles.UserName
  1963. // data["department"] = department.Name
  1964. // data["org_name"] = miConfig.OrgName
  1965. // data["med_type"] = strconv.FormatInt(reg_type, 10)
  1966. // data["doctor_id"] = doctor_info.DoctorNumber
  1967. // data["new_doctor_name"] = doctor_info.UserName
  1968. // data["fixmedins_code"] = miConfig.Code
  1969. // data["insuplc_admdvs"] = his.InsuplcAdmdvs
  1970. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  1971. // data["secret_key"] = miConfig.SecretKey
  1972. // data["sick_code"] = sickConfig.CountryCode
  1973. // data["sick_name"] = sickConfig.ClassName
  1974. // data["url"] = miConfig.Url
  1975. // data["ak"] = miConfig.AccessKey
  1976. // data["begin_time"] = begin_time
  1977. // data["cainfo"] = miConfig.Cainfo
  1978. // data["is_vaild"] = "0"
  1979. //
  1980. // data["dept"] = strconv.FormatInt(department.ID, 10)
  1981. // data["config"] = config
  1982. // bytesData, _ := json.Marshal(data)
  1983. //
  1984. // var req *http.Request
  1985. // req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2203C", bytes.NewReader(bytesData))
  1986. // resp, _ := client.Do(req)
  1987. // defer resp.Body.Close()
  1988. // body, ioErr := ioutil.ReadAll(resp.Body)
  1989. // if ioErr != nil {
  1990. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1991. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1992. // return
  1993. // }
  1994. // var respJSON map[string]interface{}
  1995. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1996. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1997. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1998. // return
  1999. // }
  2000. //
  2001. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2002. // userJSONBytes, _ := json.Marshal(respJSON)
  2003. // fmt.Println("log")
  2004. // fmt.Println(string(userJSONBytes))
  2005. //
  2006. // if err := json.Unmarshal(userJSONBytes, &ressix10265); err != nil {
  2007. // utils.ErrorLog("解析失败:%v", err)
  2008. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2009. // return
  2010. // }
  2011. // res2.InfRefmsgid = ressix10265.InfRefmsgid
  2012. // res2.Output = ressix10265.Output
  2013. // res2.ErrMsg = ressix10265.ErrMsg
  2014. // res2.Cainfo = ressix10265.Cainfo
  2015. // res2.WarnMsg = ressix10265.WarnMsg
  2016. // infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  2017. // res2.Infcode = infocode
  2018. //
  2019. //}
  2020. func (c *HisApiController) Get4102() {
  2021. order_id, _ := c.GetInt64("order_id")
  2022. admin_user_id, _ := c.GetInt64("admin_user_id")
  2023. stas_type := c.GetString("stas_type")
  2024. order, _ := service.GetHisOrderByIDTwo(order_id)
  2025. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2026. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2027. var pp models.PublicParams
  2028. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  2029. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  2030. pp.FixmedinsName = miConfig.OrgName
  2031. pp.FixmedinsCode = miConfig.Code
  2032. pp.RequestUrl = miConfig.Url
  2033. pp.Cainfo = miConfig.Cainfo
  2034. pp.SecretKey = miConfig.SecretKey
  2035. pp.AccessKey = miConfig.AccessKey
  2036. pp.OpterName = curRoles.UserName
  2037. if miConfig.MdtrtareaAdmvs == "350500" {
  2038. result, request, _ := service.Fjyb4102(order.PsnNo, order.SetlId, pp, stas_type)
  2039. //result, request := service.Jxyb4103(order.PsnNo,order.SetlId,pp)
  2040. saveLog(result, request, "4102", "清单确认")
  2041. var dat map[string]interface{}
  2042. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  2043. fmt.Println(dat)
  2044. } else {
  2045. fmt.Println(err)
  2046. }
  2047. var empty ResultFourteen
  2048. userJSONBytes, _ := json.Marshal(dat)
  2049. if err := json.Unmarshal(userJSONBytes, &empty); err != nil {
  2050. utils.ErrorLog("解析失败:%v", err)
  2051. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2052. return
  2053. }
  2054. if empty.Infcode == 0 {
  2055. c.ServeSuccessJSON(map[string]interface{}{
  2056. "msg": "确认成功",
  2057. })
  2058. return
  2059. }
  2060. } else {
  2061. result, request := service.Jxyb4102(order.PsnNo, order.SetlId, pp, stas_type)
  2062. result2, request2 := service.Jxyb4103(order.PsnNo, order.SetlId, pp)
  2063. result3, request3 := service.Jxyb4105(pp)
  2064. saveLog(result, request, "4102", "清单确认")
  2065. saveLog(result2, request2, "4103", "清单确认")
  2066. saveLog(result3, request3, "4105", "清单统计")
  2067. var dat map[string]interface{}
  2068. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  2069. fmt.Println(dat)
  2070. } else {
  2071. fmt.Println(err)
  2072. }
  2073. var empty ResultFourteen
  2074. userJSONBytes, _ := json.Marshal(dat)
  2075. if err := json.Unmarshal(userJSONBytes, &empty); err != nil {
  2076. utils.ErrorLog("解析失败:%v", err)
  2077. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2078. return
  2079. }
  2080. if empty.Infcode == 0 {
  2081. c.ServeSuccessJSON(map[string]interface{}{
  2082. "msg": "确认成功",
  2083. })
  2084. return
  2085. }
  2086. }
  2087. }
  2088. // 对账权限查询
  2089. func (c *HisApiController) Get3260() {
  2090. admin_user_id, _ := c.GetInt64("admin_user_id")
  2091. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2092. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2093. var api string
  2094. var res models.JSResult3260
  2095. if miConfig.MdtrtareaAdmvs == "320921" {
  2096. api = "http://192.168.2.3:9532/" + "jsyb/3260?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  2097. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  2098. } else {
  2099. api = "http://192.168.5.251:9532/" + "jsyb/3260?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  2100. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  2101. }
  2102. resp, requestErr := http.Get(api)
  2103. if requestErr != nil {
  2104. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2105. return
  2106. }
  2107. body, ioErr := ioutil.ReadAll(resp.Body)
  2108. if ioErr != nil {
  2109. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2110. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2111. return
  2112. }
  2113. var respJSON map[string]interface{}
  2114. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  2115. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2116. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2117. return
  2118. }
  2119. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2120. result, _ := json.Marshal(respJSON)
  2121. if err := json.Unmarshal([]byte(result), &res); err != nil {
  2122. utils.ErrorLog("解析失败:%v", err)
  2123. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2124. return
  2125. }
  2126. if res.Infcode == "0" {
  2127. c.ServeSuccessJSON(map[string]interface{}{
  2128. "result": res.Output.Data,
  2129. })
  2130. } else {
  2131. c.ServeSuccessJSON(map[string]interface{}{
  2132. "failed_code": -10,
  2133. "msg": res.ErrMsg,
  2134. })
  2135. return
  2136. }
  2137. }
  2138. func (c *HisApiController) Get3261() {
  2139. admin_user_id, _ := c.GetInt64("admin_user_id")
  2140. //month := c.GetString("month")
  2141. startTime := c.GetString("start_time")
  2142. //endTime, _ := c.GetString("end_time")
  2143. times := strings.Split(startTime, "-")
  2144. stmt_mon := times[0] + times[1]
  2145. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2146. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2147. var api string
  2148. var res models.JSResult3261
  2149. //var res10265 Result5301For10265
  2150. if miConfig.MdtrtareaAdmvs == "320921" {
  2151. api = "http://192.168.2.3:9532/" + "jsyb/3261?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  2152. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + stmt_mon
  2153. } else {
  2154. api = "http://192.168.5.251:9532/" + "jsyb/3261?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  2155. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + stmt_mon
  2156. }
  2157. resp, requestErr := http.Get(api)
  2158. if requestErr != nil {
  2159. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2160. return
  2161. }
  2162. body, ioErr := ioutil.ReadAll(resp.Body)
  2163. if ioErr != nil {
  2164. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2165. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2166. return
  2167. }
  2168. var respJSON map[string]interface{}
  2169. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  2170. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2171. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2172. return
  2173. }
  2174. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2175. result, _ := json.Marshal(respJSON)
  2176. if err := json.Unmarshal([]byte(result), &res); err != nil {
  2177. utils.ErrorLog("解析失败:%v", err)
  2178. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2179. return
  2180. }
  2181. if res.Infcode == "0" {
  2182. c.ServeSuccessJSON(map[string]interface{}{
  2183. "result": res.Output,
  2184. })
  2185. } else {
  2186. c.ServeSuccessJSON(map[string]interface{}{
  2187. "failed_code": -10,
  2188. "msg": res.ErrMsg,
  2189. })
  2190. return
  2191. }
  2192. }
  2193. type TempFun struct {
  2194. FundKey string
  2195. FundCode string
  2196. }
  2197. func (c *HisApiController) Get3262() {
  2198. admin_user_id, _ := c.GetInt64("admin_user_id")
  2199. startTime := c.GetString("start_time")
  2200. endTime := c.GetString("end_time")
  2201. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2202. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2203. //timeLayout := "2006-01-02"
  2204. //loc, _ := time.LoadLocation("Local")
  2205. //var theStartTIme int64
  2206. //if len(startTime) > 0 {
  2207. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", startTime+" 00:00:00", loc)
  2208. // if err != nil {
  2209. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  2210. // return
  2211. // }
  2212. // theStartTIme = theTime.Unix()
  2213. //}
  2214. //var theEndtTIme int64
  2215. //if len(endTime) > 0 {
  2216. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", endTime+" 23:59:59", loc)
  2217. // if err != nil {
  2218. // utils.ErrorLog(err.Error())
  2219. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  2220. // return
  2221. // }
  2222. // theEndtTIme = theTime.Unix()
  2223. //}
  2224. datas, _ := service.GetOrderByTimeTen(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId)
  2225. datas_two, _ := service.GetOrderByTimeTentwo(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId)
  2226. for _, team := range datas {
  2227. fmt.Println(team.PsnTime)
  2228. for _, team_two := range datas_two {
  2229. fmt.Println(team_two.PsnTime)
  2230. if team.FundKey == team_two.FundKey {
  2231. fmt.Println(team_two.PsnTime)
  2232. team.PsnTime = team.PsnTime + team_two.PsnTime*2
  2233. fmt.Println(team.PsnTime)
  2234. }
  2235. }
  2236. }
  2237. fmt.Println("1111")
  2238. fmt.Println(datas)
  2239. fmt.Println("1111")
  2240. var twos []models.FixMonRecDetailFileInTwo
  2241. for _, team := range datas {
  2242. var two models.FixMonRecDetailFileInTwo
  2243. two.MedType = team.MedType
  2244. two.Insutype = team.Insutype
  2245. two.PsnType = team.PsnType
  2246. two.MedType = team.MedType
  2247. two.FixBlngAdmdvs = "999999"
  2248. two.InsuAdmdvs = "555555"
  2249. two.PsnTime = team.PsnTime
  2250. two.PsnCnt = team.PsnCnt
  2251. two.FundKey = team.FundKey
  2252. ms, _ := strconv.ParseFloat(team.Sumamt, 64)
  2253. fps, _ := strconv.ParseFloat(team.Fund, 64)
  2254. ia, _ := strconv.ParseFloat(team.Amt, 64)
  2255. two.MedfeeSumAmt = ms
  2256. two.InscpAmt = ia
  2257. two.FundPaySumAmt = fps
  2258. twos = append(twos, two)
  2259. }
  2260. //startTime := c.GetString("start_time")
  2261. //endTime, _ := c.GetString("end_time")
  2262. times := strings.Split(startTime, "-")
  2263. stmt_mon := times[0] + times[1]
  2264. var funs []models.FundDetail
  2265. for _, item := range datas {
  2266. fun, _ := service.GetOrderDetailByTimeTen(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId, item.FundKey)
  2267. funs = append(funs, fun...)
  2268. }
  2269. var funInfos []models.Fund
  2270. //for _, item := range funs {
  2271. // var rf []models.FundInfo
  2272. // json.Unmarshal([]byte(item.SetlDetail), &rf)
  2273. // for _, subitem := range rf {
  2274. // var fund models.Fund
  2275. // fund.FundCode = subitem.FundPayType
  2276. // fund.FundName = subitem.FundPayTypeName
  2277. // fund.FundAmt = subitem.FundPayAmt
  2278. // fund.FundKey = item.FundKey
  2279. // fund.InsuAdmdvs = "555555"
  2280. // fund.FixBlngAdmdvs = "999999"
  2281. // funInfos = append(funInfos, fund)
  2282. // }
  2283. //}
  2284. var tempFuns []TempFun
  2285. for _, funInfo := range funInfos {
  2286. var tempFun TempFun
  2287. tempFun.FundKey = funInfo.FundKey
  2288. tempFun.FundCode = funInfo.FundCode
  2289. tempFuns = append(tempFuns, tempFun)
  2290. }
  2291. tempFuns = RemoveRepeatedFunElement(tempFuns)
  2292. fmt.Println(tempFuns)
  2293. var funInfosTwo []models.Fund
  2294. decimal.DivisionPrecision = 2
  2295. for _, item := range tempFuns {
  2296. var fund models.Fund
  2297. for _, subItem := range funInfos {
  2298. if item.FundKey == subItem.FundKey && item.FundCode == subItem.FundCode {
  2299. fund.FundKey = subItem.FundKey
  2300. fund.InsuAdmdvs = subItem.InsuAdmdvs
  2301. fund.FixBlngAdmdvs = subItem.FixBlngAdmdvs
  2302. fund.FundName = subItem.FundName
  2303. fund.FundCode = subItem.FundCode
  2304. fund.FundAmt, _ = decimal.NewFromFloat(fund.FundAmt).Add(decimal.NewFromFloat(subItem.FundAmt)).Float64()
  2305. }
  2306. }
  2307. funInfosTwo = append(funInfosTwo, fund)
  2308. }
  2309. fmt.Println("funInfosTwo")
  2310. fmt.Println(funInfosTwo)
  2311. var upld_btch string
  2312. var empty models.JSResultEmpty
  2313. data := make(map[string]interface{})
  2314. data["org_name"] = miConfig.OrgName
  2315. data["doctor"] = curRoles.UserName
  2316. data["doctor_name"] = curRoles.UserName
  2317. data["fixmedins_code"] = miConfig.Code
  2318. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  2319. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  2320. data["secret_key"] = miConfig.SecretKey
  2321. data["url"] = miConfig.Url
  2322. data["ak"] = miConfig.AccessKey
  2323. data["cainfo"] = miConfig.Cainfo
  2324. data["datas"] = twos
  2325. data["fund"] = funInfosTwo
  2326. fmt.Println(twos)
  2327. month := time.Unix(1557042972, 0).Format("1")
  2328. year := time.Now().Format("2006")
  2329. month = time.Now().Format("01")
  2330. day := time.Now().Format("02")
  2331. hour := time.Now().Format("15")
  2332. min := time.Now().Format("04")
  2333. sec := time.Now().Format("05")
  2334. fix_fill_date := year + month + day + hour + min + sec
  2335. data["fix_fill_dept"] = miConfig.OrgName
  2336. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  2337. data["fix_fill_psn"] = curRoles.UserName
  2338. data["fix_fill_date"] = fix_fill_date
  2339. data["stmt_loc"] = "2"
  2340. data["setl_mon"] = stmt_mon
  2341. upld_btch = "0"
  2342. data["upld_btch"] = upld_btch
  2343. //fmt.Println(data)
  2344. client := &http.Client{}
  2345. bytesData, _ := json.Marshal(data)
  2346. var req *http.Request
  2347. if miConfig.MdtrtareaAdmvs == "320921" {
  2348. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3262", bytes.NewReader(bytesData))
  2349. } else {
  2350. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3262", bytes.NewReader(bytesData))
  2351. }
  2352. resp, _ := client.Do(req)
  2353. defer resp.Body.Close()
  2354. body, ioErr := ioutil.ReadAll(resp.Body)
  2355. if ioErr != nil {
  2356. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2357. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2358. }
  2359. var respJSON map[string]interface{}
  2360. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2361. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2362. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2363. }
  2364. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2365. //fmt.Println(respJSON)
  2366. result, _ := json.Marshal(respJSON)
  2367. //fmt.Println(result)
  2368. if err := json.Unmarshal([]byte(result), &empty); err != nil {
  2369. utils.ErrorLog("解析失败:%v", err)
  2370. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2371. }
  2372. if empty.Infcode != "0" {
  2373. c.ServeSuccessJSON(map[string]interface{}{
  2374. "failed_code": -10,
  2375. "msg": empty.ErrMsg,
  2376. })
  2377. return
  2378. } else {
  2379. c.ServeSuccessJSON(map[string]interface{}{
  2380. "msg": "上传成功",
  2381. })
  2382. return
  2383. }
  2384. }
  2385. func RemoveRepeatedFunElement(arr []TempFun) (newArr []TempFun) {
  2386. newArr = make([]TempFun, 0)
  2387. for i := 0; i < len(arr); i++ {
  2388. repeat := false
  2389. for j := i + 1; j < len(arr); j++ {
  2390. if arr[i].FundKey == arr[j].FundKey && arr[i].FundCode == arr[j].FundCode {
  2391. repeat = true
  2392. break
  2393. }
  2394. }
  2395. if !repeat {
  2396. newArr = append(newArr, arr[i])
  2397. }
  2398. }
  2399. return
  2400. }
  2401. func (c *HisApiController) Get3263() {
  2402. admin_user_id, _ := c.GetInt64("admin_user_id")
  2403. startTime := c.GetString("start_time")
  2404. //endTime, _ := c.GetString("end_time")
  2405. times := strings.Split(startTime, "-")
  2406. setl_mon := times[0] + times[1]
  2407. upld_btch := "0"
  2408. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2409. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2410. var result3263 models.JSResult3263
  2411. data := make(map[string]interface{})
  2412. data["org_name"] = miConfig.OrgName
  2413. data["doctor"] = curRoles.UserName
  2414. data["doctor_name"] = curRoles.UserName
  2415. data["fixmedins_code"] = miConfig.Code
  2416. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  2417. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  2418. data["secret_key"] = miConfig.SecretKey
  2419. data["url"] = miConfig.Url
  2420. data["ak"] = miConfig.AccessKey
  2421. data["cainfo"] = miConfig.Cainfo
  2422. data["setl_mon"] = setl_mon
  2423. data["stmt_loc"] = "2"
  2424. data["upld_btch"] = upld_btch
  2425. client := &http.Client{}
  2426. bytesData, _ := json.Marshal(data)
  2427. var req *http.Request
  2428. if miConfig.MdtrtareaAdmvs == "320921" {
  2429. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3263", bytes.NewReader(bytesData))
  2430. } else {
  2431. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3263", bytes.NewReader(bytesData))
  2432. }
  2433. resp, _ := client.Do(req)
  2434. defer resp.Body.Close()
  2435. body, ioErr := ioutil.ReadAll(resp.Body)
  2436. if ioErr != nil {
  2437. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2438. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2439. }
  2440. var respJSON map[string]interface{}
  2441. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2442. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2443. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2444. }
  2445. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2446. fmt.Println(respJSON)
  2447. result, _ := json.Marshal(respJSON)
  2448. fmt.Println(result)
  2449. if err := json.Unmarshal([]byte(result), &result3263); err != nil {
  2450. utils.ErrorLog("解析失败:%v", err)
  2451. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2452. }
  2453. if result3263.Infcode != "0" {
  2454. c.ServeSuccessJSON(map[string]interface{}{
  2455. "failed_code": -10,
  2456. "msg": result3263.ErrMsg,
  2457. })
  2458. return
  2459. } else {
  2460. c.ServeSuccessJSON(map[string]interface{}{
  2461. "list": result3263.Output,
  2462. })
  2463. return
  2464. }
  2465. }
  2466. func (c *HisApiController) Get3264() {
  2467. admin_user_id, _ := c.GetInt64("admin_user_id")
  2468. startTime := c.GetString("start_time")
  2469. //endTime, _ := c.GetString("end_time")
  2470. times := strings.Split(startTime, "-")
  2471. setl_mon := times[0] + times[1]
  2472. upld_btch := "0"
  2473. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2474. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2475. //solidify_id := []
  2476. var result3263 models.JSResult3263
  2477. data := make(map[string]interface{})
  2478. data["org_name"] = miConfig.OrgName
  2479. data["doctor"] = curRoles.UserName
  2480. data["doctor_name"] = curRoles.UserName
  2481. data["fixmedins_code"] = miConfig.Code
  2482. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  2483. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  2484. data["secret_key"] = miConfig.SecretKey
  2485. data["url"] = miConfig.Url
  2486. data["ak"] = miConfig.AccessKey
  2487. data["cainfo"] = miConfig.Cainfo
  2488. data["setl_mon"] = setl_mon
  2489. data["stmt_loc"] = "2"
  2490. data["upld_btch"] = upld_btch
  2491. client := &http.Client{}
  2492. bytesData, _ := json.Marshal(data)
  2493. var req3263 *http.Request
  2494. if miConfig.MdtrtareaAdmvs == "320921" {
  2495. req3263, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3263", bytes.NewReader(bytesData))
  2496. } else {
  2497. req3263, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3263", bytes.NewReader(bytesData))
  2498. }
  2499. resp, _ := client.Do(req3263)
  2500. defer resp.Body.Close()
  2501. body, ioErr := ioutil.ReadAll(resp.Body)
  2502. if ioErr != nil {
  2503. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2504. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2505. }
  2506. var respJSON3263 map[string]interface{}
  2507. if err := json.Unmarshal([]byte(body), &respJSON3263); err != nil {
  2508. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2509. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2510. }
  2511. respJSON3263 = respJSON3263["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2512. fmt.Println(respJSON3263)
  2513. result, _ := json.Marshal(respJSON3263)
  2514. fmt.Println(result)
  2515. if err := json.Unmarshal([]byte(result), &result3263); err != nil {
  2516. utils.ErrorLog("解析失败:%v", err)
  2517. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2518. }
  2519. var ids []string
  2520. for _, item := range result3263.Output {
  2521. ids = append(ids, item.SolidifyID)
  2522. }
  2523. var empty models.JSResultEmpty
  2524. data2 := make(map[string]interface{})
  2525. data2["org_name"] = miConfig.OrgName
  2526. data2["doctor"] = curRoles.UserName
  2527. data2["doctor_name"] = curRoles.UserName
  2528. data2["fixmedins_code"] = miConfig.Code
  2529. data2["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  2530. data2["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  2531. data2["secret_key"] = miConfig.SecretKey
  2532. data2["url"] = miConfig.Url
  2533. data2["ak"] = miConfig.AccessKey
  2534. data2["cainfo"] = miConfig.Cainfo
  2535. data2["setl_mon"] = setl_mon
  2536. data2["stmt_loc"] = "2"
  2537. data2["upld_btch"] = upld_btch
  2538. data2["solidify_id"] = ids
  2539. client2 := &http.Client{}
  2540. bytesData2, _ := json.Marshal(data2)
  2541. var req *http.Request
  2542. if miConfig.MdtrtareaAdmvs == "320921" {
  2543. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3264", bytes.NewReader(bytesData2))
  2544. } else {
  2545. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3264", bytes.NewReader(bytesData2))
  2546. }
  2547. resp2, _ := client2.Do(req)
  2548. defer resp.Body.Close()
  2549. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  2550. if ioErr2 != nil {
  2551. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  2552. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2553. }
  2554. var respJSON map[string]interface{}
  2555. if err := json.Unmarshal([]byte(body2), &respJSON); err != nil {
  2556. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2557. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2558. }
  2559. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  2560. fmt.Println(respJSON)
  2561. result2, _ := json.Marshal(respJSON)
  2562. fmt.Println(result2)
  2563. if err := json.Unmarshal([]byte(result2), &empty); err != nil {
  2564. utils.ErrorLog("解析失败:%v", err)
  2565. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2566. }
  2567. if empty.Infcode != "0" {
  2568. c.ServeSuccessJSON(map[string]interface{}{
  2569. "failed_code": -10,
  2570. "msg": empty.ErrMsg,
  2571. })
  2572. return
  2573. } else {
  2574. c.ServeSuccessJSON(map[string]interface{}{
  2575. "msg": "",
  2576. })
  2577. return
  2578. }
  2579. }
  2580. func (c *HisApiController) Get3265() {
  2581. admin_user_id, _ := c.GetInt64("admin_user_id")
  2582. startTime := c.GetString("start_time")
  2583. //endTime, _ := c.GetString("end_time")
  2584. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2585. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2586. times := strings.Split(startTime, "-")
  2587. setl_mon := times[0] + times[1]
  2588. var upld_btch string
  2589. upld_btch = "0"
  2590. //var empty models.JSResultEmpty
  2591. var result3265 models.JSResult3264
  2592. var result3263 models.JSResult3263
  2593. data2 := make(map[string]interface{})
  2594. data2["org_name"] = miConfig.OrgName
  2595. data2["doctor"] = curRoles.UserName
  2596. data2["doctor_name"] = curRoles.UserName
  2597. data2["fixmedins_code"] = miConfig.Code
  2598. data2["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  2599. data2["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  2600. data2["secret_key"] = miConfig.SecretKey
  2601. data2["url"] = miConfig.Url
  2602. data2["ak"] = miConfig.AccessKey
  2603. data2["cainfo"] = miConfig.Cainfo
  2604. data2["setl_mon"] = setl_mon
  2605. data2["stmt_loc"] = "2"
  2606. data2["upld_btch"] = upld_btch
  2607. client2 := &http.Client{}
  2608. bytesData2, _ := json.Marshal(data2)
  2609. var req3263 *http.Request
  2610. if miConfig.MdtrtareaAdmvs == "320921" {
  2611. req3263, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3263", bytes.NewReader(bytesData2))
  2612. } else {
  2613. req3263, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3263", bytes.NewReader(bytesData2))
  2614. }
  2615. resp2, _ := client2.Do(req3263)
  2616. defer resp2.Body.Close()
  2617. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  2618. if ioErr2 != nil {
  2619. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  2620. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2621. }
  2622. var respJSON3263 map[string]interface{}
  2623. if err := json.Unmarshal([]byte(body2), &respJSON3263); err != nil {
  2624. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2625. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2626. }
  2627. respJSON3263 = respJSON3263["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2628. fmt.Println(respJSON3263)
  2629. result2, _ := json.Marshal(respJSON3263)
  2630. fmt.Println(result2)
  2631. if err := json.Unmarshal([]byte(result2), &result3263); err != nil {
  2632. utils.ErrorLog("解析失败:%v", err)
  2633. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2634. }
  2635. var ids []string
  2636. for _, item := range result3263.Output {
  2637. ids = append(ids, item.SolidifyID)
  2638. }
  2639. data := make(map[string]interface{})
  2640. data["org_name"] = miConfig.OrgName
  2641. data["doctor"] = curRoles.UserName
  2642. data["doctor_name"] = curRoles.UserName
  2643. data["fixmedins_code"] = miConfig.Code
  2644. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  2645. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  2646. data["secret_key"] = miConfig.SecretKey
  2647. data["url"] = miConfig.Url
  2648. data["ak"] = miConfig.AccessKey
  2649. data["cainfo"] = miConfig.Cainfo
  2650. data["setl_mon"] = setl_mon
  2651. data["solidify_id"] = ids
  2652. month := time.Unix(1557042972, 0).Format("1")
  2653. year := time.Now().Format("2006")
  2654. month = time.Now().Format("01")
  2655. day := time.Now().Format("02")
  2656. hour := time.Now().Format("15")
  2657. min := time.Now().Format("04")
  2658. sec := time.Now().Format("05")
  2659. fix_fill_date := year + month + day + hour + min + sec
  2660. data["fix_fill_dept"] = miConfig.OrgName
  2661. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  2662. data["fix_fill_psn"] = curRoles.UserName
  2663. data["fix_fill_date"] = fix_fill_date
  2664. data["stmt_loc"] = "2"
  2665. data["upld_btch"] = upld_btch
  2666. client := &http.Client{}
  2667. bytesData, _ := json.Marshal(data)
  2668. var req *http.Request
  2669. if miConfig.MdtrtareaAdmvs == "320921" {
  2670. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3265", bytes.NewReader(bytesData))
  2671. } else {
  2672. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3265", bytes.NewReader(bytesData))
  2673. }
  2674. resp, _ := client.Do(req)
  2675. defer resp.Body.Close()
  2676. body, ioErr := ioutil.ReadAll(resp.Body)
  2677. if ioErr != nil {
  2678. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2679. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2680. }
  2681. var respJSON map[string]interface{}
  2682. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2683. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2684. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2685. }
  2686. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2687. fmt.Println(respJSON)
  2688. result, _ := json.Marshal(respJSON)
  2689. fmt.Println(result)
  2690. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  2691. utils.ErrorLog("解析失败:%v", err)
  2692. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2693. }
  2694. if result3265.Infcode != "0" {
  2695. c.ServeSuccessJSON(map[string]interface{}{
  2696. "failed_code": -10,
  2697. "msg": result3265.ErrMsg,
  2698. })
  2699. return
  2700. } else {
  2701. c.ServeSuccessJSON(map[string]interface{}{
  2702. "info": result3265.Output,
  2703. })
  2704. return
  2705. }
  2706. }
  2707. func (c *HisApiController) Get3266() {
  2708. admin_user_id, _ := c.GetInt64("admin_user_id")
  2709. startTime := c.GetString("start_time")
  2710. //endTime, _ := c.GetString("end_time")
  2711. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2712. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2713. times := strings.Split(startTime, "-")
  2714. stmt_mon := times[0] + times[1]
  2715. var upld_btch string
  2716. //var empty models.JSResultEmpty
  2717. var result3265 models.JSResult3264
  2718. data := make(map[string]interface{})
  2719. data["org_name"] = miConfig.OrgName
  2720. data["doctor"] = curRoles.UserName
  2721. data["doctor_name"] = curRoles.UserName
  2722. data["fixmedins_code"] = miConfig.Code
  2723. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  2724. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  2725. data["secret_key"] = miConfig.SecretKey
  2726. data["url"] = miConfig.Url
  2727. data["ak"] = miConfig.AccessKey
  2728. data["cainfo"] = miConfig.Cainfo
  2729. data["setl_mon"] = stmt_mon
  2730. month := time.Unix(1557042972, 0).Format("1")
  2731. year := time.Now().Format("2006")
  2732. month = time.Now().Format("01")
  2733. day := time.Now().Format("02")
  2734. hour := time.Now().Format("15")
  2735. min := time.Now().Format("04")
  2736. sec := time.Now().Format("05")
  2737. fix_fill_date := year + month + day + hour + min + sec
  2738. data["fix_fill_dept"] = miConfig.OrgName
  2739. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  2740. data["fix_fill_psn"] = curRoles.UserName
  2741. data["fix_fill_date"] = fix_fill_date
  2742. data["stmt_loc"] = "2"
  2743. upld_btch = "0"
  2744. data["upld_btch"] = upld_btch
  2745. client := &http.Client{}
  2746. bytesData, _ := json.Marshal(data)
  2747. var req *http.Request
  2748. if miConfig.MdtrtareaAdmvs == "320921" {
  2749. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3266", bytes.NewReader(bytesData))
  2750. } else {
  2751. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3266", bytes.NewReader(bytesData))
  2752. }
  2753. resp, _ := client.Do(req)
  2754. defer resp.Body.Close()
  2755. body, ioErr := ioutil.ReadAll(resp.Body)
  2756. if ioErr != nil {
  2757. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2758. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2759. }
  2760. var respJSON map[string]interface{}
  2761. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2762. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2763. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2764. }
  2765. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2766. fmt.Println(respJSON)
  2767. result, _ := json.Marshal(respJSON)
  2768. fmt.Println(result)
  2769. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  2770. utils.ErrorLog("解析失败:%v", err)
  2771. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2772. }
  2773. if result3265.Infcode != "0" {
  2774. c.ServeSuccessJSON(map[string]interface{}{
  2775. "failed_code": -10,
  2776. "msg": result3265.ErrMsg,
  2777. })
  2778. return
  2779. } else {
  2780. c.ServeSuccessJSON(map[string]interface{}{
  2781. "info": result3265.Output,
  2782. })
  2783. return
  2784. }
  2785. }
  2786. func (c *HisApiController) Get3267() {
  2787. admin_user_id, _ := c.GetInt64("admin_user_id")
  2788. startTime := c.GetString("start_time")
  2789. //endTime, _ := c.GetString("end_time")
  2790. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2791. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2792. times := strings.Split(startTime, "-")
  2793. setl_mon := times[0] + times[1]
  2794. var upld_btch string
  2795. //var empty models.JSResultEmpty
  2796. var result3265 models.JSResult3264
  2797. upld_btch = "0"
  2798. data := make(map[string]interface{})
  2799. data["org_name"] = miConfig.OrgName
  2800. data["doctor"] = curRoles.UserName
  2801. data["doctor_name"] = curRoles.UserName
  2802. data["fixmedins_code"] = miConfig.Code
  2803. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  2804. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  2805. data["secret_key"] = miConfig.SecretKey
  2806. data["url"] = miConfig.Url
  2807. data["ak"] = miConfig.AccessKey
  2808. data["cainfo"] = miConfig.Cainfo
  2809. data["setl_mon"] = setl_mon
  2810. data["stmt_loc"] = "2"
  2811. data["upld_btch"] = upld_btch
  2812. client := &http.Client{}
  2813. bytesData, _ := json.Marshal(data)
  2814. var req *http.Request
  2815. if miConfig.MdtrtareaAdmvs == "320921" {
  2816. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3267", bytes.NewReader(bytesData))
  2817. } else {
  2818. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3267", bytes.NewReader(bytesData))
  2819. }
  2820. resp, _ := client.Do(req)
  2821. defer resp.Body.Close()
  2822. body, ioErr := ioutil.ReadAll(resp.Body)
  2823. if ioErr != nil {
  2824. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2825. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2826. }
  2827. var respJSON map[string]interface{}
  2828. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2829. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2830. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2831. }
  2832. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2833. fmt.Println(respJSON)
  2834. result, _ := json.Marshal(respJSON)
  2835. fmt.Println(result)
  2836. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  2837. utils.ErrorLog("解析失败:%v", err)
  2838. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2839. }
  2840. if result3265.Infcode != "0" {
  2841. c.ServeSuccessJSON(map[string]interface{}{
  2842. "failed_code": -10,
  2843. "msg": result3265.ErrMsg,
  2844. })
  2845. return
  2846. } else {
  2847. c.ServeSuccessJSON(map[string]interface{}{
  2848. "info": result3265.Output.Data,
  2849. })
  2850. return
  2851. }
  2852. }
  2853. func (c *HisApiController) Get3268() {
  2854. admin_user_id, _ := c.GetInt64("admin_user_id")
  2855. startTime := c.GetString("start_time")
  2856. endTime := c.GetString("end_time")
  2857. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2858. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2859. times := strings.Split(startTime, "-")
  2860. setl_mon := times[0] + times[1]
  2861. datas, _ := service.GetOrderByTimeTen(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId)
  2862. var twos []models.FixMonRecDetailFileInTwo
  2863. var funs []models.FundDetail
  2864. for _, item := range datas {
  2865. fun, _ := service.GetOrderDetailByTimeTen(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId, item.FundKey)
  2866. funs = append(funs, fun...)
  2867. }
  2868. var funInfos []models.Fund
  2869. //for _, item := range funs {
  2870. // var rf []models.FundInfo
  2871. // json.Unmarshal([]byte(item.SetlDetail), &rf)
  2872. // for _, subitem := range rf {
  2873. // var fund models.Fund
  2874. // fund.FundCode = subitem.FundPayType
  2875. // fund.FundName = subitem.FundPayTypeName
  2876. // fund.FundAmt = subitem.FundPayAmt
  2877. // fund.FundKey = item.FundKey
  2878. // fund.InsuAdmdvs = "555555"
  2879. // fund.FixBlngAdmdvs = miConfig.MdtrtareaAdmvs
  2880. // funInfos = append(funInfos, fund)
  2881. // }
  2882. //}
  2883. for _, team := range datas {
  2884. var two models.FixMonRecDetailFileInTwo
  2885. two.SetlDate = time.Now().Format("2006-01-02")
  2886. two.MedType = team.MedType
  2887. two.Insutype = team.Insutype
  2888. two.PsnType = team.PsnType
  2889. two.MedType = team.MedType
  2890. two.FixBlngAdmdvs = team.FixBlngAdmdvs
  2891. two.InsuAdmdvs = team.InsuAdmdvs
  2892. two.PsnTime = team.PsnTime
  2893. two.PsnCnt = team.PsnCnt
  2894. two.FundKey = team.FundKey
  2895. ms, _ := strconv.ParseFloat(team.Sumamt, 64)
  2896. fps, _ := strconv.ParseFloat(team.Fund, 64)
  2897. ia, _ := strconv.ParseFloat(team.Amt, 64)
  2898. two.MedfeeSumAmt = ms
  2899. two.InscpAmt = ia
  2900. two.FundPaySumAmt = fps
  2901. twos = append(twos, two)
  2902. }
  2903. var upld_btch string
  2904. upld_btch = "0"
  2905. var empty models.JSResultEmpty
  2906. data := make(map[string]interface{})
  2907. data["org_name"] = miConfig.OrgName
  2908. data["doctor"] = curRoles.UserName
  2909. data["doctor_name"] = curRoles.UserName
  2910. data["fixmedins_code"] = miConfig.Code
  2911. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  2912. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  2913. data["secret_key"] = miConfig.SecretKey
  2914. data["url"] = miConfig.Url
  2915. data["ak"] = miConfig.AccessKey
  2916. data["cainfo"] = miConfig.Cainfo
  2917. data["datas"] = twos
  2918. data["fund"] = funInfos
  2919. data["setl_mon"] = setl_mon
  2920. month := time.Unix(1557042972, 0).Format("1")
  2921. year := time.Now().Format("2006")
  2922. month = time.Now().Format("01")
  2923. day := time.Now().Format("02")
  2924. hour := time.Now().Format("15")
  2925. min := time.Now().Format("04")
  2926. sec := time.Now().Format("05")
  2927. fix_fill_date := year + month + day + hour + min + sec
  2928. data["fix_fill_dept"] = miConfig.OrgName
  2929. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  2930. data["fix_fill_psn"] = curRoles.UserName
  2931. data["fix_fill_date"] = fix_fill_date
  2932. data["stmt_loc"] = "2"
  2933. data["upld_btch"] = upld_btch
  2934. client := &http.Client{}
  2935. bytesData, _ := json.Marshal(data)
  2936. var req *http.Request
  2937. if miConfig.MdtrtareaAdmvs == "320921" {
  2938. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3268", bytes.NewReader(bytesData))
  2939. } else {
  2940. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3268", bytes.NewReader(bytesData))
  2941. }
  2942. resp, _ := client.Do(req)
  2943. defer resp.Body.Close()
  2944. body, ioErr := ioutil.ReadAll(resp.Body)
  2945. if ioErr != nil {
  2946. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2947. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2948. }
  2949. var respJSON map[string]interface{}
  2950. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2951. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2952. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2953. }
  2954. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2955. fmt.Println(respJSON)
  2956. result, _ := json.Marshal(respJSON)
  2957. fmt.Println(result)
  2958. if err := json.Unmarshal([]byte(result), &empty); err != nil {
  2959. utils.ErrorLog("解析失败:%v", err)
  2960. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2961. }
  2962. if empty.Infcode != "0" {
  2963. c.ServeSuccessJSON(map[string]interface{}{
  2964. "failed_code": -10,
  2965. "msg": empty.ErrMsg,
  2966. })
  2967. return
  2968. } else {
  2969. c.ServeSuccessJSON(map[string]interface{}{
  2970. "msg": "上传成功",
  2971. })
  2972. return
  2973. }
  2974. }
  2975. func (c *HisApiController) Get3269() {
  2976. admin_user_id, _ := c.GetInt64("admin_user_id")
  2977. startTime := c.GetString("start_time")
  2978. //endTime, _ := c.GetString("end_time")
  2979. times := strings.Split(startTime, "-")
  2980. setl_mon := times[0] + times[1]
  2981. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2982. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2983. var result3263 models.JSResult3263
  2984. data := make(map[string]interface{})
  2985. data["org_name"] = miConfig.OrgName
  2986. data["doctor"] = curRoles.UserName
  2987. data["doctor_name"] = curRoles.UserName
  2988. data["fixmedins_code"] = miConfig.Code
  2989. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  2990. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  2991. data["secret_key"] = miConfig.SecretKey
  2992. data["url"] = miConfig.Url
  2993. data["ak"] = miConfig.AccessKey
  2994. data["cainfo"] = miConfig.Cainfo
  2995. data["setl_mon"] = setl_mon
  2996. data["stmt_loc"] = "2"
  2997. client := &http.Client{}
  2998. bytesData, _ := json.Marshal(data)
  2999. var req *http.Request
  3000. if miConfig.MdtrtareaAdmvs == "320921" {
  3001. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3269", bytes.NewReader(bytesData))
  3002. } else {
  3003. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3269", bytes.NewReader(bytesData))
  3004. }
  3005. resp, _ := client.Do(req)
  3006. defer resp.Body.Close()
  3007. body, ioErr := ioutil.ReadAll(resp.Body)
  3008. if ioErr != nil {
  3009. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3010. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3011. }
  3012. var respJSON map[string]interface{}
  3013. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  3014. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3015. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3016. }
  3017. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3018. fmt.Println(respJSON)
  3019. result, _ := json.Marshal(respJSON)
  3020. fmt.Println(result)
  3021. if err := json.Unmarshal([]byte(result), &result3263); err != nil {
  3022. utils.ErrorLog("解析失败:%v", err)
  3023. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3024. }
  3025. if result3263.Infcode != "0" {
  3026. c.ServeSuccessJSON(map[string]interface{}{
  3027. "failed_code": -10,
  3028. "msg": result3263.ErrMsg,
  3029. })
  3030. return
  3031. } else {
  3032. c.ServeSuccessJSON(map[string]interface{}{
  3033. "msg": "上传成功",
  3034. })
  3035. return
  3036. }
  3037. }
  3038. func (c *HisApiController) Get3270() {
  3039. admin_user_id, _ := c.GetInt64("admin_user_id")
  3040. startTime := c.GetString("start_time")
  3041. //endTime, _ := c.GetString("end_time")
  3042. times := strings.Split(startTime, "-")
  3043. setl_mon := times[0] + times[1]
  3044. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3045. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3046. var result3263 models.JSResult3263
  3047. data2 := make(map[string]interface{})
  3048. data2["org_name"] = miConfig.OrgName
  3049. data2["doctor"] = curRoles.UserName
  3050. data2["doctor_name"] = curRoles.UserName
  3051. data2["fixmedins_code"] = miConfig.Code
  3052. data2["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  3053. data2["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  3054. data2["secret_key"] = miConfig.SecretKey
  3055. data2["url"] = miConfig.Url
  3056. data2["ak"] = miConfig.AccessKey
  3057. data2["cainfo"] = miConfig.Cainfo
  3058. data2["setl_mon"] = setl_mon
  3059. data2["stmt_loc"] = "2"
  3060. client2 := &http.Client{}
  3061. bytesData2, _ := json.Marshal(data2)
  3062. var req3263 *http.Request
  3063. if miConfig.MdtrtareaAdmvs == "320921" {
  3064. req3263, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3269", bytes.NewReader(bytesData2))
  3065. } else {
  3066. req3263, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3269", bytes.NewReader(bytesData2))
  3067. }
  3068. resp2, _ := client2.Do(req3263)
  3069. defer resp2.Body.Close()
  3070. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  3071. if ioErr2 != nil {
  3072. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  3073. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3074. }
  3075. var respJSON3263 map[string]interface{}
  3076. if err := json.Unmarshal([]byte(body2), &respJSON3263); err != nil {
  3077. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3078. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3079. }
  3080. respJSON3263 = respJSON3263["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3081. fmt.Println(respJSON3263)
  3082. result2, _ := json.Marshal(respJSON3263)
  3083. fmt.Println(result2)
  3084. if err := json.Unmarshal([]byte(result2), &result3263); err != nil {
  3085. utils.ErrorLog("解析失败:%v", err)
  3086. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3087. }
  3088. var ids []string
  3089. for _, item := range result3263.Output {
  3090. ids = append(ids, item.SolidifyID)
  3091. }
  3092. var result3264 models.JSResult3264
  3093. data := make(map[string]interface{})
  3094. data["org_name"] = miConfig.OrgName
  3095. data["doctor"] = curRoles.UserName
  3096. data["doctor_name"] = curRoles.UserName
  3097. data["fixmedins_code"] = miConfig.Code
  3098. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  3099. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  3100. data["secret_key"] = miConfig.SecretKey
  3101. data["url"] = miConfig.Url
  3102. data["ak"] = miConfig.AccessKey
  3103. data["cainfo"] = miConfig.Cainfo
  3104. data["setl_mon"] = setl_mon
  3105. data["stmt_loc"] = "2"
  3106. data["solidify_id"] = ids
  3107. client := &http.Client{}
  3108. bytesData, _ := json.Marshal(data)
  3109. var req *http.Request
  3110. if miConfig.MdtrtareaAdmvs == "320921" {
  3111. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3270", bytes.NewReader(bytesData))
  3112. } else {
  3113. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3270", bytes.NewReader(bytesData))
  3114. }
  3115. resp, _ := client.Do(req)
  3116. defer resp.Body.Close()
  3117. body, ioErr := ioutil.ReadAll(resp.Body)
  3118. if ioErr != nil {
  3119. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3120. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3121. }
  3122. var respJSON map[string]interface{}
  3123. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  3124. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3125. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3126. }
  3127. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3128. fmt.Println(respJSON)
  3129. result, _ := json.Marshal(respJSON)
  3130. fmt.Println(result)
  3131. if err := json.Unmarshal([]byte(result), &result3264); err != nil {
  3132. utils.ErrorLog("解析失败:%v", err)
  3133. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3134. }
  3135. if result3264.Infcode != "0" {
  3136. c.ServeSuccessJSON(map[string]interface{}{
  3137. "failed_code": -10,
  3138. "msg": result3264.ErrMsg,
  3139. })
  3140. return
  3141. } else {
  3142. c.ServeSuccessJSON(map[string]interface{}{
  3143. "info": result3264.Output,
  3144. })
  3145. return
  3146. }
  3147. }
  3148. func (c *HisApiController) Get3271() {
  3149. admin_user_id, _ := c.GetInt64("admin_user_id")
  3150. startTime := c.GetString("start_time")
  3151. //endTime, _ := c.GetString("end_time")
  3152. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3153. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3154. times := strings.Split(startTime, "-")
  3155. setl_mon := times[0] + times[1]
  3156. //var empty models.JSResultEmpty
  3157. var result3265 models.JSResult3264
  3158. var result3263 models.JSResult3263
  3159. data2 := make(map[string]interface{})
  3160. data2["org_name"] = miConfig.OrgName
  3161. data2["doctor"] = curRoles.UserName
  3162. data2["doctor_name"] = curRoles.UserName
  3163. data2["fixmedins_code"] = miConfig.Code
  3164. data2["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  3165. data2["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  3166. data2["secret_key"] = miConfig.SecretKey
  3167. data2["url"] = miConfig.Url
  3168. data2["ak"] = miConfig.AccessKey
  3169. data2["cainfo"] = miConfig.Cainfo
  3170. data2["setl_mon"] = setl_mon
  3171. data2["stmt_loc"] = "2"
  3172. client2 := &http.Client{}
  3173. bytesData2, _ := json.Marshal(data2)
  3174. var req3263 *http.Request
  3175. if miConfig.MdtrtareaAdmvs == "320921" {
  3176. req3263, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3269", bytes.NewReader(bytesData2))
  3177. } else {
  3178. req3263, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3269", bytes.NewReader(bytesData2))
  3179. }
  3180. resp2, _ := client2.Do(req3263)
  3181. defer resp2.Body.Close()
  3182. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  3183. if ioErr2 != nil {
  3184. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  3185. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3186. }
  3187. var respJSON3263 map[string]interface{}
  3188. if err := json.Unmarshal([]byte(body2), &respJSON3263); err != nil {
  3189. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3190. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3191. }
  3192. respJSON3263 = respJSON3263["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3193. fmt.Println(respJSON3263)
  3194. result2, _ := json.Marshal(respJSON3263)
  3195. fmt.Println(result2)
  3196. if err := json.Unmarshal([]byte(result2), &result3263); err != nil {
  3197. utils.ErrorLog("解析失败:%v", err)
  3198. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3199. }
  3200. var ids []string
  3201. for _, item := range result3263.Output {
  3202. ids = append(ids, item.SolidifyID)
  3203. }
  3204. data := make(map[string]interface{})
  3205. data["org_name"] = miConfig.OrgName
  3206. data["doctor"] = curRoles.UserName
  3207. data["doctor_name"] = curRoles.UserName
  3208. data["fixmedins_code"] = miConfig.Code
  3209. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  3210. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  3211. data["secret_key"] = miConfig.SecretKey
  3212. data["url"] = miConfig.Url
  3213. data["ak"] = miConfig.AccessKey
  3214. data["cainfo"] = miConfig.Cainfo
  3215. data["setl_mon"] = setl_mon
  3216. data["solidify_id"] = ids
  3217. month := time.Unix(1557042972, 0).Format("1")
  3218. year := time.Now().Format("2006")
  3219. month = time.Now().Format("01")
  3220. day := time.Now().Format("02")
  3221. hour := time.Now().Format("15")
  3222. min := time.Now().Format("04")
  3223. sec := time.Now().Format("05")
  3224. fix_fill_date := year + month + day + hour + min + sec
  3225. data["fix_fill_dept"] = miConfig.OrgName
  3226. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  3227. data["fix_fill_psn"] = curRoles.UserName
  3228. data["fix_fill_date"] = fix_fill_date
  3229. data["stmt_loc"] = "2"
  3230. client := &http.Client{}
  3231. bytesData, _ := json.Marshal(data)
  3232. var req *http.Request
  3233. if miConfig.MdtrtareaAdmvs == "320921" {
  3234. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3271", bytes.NewReader(bytesData))
  3235. } else {
  3236. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3271", bytes.NewReader(bytesData))
  3237. }
  3238. resp, _ := client.Do(req)
  3239. defer resp.Body.Close()
  3240. body, ioErr := ioutil.ReadAll(resp.Body)
  3241. if ioErr != nil {
  3242. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3243. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3244. }
  3245. var respJSON map[string]interface{}
  3246. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  3247. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3248. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3249. }
  3250. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3251. fmt.Println(respJSON)
  3252. result, _ := json.Marshal(respJSON)
  3253. fmt.Println(result)
  3254. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  3255. utils.ErrorLog("解析失败:%v", err)
  3256. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3257. }
  3258. if result3265.Infcode != "0" {
  3259. c.ServeSuccessJSON(map[string]interface{}{
  3260. "failed_code": -10,
  3261. "msg": result3265.ErrMsg,
  3262. })
  3263. return
  3264. } else {
  3265. c.ServeSuccessJSON(map[string]interface{}{
  3266. "info": result3265.Output.Data,
  3267. })
  3268. return
  3269. }
  3270. }
  3271. func (c *HisApiController) Get3272() {
  3272. admin_user_id, _ := c.GetInt64("admin_user_id")
  3273. startTime := c.GetString("start_time")
  3274. //endTime, _ := c.GetString("end_time")
  3275. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3276. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3277. times := strings.Split(startTime, "-")
  3278. setl_mon := times[0] + times[1]
  3279. var upld_btch string
  3280. //var empty models.JSResultEmpty
  3281. var result3265 models.JSResult3264
  3282. data := make(map[string]interface{})
  3283. data["org_name"] = miConfig.OrgName
  3284. data["doctor"] = curRoles.UserName
  3285. data["doctor_name"] = curRoles.UserName
  3286. data["fixmedins_code"] = miConfig.Code
  3287. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  3288. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  3289. data["secret_key"] = miConfig.SecretKey
  3290. data["url"] = miConfig.Url
  3291. data["ak"] = miConfig.AccessKey
  3292. data["cainfo"] = miConfig.Cainfo
  3293. data["setl_mon"] = setl_mon
  3294. month := time.Unix(1557042972, 0).Format("1")
  3295. year := time.Now().Format("2006")
  3296. month = time.Now().Format("01")
  3297. day := time.Now().Format("02")
  3298. hour := time.Now().Format("15")
  3299. min := time.Now().Format("04")
  3300. sec := time.Now().Format("05")
  3301. fix_fill_date := year + month + day + hour + min + sec
  3302. data["fix_fill_dept"] = miConfig.OrgName
  3303. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  3304. data["fix_fill_psn"] = curRoles.UserName
  3305. data["fix_fill_date"] = fix_fill_date
  3306. data["stmt_loc"] = "2"
  3307. data["upld_btch"] = upld_btch
  3308. client := &http.Client{}
  3309. bytesData, _ := json.Marshal(data)
  3310. var req *http.Request
  3311. if miConfig.MdtrtareaAdmvs == "320921" {
  3312. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3272", bytes.NewReader(bytesData))
  3313. } else {
  3314. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3272", bytes.NewReader(bytesData))
  3315. }
  3316. resp, _ := client.Do(req)
  3317. defer resp.Body.Close()
  3318. body, ioErr := ioutil.ReadAll(resp.Body)
  3319. if ioErr != nil {
  3320. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3321. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3322. }
  3323. var respJSON map[string]interface{}
  3324. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  3325. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3326. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3327. }
  3328. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3329. fmt.Println(respJSON)
  3330. result, _ := json.Marshal(respJSON)
  3331. fmt.Println(result)
  3332. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  3333. utils.ErrorLog("解析失败:%v", err)
  3334. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3335. }
  3336. if result3265.Infcode != "0" {
  3337. c.ServeSuccessJSON(map[string]interface{}{
  3338. "failed_code": -10,
  3339. "msg": result3265.ErrMsg,
  3340. })
  3341. return
  3342. } else {
  3343. c.ServeSuccessJSON(map[string]interface{}{
  3344. "info": result3265.Output,
  3345. })
  3346. return
  3347. }
  3348. }
  3349. func (c *HisApiController) Get3273() {
  3350. admin_user_id, _ := c.GetInt64("admin_user_id")
  3351. startTime := c.GetString("start_time")
  3352. //endTime, _ := c.GetString("end_time")
  3353. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3354. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3355. times := strings.Split(startTime, "-")
  3356. setl_mon := times[0] + times[1]
  3357. var result3265 models.JSResult3264
  3358. data := make(map[string]interface{})
  3359. data["org_name"] = miConfig.OrgName
  3360. data["doctor"] = curRoles.UserName
  3361. data["doctor_name"] = curRoles.UserName
  3362. data["fixmedins_code"] = miConfig.Code
  3363. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  3364. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  3365. data["secret_key"] = miConfig.SecretKey
  3366. data["url"] = miConfig.Url
  3367. data["ak"] = miConfig.AccessKey
  3368. data["cainfo"] = miConfig.Cainfo
  3369. data["setl_mon"] = setl_mon
  3370. data["stmt_loc"] = "2"
  3371. client := &http.Client{}
  3372. bytesData, _ := json.Marshal(data)
  3373. var req *http.Request
  3374. if miConfig.MdtrtareaAdmvs == "320921" {
  3375. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3273", bytes.NewReader(bytesData))
  3376. } else {
  3377. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3273", bytes.NewReader(bytesData))
  3378. }
  3379. resp, _ := client.Do(req)
  3380. defer resp.Body.Close()
  3381. body, ioErr := ioutil.ReadAll(resp.Body)
  3382. if ioErr != nil {
  3383. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3384. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3385. }
  3386. var respJSON map[string]interface{}
  3387. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  3388. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3389. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3390. }
  3391. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  3392. fmt.Println(respJSON)
  3393. result, _ := json.Marshal(respJSON)
  3394. fmt.Println(result)
  3395. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  3396. utils.ErrorLog("解析失败:%v", err)
  3397. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3398. }
  3399. if result3265.Infcode != "0" {
  3400. c.ServeSuccessJSON(map[string]interface{}{
  3401. "failed_code": -10,
  3402. "msg": result3265.ErrMsg,
  3403. })
  3404. return
  3405. } else {
  3406. c.ServeSuccessJSON(map[string]interface{}{
  3407. "info": result3265.Output.Data,
  3408. })
  3409. return
  3410. }
  3411. }
  3412. func (c *HisApiController) Get3274() {
  3413. //if miConfig.MdtrtareaAdmvs == "320921" {
  3414. // api = "http://192.168.2.3:9532/" + "jsyb/3274?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  3415. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  3416. // "&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
  3417. //
  3418. //} else {
  3419. // api = "http://192.168.5.251:9532/" + "jsyb/3274?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  3420. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  3421. // "&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
  3422. //
  3423. //}
  3424. }
  3425. func (c *HisApiController) Get3275() {
  3426. //if miConfig.MdtrtareaAdmvs == "320921" {
  3427. // api = "http://192.168.2.3:9532/" + "jsyb/3275?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  3428. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  3429. // "&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
  3430. //
  3431. //} else {
  3432. // api = "http://192.168.5.251:9532/" + "jsyb/3275?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  3433. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  3434. // "&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
  3435. //
  3436. //}
  3437. }
  3438. func (c *HisApiController) Get3276() {
  3439. //admin_user_id, _ := c.GetInt64("admin_user_id")
  3440. //month := c.GetString("month")
  3441. //
  3442. //curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3443. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3444. //var api string
  3445. //var res Result5301
  3446. //
  3447. //if miConfig.MdtrtareaAdmvs == "320921" {
  3448. // api = "http://192.168.2.3:9532/" + "jsyb/3276?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  3449. // "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + month
  3450. //} else {
  3451. // api = "http://192.168.5.251:9532/" + "jsyb/3264?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  3452. // "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + month
  3453. //}
  3454. //
  3455. //resp, requestErr := http.Get(api)
  3456. //if requestErr != nil {
  3457. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3458. // return
  3459. //}
  3460. //
  3461. //body, ioErr := ioutil.ReadAll(resp.Body)
  3462. //if ioErr != nil {
  3463. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3464. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3465. // return
  3466. //}
  3467. //var respJSON map[string]interface{}
  3468. //if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  3469. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3470. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3471. // return
  3472. //}
  3473. //
  3474. //respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3475. //result, _ := json.Marshal(respJSON)
  3476. //if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  3477. // utils.ErrorLog("解析失败:%v", err)
  3478. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3479. // return
  3480. //}
  3481. }
  3482. func (c *HisApiController) Get3277() {
  3483. //admin_user_id, _ := c.GetInt64("admin_user_id")
  3484. //month := c.GetString("month")
  3485. //
  3486. //curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3487. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3488. //var api string
  3489. //var res Result5301
  3490. //
  3491. //if miConfig.MdtrtareaAdmvs == "320921" {
  3492. // api = "http://192.168.2.3:9532/" + "jsyb/3264?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  3493. // "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + month
  3494. //} else {
  3495. // api = "http://192.168.5.251:9532/" + "jsyb/3264?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  3496. // "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + month
  3497. //}
  3498. //
  3499. //resp, requestErr := http.Get(api)
  3500. //if requestErr != nil {
  3501. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3502. // return
  3503. //}
  3504. //
  3505. //body, ioErr := ioutil.ReadAll(resp.Body)
  3506. //if ioErr != nil {
  3507. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3508. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3509. // return
  3510. //}
  3511. //var respJSON map[string]interface{}
  3512. //if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  3513. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3514. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3515. // return
  3516. //}
  3517. //
  3518. //respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3519. //result, _ := json.Marshal(respJSON)
  3520. //if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  3521. // utils.ErrorLog("解析失败:%v", err)
  3522. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3523. // return
  3524. //}
  3525. }
  3526. func (c *HisApiController) GetCFYLJG001() {
  3527. admin_user_id, _ := c.GetInt64("admin_user_id")
  3528. patient_id, _ := c.GetInt64("patient_id")
  3529. his_patient_id, _ := c.GetInt64("his_patient_id")
  3530. record_time := c.GetString("record_time")
  3531. admin_user_id = 3626
  3532. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  3533. psn, _ := service.GetPsnByPatientId(patient_id)
  3534. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3535. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3536. var cFYLJG001 models.CFYLJG001
  3537. timeLayout := "2006-01-02"
  3538. loc, _ := time.LoadLocation("Local")
  3539. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  3540. if err != nil {
  3541. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  3542. return
  3543. }
  3544. recordDateTime := theTime.Unix()
  3545. prescriptions, _ := service.GetHisPrescriptionForMedType(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  3546. info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  3547. //info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  3548. doctor_info, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, info.DoctorId)
  3549. //dept, _ := service.GetDepartMentDetail(info.Departments)
  3550. for _, item := range prescriptions {
  3551. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, item.Creator)
  3552. if his.IdCardType == 1 {
  3553. bas := strings.Split(psn.CardInfo, "|")
  3554. basNumber := bas[1]
  3555. fmt.Println(basNumber)
  3556. card_sn := bas[3]
  3557. card_no := bas[2]
  3558. cFYLJG001.MdtrtCertType = "03"
  3559. cFYLJG001.CardSn = card_sn
  3560. cFYLJG001.MdtrtCertNo = card_no
  3561. cFYLJG001.EcToken = ""
  3562. cFYLJG001.AuthNo = ""
  3563. } else if his.IdCardType == 2 {
  3564. cFYLJG001.MdtrtCertType = "02"
  3565. cFYLJG001.CardSn = ""
  3566. cFYLJG001.MdtrtCertNo = his.IdCardNo
  3567. cFYLJG001.EcToken = ""
  3568. cFYLJG001.AuthNo = ""
  3569. } else if his.IdCardType == 4 {
  3570. cFYLJG001.MdtrtCertType = "01"
  3571. cFYLJG001.CardSn = ""
  3572. cFYLJG001.MdtrtCertNo = psn.VerifyNumber
  3573. cFYLJG001.EcToken = psn.VerifyNumber
  3574. cFYLJG001.AuthNo = ""
  3575. }
  3576. cFYLJG001.BizTypeCode = "01"
  3577. cFYLJG001.InsuAdmdvs = psn.InsuplcAdmdvs
  3578. cFYLJG001.HospRxno = strconv.FormatInt(item.ID, 10)
  3579. cFYLJG001.RxTypeCode = "1"
  3580. tempTime := time.Unix(item.PreTime, 0)
  3581. timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  3582. cFYLJG001.PrscTime = timeFormatOne
  3583. var count float64
  3584. if item.Type == 1 {
  3585. for _, sumItem := range item.HisDoctorAdviceInfo {
  3586. count = count + sumItem.PrescribingNumber
  3587. }
  3588. }
  3589. cFYLJG001.RxDrugCnt = count
  3590. cFYLJG001.ValiDays = "5"
  3591. ts := time.Unix(item.PreTime, 0)
  3592. record_time2 := ts.AddDate(0, 0, int(5)).Unix()
  3593. tempTime3 := time.Unix(record_time2, 0)
  3594. timeFormat3 := tempTime3.Format("2006-01-02 15:04:05")
  3595. cFYLJG001.ValiEndTime = timeFormat3
  3596. cFYLJG001.RxCotnFlag = "0"
  3597. for _, subItem := range item.HisDoctorAdviceInfo {
  3598. var drug models.RxDrug
  3599. drug.MedListCodg = subItem.BaseDrugLib.MedicalInsuranceNumber
  3600. drug.MedinsListCodg = subItem.BaseDrugLib.MedicalInsuranceNumber
  3601. drug.RxItemTypeCode = "11"
  3602. drug.DrugDosform = "乳膏剂" //TODO
  3603. if subItem.BaseDrugLib.MinUnit != subItem.BaseDrugLib.DoseUnit {
  3604. drug.DrugSpec = subItem.BaseDrugLib.Dose + subItem.BaseDrugLib.DoseUnit + "*" + strconv.FormatInt(subItem.BaseDrugLib.MinNumber, 10) + subItem.BaseDrugLib.MinUnit + "/" + subItem.BaseDrugLib.MaxUnit
  3605. }
  3606. drug.MedcWayDscr = subItem.DeliveryWay
  3607. tempTime2 := time.Unix(subItem.StartTime, 0)
  3608. timeFormatTwo := tempTime2.Format("2006-01-02 15:04:05")
  3609. drug.MedcBegntime = timeFormatTwo
  3610. if subItem.Day > 0 {
  3611. ts := time.Unix(subItem.StartTime, 0)
  3612. record_time := ts.AddDate(0, 0, int(subItem.Day)).Unix()
  3613. tempTime4 := time.Unix(record_time, 0)
  3614. timeFormat5 := tempTime4.Format("2006-01-02 15:04:05")
  3615. drug.MedcEndtime = timeFormat5
  3616. } else {
  3617. tempTime2 := time.Unix(subItem.StartTime, 0)
  3618. timeFormatTwo := tempTime2.Format("2006-01-02 15:04:05")
  3619. drug.MedcEndtime = timeFormatTwo
  3620. }
  3621. drug.MedcDays = strconv.FormatInt(subItem.Day, 10)
  3622. drug.DrugPric = fmt.Sprintf("%.2f", subItem.Price)
  3623. drug.DrugSumamt = fmt.Sprintf("%.2f", subItem.Price*subItem.PrescribingNumber)
  3624. drug.DrugCnt = subItem.PrescribingNumber
  3625. drug.DrugDosunt = subItem.PrescribingNumberUnit
  3626. drug.DrugGenname = subItem.AdviceName
  3627. drug.MedcWayCodg = subItem.DeliveryWay
  3628. //drug.DrugTotlcnt = subItem.PrescribingNumber
  3629. drug.SinDoscnt = subItem.SingleDose
  3630. drug.SinDosunt = subItem.SingleDoseUnit
  3631. drug.UsedFrquCodg = strconv.FormatInt(subItem.ID, 10)
  3632. drug.UsedFrquName = subItem.ExecutionFrequency
  3633. drug.DrugTotlcnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  3634. drug.DrugTotlcntEmp = subItem.PrescribingNumberUnit
  3635. drug.HospApprFlag = "1"
  3636. cFYLJG001.List = append(cFYLJG001.List, drug)
  3637. }
  3638. cFYLJG001.Mdtrtinfo.FixmedinsCode = miConfig.Code
  3639. cFYLJG001.Mdtrtinfo.FixmedinsName = miConfig.Code
  3640. cFYLJG001.Mdtrtinfo.MdtrtID = his.Number
  3641. cFYLJG001.Mdtrtinfo.MedType = item.MedType
  3642. cFYLJG001.Mdtrtinfo.IptOtpNo = his.IptOtpNo
  3643. cFYLJG001.Mdtrtinfo.OtpIptFlag = "1"
  3644. cFYLJG001.Mdtrtinfo.PsnNo = his.PsnNo
  3645. cFYLJG001.Mdtrtinfo.PatnName = his.PsnName
  3646. cFYLJG001.Mdtrtinfo.Certno = his.IdCardNo
  3647. cFYLJG001.Mdtrtinfo.PsnCertType = "01"
  3648. cFYLJG001.Mdtrtinfo.PatnAge = fmt.Sprintf("%.1f", his.Age)
  3649. cFYLJG001.Mdtrtinfo.PatnHgt = "160" //todo
  3650. cFYLJG001.Mdtrtinfo.PatnWt = "58" //todo
  3651. cFYLJG001.Mdtrtinfo.Gend = his.Gend
  3652. cFYLJG001.Mdtrtinfo.PatnAge = fmt.Sprintf("%.1f", his.Age)
  3653. cFYLJG001.Mdtrtinfo.PrscDeptName = "肾内科"
  3654. cFYLJG001.Mdtrtinfo.PrscDeptCode = "A03.06"
  3655. cFYLJG001.Mdtrtinfo.DrCode = doctor.DoctorNumber
  3656. cFYLJG001.Mdtrtinfo.PrscDrName = doctor.UserName
  3657. cFYLJG001.Mdtrtinfo.DrProfttlCodg = "234"
  3658. cFYLJG001.Mdtrtinfo.DrProfttlName = "医师"
  3659. cFYLJG001.Mdtrtinfo.DrDeptCode = "A03.06"
  3660. cFYLJG001.Mdtrtinfo.DrDeptName = "肾内科"
  3661. cFYLJG001.Mdtrtinfo.Caty = "A03.06"
  3662. tempTime2 := time.Now().Unix()
  3663. tempTime6 := time.Unix(tempTime2, 0)
  3664. timeFormatTwo := tempTime6.Format("2006-01-02 15:04:05")
  3665. cFYLJG001.Mdtrtinfo.MdtrtTime = timeFormatTwo
  3666. cFYLJG001.Mdtrtinfo.DiseCodg = "M07803"
  3667. cFYLJG001.Mdtrtinfo.SpDiseFlag = "1"
  3668. cFYLJG001.Mdtrtinfo.MaindiagCode = "N18.500"
  3669. cFYLJG001.Mdtrtinfo.MaindiagName = "慢性肾脏病5期"
  3670. //memo := make(map[string]interface{})
  3671. //inputData := make(map[string]interface{}, 0)
  3672. //type MyData struct {
  3673. // Insutype string `json:"insutype"`
  3674. //}
  3675. //
  3676. // data := MyData{
  3677. // Insutype: his.Insutype,
  3678. //}
  3679. //
  3680. diagnosis_ids := strings.Split(info.Diagnosis, ",")
  3681. var config []*models.HisXtDiagnoseConfig
  3682. for _, item := range diagnosis_ids {
  3683. id, _ := strconv.ParseInt(item, 10, 64)
  3684. diagnosisConfig, _ := service.FindDiagnoseById(id)
  3685. config = append(config, &diagnosisConfig)
  3686. }
  3687. for index, subitem := range config {
  3688. if index == 0 {
  3689. var dia models.DiseInfo
  3690. dia.DiagType = "1"
  3691. dia.MaindiagFlag = "1"
  3692. dia.DiagSrtNo = strconv.FormatInt(int64(index+1), 10)
  3693. dia.DiagCode = subitem.CountryCode
  3694. dia.DiagName = subitem.ClassName
  3695. dia.DiagDept = "肾内科"
  3696. dia.DiagDrNo = doctor.DoctorNumber
  3697. dia.DiagDrName = doctor.UserName
  3698. tempTime3 := time.Unix(item.PreTime, 0)
  3699. timeFormatTwo := tempTime3.Format("2006-01-02 15:04:05")
  3700. dia.DiagTime = timeFormatTwo
  3701. cFYLJG001.Diseinfo = append(cFYLJG001.Diseinfo, dia)
  3702. } else {
  3703. var dia models.DiseInfo
  3704. dia.DiagType = "1"
  3705. dia.MaindiagFlag = "0"
  3706. dia.DiagSrtNo = strconv.FormatInt(int64(index+1), 10)
  3707. dia.DiagCode = subitem.CountryCode
  3708. dia.DiagName = subitem.ClassName
  3709. dia.DiagDept = "肾内科"
  3710. dia.DiagDrNo = doctor.DoctorNumber
  3711. dia.DiagDrName = doctor.UserName
  3712. tempTime3 := time.Unix(item.PreTime, 0)
  3713. timeFormatTwo := tempTime3.Format("2006-01-02 15:04:05")
  3714. dia.DiagTime = timeFormatTwo
  3715. cFYLJG001.Diseinfo = append(cFYLJG001.Diseinfo, dia)
  3716. }
  3717. }
  3718. result, request := service.GetCFYLJG001(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG001, his.Insutype)
  3719. saveLog(result, request, "GetCFYLJG001", "GetCFYLJG001")
  3720. var res ResultCFYLJG001
  3721. var respJSON2 map[string]interface{}
  3722. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  3723. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3724. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3725. return
  3726. }
  3727. userJSONBytes2, _ := json.Marshal(respJSON2)
  3728. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  3729. utils.ErrorLog("解析失败:%v", err)
  3730. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3731. return
  3732. }
  3733. if res.Infcode == -1 {
  3734. c.ServeSuccessJSON(map[string]interface{}{
  3735. "failed_code": -10,
  3736. "msg": res.ErrMsg,
  3737. })
  3738. return
  3739. } else {
  3740. var flow models.HisPrescriptionFlow
  3741. flow.Ctime = time.Now().Unix()
  3742. flow.SignDigest = ""
  3743. flow.RxTraceCode = res.Output.RxTraceCode
  3744. flow.HiRxno = res.Output.HiRxno
  3745. flow.MID = his.Number
  3746. flow.Status = 1
  3747. flow.DCode = doctor_info.DoctorNumber
  3748. flow.OriginalRxFile = ""
  3749. flow.OriginalValue = ""
  3750. flow.SignCertDn = ""
  3751. flow.UserOrgId = 10454
  3752. flow.SignCertSn = ""
  3753. flow.Mtime = time.Now().Unix()
  3754. service.Createflow(&flow)
  3755. c.ServeSuccessJSON(map[string]interface{}{
  3756. "msg": "上传成功",
  3757. })
  3758. }
  3759. }
  3760. }
  3761. func (c *HisApiController) GetCFYLJG002() {
  3762. admin_user_id, _ := c.GetInt64("admin_user_id")
  3763. his_patient_id, _ := c.GetInt64("his_patient_id")
  3764. record_time := c.GetString("record_time")
  3765. admin_user_id = 3626
  3766. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  3767. //id, _ := c.GetInt64("id")
  3768. admin_user_id = 3626
  3769. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3770. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3771. flow, _ := service.Getflowtwo(his.Number)
  3772. //his, _ := service.GetHisPatientByNumber(flow.MID)
  3773. //record_time := c.GetString("record_time")
  3774. patient_id, _ := c.GetInt64("patient_id")
  3775. //patient_id = 23834
  3776. //record_time = "2023-09-18"
  3777. timeLayout := "2006-01-02"
  3778. loc, _ := time.LoadLocation("Local")
  3779. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  3780. if err != nil {
  3781. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  3782. return
  3783. }
  3784. recordDateTime := theTime.Unix()
  3785. //prescriptions, _ := service.GetHisPrescriptionForMedType(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  3786. info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  3787. doctor_info, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, info.DoctorId)
  3788. dept, _ := service.GetDepartMentDetail(info.Departments)
  3789. inputData := make(map[string]interface{})
  3790. inputData["rxTraceCode"] = flow.RxTraceCode
  3791. inputData["hiRxno"] = flow.HiRxno
  3792. inputData["mdtrtId"] = flow.MID
  3793. inputData["patnName"] = his.PsnName
  3794. inputData["psnCertType"] = his.PsnCertType
  3795. inputData["certno"] = his.Certno
  3796. inputData["fixmedinsName"] = miConfig.OrgName
  3797. inputData["fixmedinsCode"] = miConfig.Code
  3798. inputData["drCode"] = doctor_info.DoctorNumber
  3799. inputData["prscDrName"] = doctor_info.UserName
  3800. inputData["pharDeptName"] = dept.Name
  3801. inputData["pharDeptCode"] = dept.Number
  3802. inputData["pharProfttlCodg"] = dept.Name
  3803. inputData["pharProfttlName"] = ""
  3804. inputData["pharCode"] = "HY440309002107"
  3805. inputData["pharCertType"] = "01"
  3806. inputData["pharCertno"] = "430482199408260023"
  3807. inputData["pharName"] = "彭斯遥"
  3808. inputData["pharPracCertNo"] = ""
  3809. tempTime2 := time.Unix(info.Ctime, 0)
  3810. timeFormatTwo := tempTime2.Format("2006-01-02 15:04:05")
  3811. inputData["pharChkTime"] = timeFormatTwo
  3812. bytesData, _ := json.Marshal(inputData)
  3813. fmt.Println(string(bytesData))
  3814. encoded := base64.StdEncoding.EncodeToString(bytesData)
  3815. pdfContent, err := ioutil.ReadFile("signed_data.pdf")
  3816. if err != nil {
  3817. fmt.Println("Error reading PDF file:", err)
  3818. return
  3819. }
  3820. // 将 PDF 文件内容进行 Base64 编码
  3821. rx_encoded := base64.StdEncoding.EncodeToString(pdfContent)
  3822. fmt.Println(err)
  3823. result, request := service.GetCFYLJG002(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, encoded, rx_encoded, "")
  3824. //result, request := service.GetCFYLJG001(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG001,his.Insutype)
  3825. saveLog(result, request, "GetCFYLJG002", "GetCFYLJG002")
  3826. var res2 Result002
  3827. var respJSON2 map[string]interface{}
  3828. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  3829. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3830. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3831. return
  3832. }
  3833. userJSONBytes2, _ := json.Marshal(respJSON2)
  3834. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  3835. utils.ErrorLog("解析失败:%v", err)
  3836. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3837. return
  3838. }
  3839. if res2.Infcode == 0 {
  3840. flow.Ctime = time.Now().Unix()
  3841. flow.SignDigest = res2.Output.SignDigest
  3842. flow.RxFile = res2.Output.RxFile
  3843. flow.MID = his.Number
  3844. flow.Status = 1
  3845. flow.DCode = doctor_info.DoctorNumber
  3846. flow.OriginalRxFile = rx_encoded
  3847. flow.OriginalValue = encoded
  3848. flow.SignCertDn = res2.Output.SignCertDn
  3849. flow.SignCertSn = res2.Output.SignCertSn
  3850. flow.Mtime = time.Now().Unix()
  3851. service.Saveflow(flow)
  3852. c.ServeSuccessJSON(map[string]interface{}{
  3853. "msg": "预签名成功",
  3854. })
  3855. } else {
  3856. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3857. return
  3858. }
  3859. }
  3860. func (c *HisApiController) GetCFYLJG003() {
  3861. admin_user_id, _ := c.GetInt64("admin_user_id")
  3862. his_patient_id, _ := c.GetInt64("his_patient_id")
  3863. record_time := c.GetString("record_time")
  3864. admin_user_id = 3626
  3865. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  3866. //id, _ := c.GetInt64("id")
  3867. admin_user_id = 3626
  3868. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3869. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3870. flow, _ := service.Getflowtwo(his.Number)
  3871. //id = 3
  3872. patient_id, _ := c.GetInt64("patient_id")
  3873. //patient_id = 23834
  3874. //record_time = "2023-09-18"
  3875. timeLayout := "2006-01-02"
  3876. loc, _ := time.LoadLocation("Local")
  3877. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  3878. if err != nil {
  3879. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  3880. return
  3881. }
  3882. recordDateTime := theTime.Unix()
  3883. //prescriptions, _ := service.GetHisPrescriptionForMedType(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  3884. info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  3885. doctor_info, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, info.DoctorId)
  3886. dept, _ := service.GetDepartMentDetail(info.Departments)
  3887. //psn_info,_ := service.GetPsnByPatientId(his.PatientId)
  3888. var cFYLJG003 models.CFYLJG003
  3889. cFYLJG003.RxTraceCode = flow.RxTraceCode
  3890. cFYLJG003.HiRxno = flow.HiRxno
  3891. cFYLJG003.MdtrtID = flow.MID
  3892. cFYLJG003.PatnName = his.Name
  3893. cFYLJG003.Certno = his.Certno
  3894. cFYLJG003.FixmedinsName = miConfig.OrgName
  3895. cFYLJG003.FixmedinsCode = miConfig.Code
  3896. cFYLJG003.DrCode = doctor_info.DoctorNumber
  3897. cFYLJG003.PrscDrName = doctor_info.UserName
  3898. cFYLJG003.PharDeptName = dept.Name
  3899. cFYLJG003.PharDeptCode = dept.Number
  3900. cFYLJG003.PharCode = "HY440309002107"
  3901. cFYLJG003.PharCertType = "01"
  3902. cFYLJG003.PharCertno = "430482199408260023"
  3903. cFYLJG003.PharName = "彭斯遥"
  3904. cFYLJG003.PsnCertType = "01"
  3905. cFYLJG003.RxFile = flow.RxFile
  3906. cFYLJG003.SignDigest = flow.SignDigest
  3907. cFYLJG003.FixmedinsCode = miConfig.Code
  3908. cFYLJG003.PsnCertType = "01"
  3909. cFYLJG003.PharProfttlCodg = dept.Name
  3910. //inputData["pharProfttlCodg"] =dept.Name
  3911. tempTime2 := time.Unix(info.Ctime, 0)
  3912. timeFormatTwo := tempTime2.Format("2006-01-02 15:04:05")
  3913. cFYLJG003.PharChkTime = timeFormatTwo
  3914. result, request := service.GetCFYLJG003(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG003)
  3915. saveLog(result, request, "GetCFYLJG003", "GetCFYLJG003")
  3916. var res ResultCFYLJG003
  3917. var respJSON2 map[string]interface{}
  3918. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  3919. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3920. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3921. return
  3922. }
  3923. userJSONBytes2, _ := json.Marshal(respJSON2)
  3924. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  3925. utils.ErrorLog("解析失败:%v", err)
  3926. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3927. return
  3928. }
  3929. if res.Infcode == -1 {
  3930. c.ServeSuccessJSON(map[string]interface{}{
  3931. "failed_code": -10,
  3932. "msg": res.ErrMsg,
  3933. })
  3934. return
  3935. } else {
  3936. c.ServeSuccessJSON(map[string]interface{}{
  3937. "info": res.Output,
  3938. })
  3939. }
  3940. }
  3941. func (c *HisApiController) GetCFYLJG004() {
  3942. admin_user_id, _ := c.GetInt64("admin_user_id")
  3943. his_patient_id, _ := c.GetInt64("his_patient_id")
  3944. record_time := c.GetString("record_time")
  3945. admin_user_id = 3626
  3946. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  3947. //id, _ := c.GetInt64("id")
  3948. admin_user_id = 3626
  3949. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3950. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3951. flow, _ := service.Getflowtwo(his.Number)
  3952. //id = 3
  3953. patient_id, _ := c.GetInt64("patient_id")
  3954. //patient_id = 23834
  3955. //record_time = "2023-09-18"
  3956. timeLayout := "2006-01-02"
  3957. loc, _ := time.LoadLocation("Local")
  3958. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  3959. if err != nil {
  3960. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  3961. return
  3962. }
  3963. recordDateTime := theTime.Unix()
  3964. info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  3965. doctor_info, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, info.DoctorId)
  3966. var cFYLJG004 models.CFYLJG004
  3967. cFYLJG004.HiRxno = flow.HiRxno
  3968. cFYLJG004.FixmedinsCode = miConfig.Code
  3969. cFYLJG004.UndoDrCertno = doctor_info.IdCard
  3970. cFYLJG004.UndoDrCertType = "01"
  3971. cFYLJG004.UndoRea = "撤销处方"
  3972. cFYLJG004.UndoTime = time.Now().Format("2006-01-02 15:04:05")
  3973. cFYLJG004.UndoDrName = doctor_info.UserName
  3974. cFYLJG004.UndoDrCode = doctor_info.DoctorNumber
  3975. result, request := service.GetCFYLJG004(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG004)
  3976. saveLog(result, request, "GetCFYLJG004", "GetCFYLJG004")
  3977. var res ResultCFYLJG004
  3978. var respJSON2 map[string]interface{}
  3979. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  3980. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3981. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3982. return
  3983. }
  3984. userJSONBytes2, _ := json.Marshal(respJSON2)
  3985. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  3986. utils.ErrorLog("解析失败:%v", err)
  3987. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3988. return
  3989. }
  3990. if res.Infcode == -1 {
  3991. c.ServeSuccessJSON(map[string]interface{}{
  3992. "failed_code": -10,
  3993. "msg": res.ErrMsg,
  3994. })
  3995. return
  3996. } else {
  3997. flow.Status = 0
  3998. service.Saveflow(flow)
  3999. c.ServeSuccessJSON(map[string]interface{}{
  4000. "msg": "撤销成功",
  4001. })
  4002. return
  4003. }
  4004. }
  4005. func (c *HisApiController) GetCFYLJG005() {
  4006. admin_user_id, _ := c.GetInt64("admin_user_id")
  4007. his_patient_id, _ := c.GetInt64("his_patient_id")
  4008. //record_time := c.GetString("record_time")
  4009. admin_user_id = 3626
  4010. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  4011. //id, _ := c.GetInt64("id")
  4012. admin_user_id = 3626
  4013. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  4014. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  4015. flow, _ := service.Getflowtwo(his.Number)
  4016. //id = 3
  4017. var cFYLJG005 models.CFYLJG005
  4018. //patient_id, _ := c.GetInt64("patient_id")
  4019. cFYLJG005.HiRxno = flow.HiRxno
  4020. cFYLJG005.MdtrtID = flow.MID
  4021. cFYLJG005.EcToken = ""
  4022. cFYLJG005.PsnName = his.Name
  4023. cFYLJG005.PsnCertType = "01"
  4024. cFYLJG005.Certno = his.IdCardNo
  4025. result, request := service.GetCFYLJG005(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG005)
  4026. saveLog(result, request, "GetCFYLJG005", "GetCFYLJG005")
  4027. var res ResultCFYLJG005
  4028. var respJSON2 map[string]interface{}
  4029. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  4030. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4031. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4032. return
  4033. }
  4034. userJSONBytes2, _ := json.Marshal(respJSON2)
  4035. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  4036. utils.ErrorLog("解析失败:%v", err)
  4037. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4038. return
  4039. }
  4040. if res.Infcode == -1 {
  4041. c.ServeSuccessJSON(map[string]interface{}{
  4042. "failed_code": -10,
  4043. "msg": res.ErrMsg,
  4044. })
  4045. return
  4046. } else {
  4047. c.ServeSuccessJSON(map[string]interface{}{
  4048. "info": res.Output,
  4049. })
  4050. return
  4051. }
  4052. }
  4053. func (c *HisApiController) GetCFYLJG006() {
  4054. admin_user_id, _ := c.GetInt64("admin_user_id")
  4055. his_patient_id, _ := c.GetInt64("his_patient_id")
  4056. admin_user_id = 3626
  4057. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  4058. //id, _ := c.GetInt64("id")
  4059. admin_user_id = 3626
  4060. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  4061. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  4062. flow, _ := service.Getflowtwo(his.Number)
  4063. //id = 3
  4064. patient_id, _ := c.GetInt64("patient_id")
  4065. var cFYLJG006 models.CFYLJG006
  4066. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, patient_id)
  4067. cFYLJG006.HiRxno = flow.HiRxno
  4068. cFYLJG006.MdtrtID = flow.MID
  4069. cFYLJG006.PsnName = patient.Name
  4070. cFYLJG006.PsnCertType = "01"
  4071. cFYLJG006.Certno = patient.IdCardNo
  4072. result, request := service.GetCFYLJG006(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG006)
  4073. saveLog(result, request, "GetCFYLJG006", "GetCFYLJG006")
  4074. var res ResultCFYLJG006
  4075. var respJSON2 map[string]interface{}
  4076. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  4077. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4078. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4079. return
  4080. }
  4081. userJSONBytes2, _ := json.Marshal(respJSON2)
  4082. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  4083. utils.ErrorLog("解析失败:%v", err)
  4084. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4085. return
  4086. }
  4087. if res.Infcode == -1 {
  4088. c.ServeSuccessJSON(map[string]interface{}{
  4089. "failed_code": -10,
  4090. "msg": res.ErrMsg,
  4091. })
  4092. return
  4093. } else {
  4094. c.ServeSuccessJSON(map[string]interface{}{
  4095. "info": res.Output,
  4096. })
  4097. return
  4098. }
  4099. }
  4100. func (c *HisApiController) GetCFYLJG007() {
  4101. admin_user_id, _ := c.GetInt64("admin_user_id")
  4102. his_patient_id, _ := c.GetInt64("his_patient_id")
  4103. admin_user_id = 3626
  4104. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  4105. //id, _ := c.GetInt64("id")
  4106. admin_user_id = 3626
  4107. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  4108. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  4109. flow, _ := service.Getflowtwo(his.Number)
  4110. //id = 3
  4111. patient_id, _ := c.GetInt64("patient_id")
  4112. var cFYLJG007 models.CFYLJG007
  4113. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, patient_id)
  4114. //his, _ := service.GetHisPatient(c.GetAdminUserInfo().CurrentOrgId,patient_id)
  4115. cFYLJG007.HiRxno = flow.HiRxno
  4116. cFYLJG007.MdtrtID = flow.MID
  4117. cFYLJG007.PsnNo = his.PsnNo
  4118. cFYLJG007.PsnCertType = "01"
  4119. cFYLJG007.Certno = patient.IdCardNo
  4120. cFYLJG007.PsnName = patient.Name
  4121. result, request := service.GetCFYLJG007(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG007)
  4122. saveLog(result, request, "GetCFYLJG007", "GetCFYLJG007")
  4123. var res ResultCFYLJG007
  4124. var respJSON2 map[string]interface{}
  4125. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  4126. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4127. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4128. return
  4129. }
  4130. userJSONBytes2, _ := json.Marshal(respJSON2)
  4131. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  4132. utils.ErrorLog("解析失败:%v", err)
  4133. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4134. return
  4135. }
  4136. if res.Infcode == -1 {
  4137. c.ServeSuccessJSON(map[string]interface{}{
  4138. "failed_code": -10,
  4139. "msg": res.ErrMsg,
  4140. })
  4141. return
  4142. } else {
  4143. c.ServeSuccessJSON(map[string]interface{}{
  4144. "info": res,
  4145. })
  4146. return
  4147. }
  4148. }
  4149. func (c *HisApiController) GetCFYLJG008() {
  4150. admin_user_id, _ := c.GetInt64("admin_user_id")
  4151. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  4152. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  4153. var cFYLJG008 models.CFYLJG008
  4154. //id, _ := c.GetInt64("id")
  4155. patient_id, _ := c.GetInt64("patient_id")
  4156. //patient, _ := service.G/etPatientByID(c.GetAdminUserInfo().CurrentOrgId,patient_id)
  4157. //his, _ := service.GetHisPatient(c.GetAdminUserInfo().CurrentOrgId,patient_id)
  4158. //id = 3
  4159. //flow, _ := service.Getflow(id)
  4160. //his, _ := service.GetHisPatientByNumber(flow.MID)
  4161. //
  4162. //admin_user_id, _ := c.GetInt64("admin_user_id")
  4163. //patient_id, _ := c.GetInt64("patient_id")
  4164. //his_patient_id, _ := c.GetInt64("his_patient_id")
  4165. record_time := c.GetString("record_time")
  4166. admin_user_id = 3626
  4167. patient_id = 19424
  4168. //his_patient_id = 263947
  4169. record_time = "2023-08-29"
  4170. timeLayout := "2006-01-02"
  4171. loc, _ := time.LoadLocation("Local")
  4172. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  4173. if err != nil {
  4174. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4175. return
  4176. }
  4177. recordDateTime := theTime.Unix()
  4178. prescriptions, _ := service.GetHisPrescriptionForMedType(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  4179. cFYLJG008.FixmedinsName = ""
  4180. cFYLJG008.Lat = ""
  4181. cFYLJG008.Lng = ""
  4182. cFYLJG008.OrderType = "1"
  4183. cFYLJG008.PoolareaNo = ""
  4184. cFYLJG008.Lng = ""
  4185. cFYLJG008.PageNum = 1
  4186. cFYLJG008.PageSize = 10
  4187. var MPI models.MedinsProdInvChgDDTO
  4188. MPI.MedListCodg = prescriptions[0].HisDoctorAdviceInfo[0].MedListCodg
  4189. MPI.Cnt = prescriptions[0].HisDoctorAdviceInfo[0].PrescribingNumber
  4190. cFYLJG008.MedList = append(cFYLJG008.MedList, MPI)
  4191. result, request := service.GetCFYLJG008(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG008)
  4192. saveLog(result, request, "GetCFYLJG008", "GetCFYLJG008")
  4193. var res ResultCFYLJG008
  4194. var respJSON2 map[string]interface{}
  4195. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  4196. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4197. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4198. return
  4199. }
  4200. userJSONBytes2, _ := json.Marshal(respJSON2)
  4201. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  4202. utils.ErrorLog("解析失败:%v", err)
  4203. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4204. return
  4205. }
  4206. if res.Infcode == -1 {
  4207. c.ServeSuccessJSON(map[string]interface{}{
  4208. "failed_code": -10,
  4209. "msg": res.ErrMsg,
  4210. })
  4211. return
  4212. } else {
  4213. c.ServeSuccessJSON(map[string]interface{}{
  4214. "info": res.Output,
  4215. })
  4216. return
  4217. }
  4218. }
  4219. func (c *HisApiController) GetBL4201A() {
  4220. order_id, _ := c.GetInt64("order_id")
  4221. admin_user_id, _ := c.GetInt64("admin_user_id")
  4222. order, _ := service.GetHisOrderByIDTwo(order_id)
  4223. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  4224. order_info, _ := service.GetHisOrderInfoByNumber(order.MdtrtId)
  4225. order_info_two, _ := service.GetHisOrderInfoByNumberTwo(order.MdtrtId)
  4226. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  4227. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  4228. department, _ := service.GetDepartMentDetail(his.Departments)
  4229. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  4230. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  4231. if order.ID == 0 {
  4232. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  4233. return
  4234. }
  4235. var struct4201A models.Struct4201A
  4236. var fsiOPFLDs []models.FsiOwnpayPatnFeeListDDTO
  4237. for _, items := range order_info {
  4238. memo := make(map[string]interface{})
  4239. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  4240. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  4241. fsiOPFLD.MedType = "14"
  4242. fsiOPFLD.BkkpSn = items.FeedetlSn
  4243. fsiOPFLD.FixmedinsCode = miConfig.Code
  4244. fsiOPFLD.FixmedinsName = miConfig.OrgName
  4245. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  4246. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  4247. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  4248. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  4249. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  4250. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  4251. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  4252. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  4253. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  4254. fsiOPFLD.BilgDeptName = department.Name
  4255. fsiOPFLD.BilgDeptCodg = department.Number
  4256. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  4257. fsiOPFLD.BilgDrName = doctor.UserName
  4258. fsiOPFLD.MedChrgitmType = "09"
  4259. memo["hosp_appr_flag"] = "1"
  4260. memo["invoice_no"] = order.MdtrtId
  4261. memo["memo"] = "自费"
  4262. bytesData, _ := json.Marshal(memo)
  4263. fsiOPFLD.Memo = string(bytesData)
  4264. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  4265. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  4266. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  4267. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  4268. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  4269. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  4270. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  4271. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  4272. fsiOPFLD.BilgDeptName = department.Name
  4273. fsiOPFLD.BilgDeptCodg = department.Number
  4274. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  4275. fsiOPFLD.BilgDrName = doctor.UserName
  4276. switch items.HisPrescriptionProject.HisProject.CostClassify {
  4277. case 0:
  4278. break
  4279. case 1:
  4280. fsiOPFLD.MedChrgitmType = "14"
  4281. break
  4282. case 2:
  4283. fsiOPFLD.MedChrgitmType = "05"
  4284. break
  4285. case 3:
  4286. fsiOPFLD.MedChrgitmType = "03"
  4287. break
  4288. case 4:
  4289. fsiOPFLD.MedChrgitmType = "03"
  4290. break
  4291. case 5:
  4292. fsiOPFLD.MedChrgitmType = "08"
  4293. break
  4294. case 6:
  4295. fsiOPFLD.MedChrgitmType = "14"
  4296. break
  4297. case 7:
  4298. fsiOPFLD.MedChrgitmType = "14"
  4299. break
  4300. case 8:
  4301. fsiOPFLD.MedChrgitmType = "03"
  4302. break
  4303. case 9:
  4304. fsiOPFLD.MedChrgitmType = "14"
  4305. break
  4306. case 10:
  4307. fsiOPFLD.MedChrgitmType = "14"
  4308. break
  4309. case 11:
  4310. fsiOPFLD.MedChrgitmType = "06"
  4311. break
  4312. case 12:
  4313. fsiOPFLD.MedChrgitmType = "12"
  4314. break
  4315. case 13:
  4316. fsiOPFLD.MedChrgitmType = "01"
  4317. break
  4318. case 14:
  4319. fsiOPFLD.MedChrgitmType = "04"
  4320. break
  4321. case 15:
  4322. fsiOPFLD.MedChrgitmType = "14"
  4323. break
  4324. }
  4325. memo["hosp_appr_flag"] = "1"
  4326. memo["invoice_no"] = order.MdtrtId
  4327. memo["memo"] = "自费"
  4328. bytesData, _ := json.Marshal(memo)
  4329. fsiOPFLD.Memo = string(bytesData)
  4330. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  4331. } else if items.HisPrescriptionProject.Type == 3 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 {
  4332. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  4333. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  4334. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  4335. fsiOPFLD.BilgDeptName = department.Name
  4336. fsiOPFLD.BilgDeptCodg = department.Number
  4337. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  4338. fsiOPFLD.BilgDrName = doctor.UserName
  4339. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  4340. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  4341. fsiOPFLD.MedChrgitmType = "08"
  4342. memo["hosp_appr_flag"] = "1"
  4343. memo["invoice_no"] = order.MdtrtId
  4344. memo["memo"] = "自费"
  4345. bytesData, _ := json.Marshal(memo)
  4346. fsiOPFLD.Memo = string(bytesData)
  4347. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  4348. }
  4349. }
  4350. }
  4351. for _, items := range order_info_two {
  4352. memo := make(map[string]interface{})
  4353. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  4354. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  4355. fsiOPFLD.MedType = "14"
  4356. fsiOPFLD.BkkpSn = items.FeedetlSn
  4357. fsiOPFLD.FixmedinsCode = miConfig.Code
  4358. fsiOPFLD.FixmedinsName = miConfig.OrgName
  4359. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  4360. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  4361. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  4362. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  4363. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  4364. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  4365. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  4366. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  4367. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  4368. fsiOPFLD.BilgDeptName = department.Name
  4369. fsiOPFLD.BilgDeptCodg = department.Number
  4370. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  4371. fsiOPFLD.BilgDrName = doctor.UserName
  4372. fsiOPFLD.MedChrgitmType = "09"
  4373. memo["hosp_appr_flag"] = "1"
  4374. memo["invoice_no"] = order.MdtrtId
  4375. memo["memo"] = "自费"
  4376. bytesData, _ := json.Marshal(memo)
  4377. fsiOPFLD.Memo = string(bytesData)
  4378. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  4379. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  4380. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  4381. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  4382. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  4383. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  4384. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  4385. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  4386. fsiOPFLD.BilgDeptName = department.Name
  4387. fsiOPFLD.BilgDeptCodg = department.Number
  4388. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  4389. fsiOPFLD.BilgDrName = doctor.UserName
  4390. switch items.HisPrescriptionProject.HisProject.CostClassify {
  4391. case 0:
  4392. break
  4393. case 1:
  4394. fsiOPFLD.MedChrgitmType = "14"
  4395. break
  4396. case 2:
  4397. fsiOPFLD.MedChrgitmType = "05"
  4398. break
  4399. case 3:
  4400. fsiOPFLD.MedChrgitmType = "03"
  4401. break
  4402. case 4:
  4403. fsiOPFLD.MedChrgitmType = "03"
  4404. break
  4405. case 5:
  4406. fsiOPFLD.MedChrgitmType = "08"
  4407. break
  4408. case 6:
  4409. fsiOPFLD.MedChrgitmType = "14"
  4410. break
  4411. case 7:
  4412. fsiOPFLD.MedChrgitmType = "14"
  4413. break
  4414. case 8:
  4415. fsiOPFLD.MedChrgitmType = "03"
  4416. break
  4417. case 9:
  4418. fsiOPFLD.MedChrgitmType = "14"
  4419. break
  4420. case 10:
  4421. fsiOPFLD.MedChrgitmType = "14"
  4422. break
  4423. case 11:
  4424. fsiOPFLD.MedChrgitmType = "06"
  4425. break
  4426. case 12:
  4427. fsiOPFLD.MedChrgitmType = "12"
  4428. break
  4429. case 13:
  4430. fsiOPFLD.MedChrgitmType = "01"
  4431. break
  4432. case 14:
  4433. fsiOPFLD.MedChrgitmType = "04"
  4434. break
  4435. case 15:
  4436. fsiOPFLD.MedChrgitmType = "14"
  4437. break
  4438. }
  4439. memo["hosp_appr_flag"] = "1"
  4440. memo["invoice_no"] = order.MdtrtId
  4441. memo["memo"] = "自费"
  4442. bytesData, _ := json.Marshal(memo)
  4443. fsiOPFLD.Memo = string(bytesData)
  4444. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  4445. } else if items.HisPrescriptionProject.Type == 3 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 {
  4446. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  4447. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  4448. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  4449. fsiOPFLD.BilgDeptName = department.Name
  4450. fsiOPFLD.BilgDeptCodg = department.Number
  4451. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  4452. fsiOPFLD.BilgDrName = doctor.UserName
  4453. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  4454. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  4455. fsiOPFLD.MedChrgitmType = "08"
  4456. memo["hosp_appr_flag"] = "1"
  4457. memo["invoice_no"] = order.MdtrtId
  4458. memo["memo"] = "自费"
  4459. bytesData, _ := json.Marshal(memo)
  4460. fsiOPFLD.Memo = string(bytesData)
  4461. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  4462. }
  4463. }
  4464. }
  4465. fmt.Println(fsiOPFLDs)
  4466. struct4201A.Fopfd = fsiOPFLDs
  4467. fmt.Println(struct4201A.Fopfd)
  4468. result, requestLog := service.Gdyb4201A(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4201A)
  4469. saveLog(result, requestLog, "4201A", "自费费用明细上传")
  4470. var res2 ResultSix
  4471. var respJSON2 map[string]interface{}
  4472. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  4473. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4474. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4475. return
  4476. }
  4477. userJSONBytes2, _ := json.Marshal(respJSON2)
  4478. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  4479. utils.ErrorLog("解析失败:%v", err)
  4480. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4481. return
  4482. }
  4483. if res2.Infcode != 0 {
  4484. c.ServeSuccessJSON(map[string]interface{}{
  4485. "failed_code": -10,
  4486. "msg": res2.ErrMsg,
  4487. })
  4488. return
  4489. } else {
  4490. order.IsUploadOrderInfo = 1
  4491. service.UpdateOrder(order)
  4492. c.ServeSuccessJSON(map[string]interface{}{
  4493. "msg": "上传成功",
  4494. })
  4495. }
  4496. }
  4497. func (c *HisApiController) Get2505() {
  4498. admin_user_id, _ := c.GetInt64("admin_user_id")
  4499. miConfig, _ := service.FindMedicalInsuranceInfo(10375)
  4500. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  4501. 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)
  4502. }
  4503. func (c *HisApiController) Get4201A() {
  4504. order_id, _ := c.GetInt64("order_id")
  4505. admin_user_id, _ := c.GetInt64("admin_user_id")
  4506. order, _ := service.GetHisOrderByIDTwo(order_id)
  4507. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  4508. order_info, _ := service.GetHisOrderInfoByNumber(order.MdtrtId)
  4509. order_info_two, _ := service.GetHisOrderInfoByNumberTwo(order.MdtrtId)
  4510. //order_info = append(order_info, order_info_two...)
  4511. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  4512. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  4513. department, _ := service.GetDepartMentDetail(his.Departments)
  4514. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  4515. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  4516. if order.ID == 0 {
  4517. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  4518. return
  4519. }
  4520. var struct4201A models.Struct4201A
  4521. var fsiOPFLDs []models.FsiOwnpayPatnFeeListDDTO
  4522. for _, items := range order_info {
  4523. memo := make(map[string]interface{})
  4524. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  4525. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  4526. fsiOPFLD.MedType = "14"
  4527. fsiOPFLD.BkkpSn = items.FeedetlSn
  4528. fsiOPFLD.FixmedinsCode = miConfig.Code
  4529. fsiOPFLD.FixmedinsName = miConfig.OrgName
  4530. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  4531. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  4532. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  4533. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  4534. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  4535. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  4536. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  4537. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  4538. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  4539. fsiOPFLD.BilgDeptName = department.Name
  4540. fsiOPFLD.BilgDeptCodg = department.Number
  4541. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  4542. fsiOPFLD.BilgDrName = doctor.UserName
  4543. fsiOPFLD.MedChrgitmType = "09"
  4544. memo["hosp_appr_flag"] = "1"
  4545. memo["invoice_no"] = order.MdtrtId
  4546. memo["memo"] = "自费"
  4547. bytesData, _ := json.Marshal(memo)
  4548. fsiOPFLD.Memo = string(bytesData)
  4549. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  4550. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  4551. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  4552. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  4553. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  4554. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  4555. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  4556. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  4557. fsiOPFLD.BilgDeptName = department.Name
  4558. fsiOPFLD.BilgDeptCodg = department.Number
  4559. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  4560. fsiOPFLD.BilgDrName = doctor.UserName
  4561. switch items.HisPrescriptionProject.HisProject.CostClassify {
  4562. case 0:
  4563. break
  4564. case 1:
  4565. fsiOPFLD.MedChrgitmType = "14"
  4566. break
  4567. case 2:
  4568. fsiOPFLD.MedChrgitmType = "05"
  4569. break
  4570. case 3:
  4571. fsiOPFLD.MedChrgitmType = "03"
  4572. break
  4573. case 4:
  4574. fsiOPFLD.MedChrgitmType = "03"
  4575. break
  4576. case 5:
  4577. fsiOPFLD.MedChrgitmType = "08"
  4578. break
  4579. case 6:
  4580. fsiOPFLD.MedChrgitmType = "14"
  4581. break
  4582. case 7:
  4583. fsiOPFLD.MedChrgitmType = "14"
  4584. break
  4585. case 8:
  4586. fsiOPFLD.MedChrgitmType = "03"
  4587. break
  4588. case 9:
  4589. fsiOPFLD.MedChrgitmType = "14"
  4590. break
  4591. case 10:
  4592. fsiOPFLD.MedChrgitmType = "14"
  4593. break
  4594. case 11:
  4595. fsiOPFLD.MedChrgitmType = "06"
  4596. break
  4597. case 12:
  4598. fsiOPFLD.MedChrgitmType = "12"
  4599. break
  4600. case 13:
  4601. fsiOPFLD.MedChrgitmType = "01"
  4602. break
  4603. case 14:
  4604. fsiOPFLD.MedChrgitmType = "04"
  4605. break
  4606. case 15:
  4607. fsiOPFLD.MedChrgitmType = "14"
  4608. break
  4609. }
  4610. memo["hosp_appr_flag"] = "1"
  4611. memo["invoice_no"] = order.MdtrtId
  4612. memo["memo"] = "自费"
  4613. bytesData, _ := json.Marshal(memo)
  4614. fsiOPFLD.Memo = string(bytesData)
  4615. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  4616. } else if items.HisPrescriptionProject.Type == 3 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 {
  4617. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  4618. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  4619. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  4620. fsiOPFLD.BilgDeptName = department.Name
  4621. fsiOPFLD.BilgDeptCodg = department.Number
  4622. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  4623. fsiOPFLD.BilgDrName = doctor.UserName
  4624. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  4625. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  4626. fsiOPFLD.MedChrgitmType = "08"
  4627. memo["hosp_appr_flag"] = "1"
  4628. memo["invoice_no"] = order.MdtrtId
  4629. memo["memo"] = "自费"
  4630. bytesData, _ := json.Marshal(memo)
  4631. fsiOPFLD.Memo = string(bytesData)
  4632. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  4633. }
  4634. }
  4635. }
  4636. for _, items := range order_info_two {
  4637. memo := make(map[string]interface{})
  4638. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  4639. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  4640. fsiOPFLD.MedType = "14"
  4641. fsiOPFLD.BkkpSn = items.FeedetlSn
  4642. fsiOPFLD.FixmedinsCode = miConfig.Code
  4643. fsiOPFLD.FixmedinsName = miConfig.OrgName
  4644. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  4645. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  4646. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  4647. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  4648. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  4649. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  4650. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  4651. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  4652. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  4653. fsiOPFLD.BilgDeptName = department.Name
  4654. fsiOPFLD.BilgDeptCodg = department.Number
  4655. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  4656. fsiOPFLD.BilgDrName = doctor.UserName
  4657. fsiOPFLD.MedChrgitmType = "09"
  4658. memo["hosp_appr_flag"] = "1"
  4659. memo["invoice_no"] = order.MdtrtId
  4660. memo["memo"] = "自费"
  4661. bytesData, _ := json.Marshal(memo)
  4662. fsiOPFLD.Memo = string(bytesData)
  4663. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  4664. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  4665. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  4666. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  4667. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  4668. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  4669. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  4670. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  4671. fsiOPFLD.BilgDeptName = department.Name
  4672. fsiOPFLD.BilgDeptCodg = department.Number
  4673. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  4674. fsiOPFLD.BilgDrName = doctor.UserName
  4675. switch items.HisPrescriptionProject.HisProject.CostClassify {
  4676. case 0:
  4677. break
  4678. case 1:
  4679. fsiOPFLD.MedChrgitmType = "14"
  4680. break
  4681. case 2:
  4682. fsiOPFLD.MedChrgitmType = "05"
  4683. break
  4684. case 3:
  4685. fsiOPFLD.MedChrgitmType = "03"
  4686. break
  4687. case 4:
  4688. fsiOPFLD.MedChrgitmType = "03"
  4689. break
  4690. case 5:
  4691. fsiOPFLD.MedChrgitmType = "08"
  4692. break
  4693. case 6:
  4694. fsiOPFLD.MedChrgitmType = "14"
  4695. break
  4696. case 7:
  4697. fsiOPFLD.MedChrgitmType = "14"
  4698. break
  4699. case 8:
  4700. fsiOPFLD.MedChrgitmType = "03"
  4701. break
  4702. case 9:
  4703. fsiOPFLD.MedChrgitmType = "14"
  4704. break
  4705. case 10:
  4706. fsiOPFLD.MedChrgitmType = "14"
  4707. break
  4708. case 11:
  4709. fsiOPFLD.MedChrgitmType = "06"
  4710. break
  4711. case 12:
  4712. fsiOPFLD.MedChrgitmType = "12"
  4713. break
  4714. case 13:
  4715. fsiOPFLD.MedChrgitmType = "01"
  4716. break
  4717. case 14:
  4718. fsiOPFLD.MedChrgitmType = "04"
  4719. break
  4720. case 15:
  4721. fsiOPFLD.MedChrgitmType = "14"
  4722. break
  4723. }
  4724. memo["hosp_appr_flag"] = "1"
  4725. memo["invoice_no"] = order.MdtrtId
  4726. memo["memo"] = "自费"
  4727. bytesData, _ := json.Marshal(memo)
  4728. fsiOPFLD.Memo = string(bytesData)
  4729. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  4730. } else if items.HisPrescriptionProject.Type == 3 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 {
  4731. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  4732. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  4733. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  4734. fsiOPFLD.BilgDeptName = department.Name
  4735. fsiOPFLD.BilgDeptCodg = department.Number
  4736. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  4737. fsiOPFLD.BilgDrName = doctor.UserName
  4738. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  4739. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  4740. fsiOPFLD.MedChrgitmType = "08"
  4741. memo["hosp_appr_flag"] = "1"
  4742. memo["invoice_no"] = order.MdtrtId
  4743. memo["memo"] = "自费"
  4744. bytesData, _ := json.Marshal(memo)
  4745. fsiOPFLD.Memo = string(bytesData)
  4746. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  4747. }
  4748. }
  4749. }
  4750. fmt.Println(fsiOPFLDs)
  4751. struct4201A.Fopfd = fsiOPFLDs
  4752. fmt.Println(struct4201A.Fopfd)
  4753. result, requestLog := service.Gdyb4201A(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4201A)
  4754. saveLog(result, requestLog, "4201A", "自费费用明细上传")
  4755. var res2 ResultSix
  4756. var respJSON2 map[string]interface{}
  4757. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  4758. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4759. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4760. return
  4761. }
  4762. userJSONBytes2, _ := json.Marshal(respJSON2)
  4763. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  4764. utils.ErrorLog("解析失败:%v", err)
  4765. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4766. return
  4767. }
  4768. if res2.Infcode != 0 {
  4769. c.ServeSuccessJSON(map[string]interface{}{
  4770. "failed_code": -10,
  4771. "msg": res2.ErrMsg,
  4772. })
  4773. return
  4774. } else {
  4775. order.IsUploadOrderInfo = 1
  4776. service.UpdateOrder(order)
  4777. c.ServeSuccessJSON(map[string]interface{}{
  4778. "msg": "上传成功",
  4779. })
  4780. }
  4781. }
  4782. func (c *HisApiController) Get4202() {
  4783. order_id, _ := c.GetInt64("order_id")
  4784. admin_user_id, _ := c.GetInt64("admin_user_id")
  4785. order, _ := service.GetHisOrderByIDTwo(order_id)
  4786. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  4787. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  4788. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  4789. if order.ID == 0 {
  4790. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  4791. return
  4792. }
  4793. var struct4202 models.Struct4202
  4794. struct4202.OwnPayPatnMdtrtD.FixmedinsMdtrtID = his.Number
  4795. struct4202.OwnPayPatnMdtrtD.FixmedinsCode = miConfig.Code
  4796. struct4202.OwnPayPatnMdtrtD.FixmedinsName = miConfig.OrgName
  4797. struct4202.OwnPayPatnMdtrtD.PsnCertType = "01"
  4798. struct4202.OwnPayPatnMdtrtD.Certno = his.IdCardNo
  4799. struct4202.OwnPayPatnMdtrtD.PsnName = his.Name
  4800. struct4202.OwnPayPatnMdtrtD.Begntime = his.InHosptialTime
  4801. struct4202.OwnPayPatnMdtrtD.MedType = "14"
  4802. struct4202.OwnPayPatnMdtrtD.ValiFlag = "1"
  4803. struct4202.OwnPayPatnMdtrtD.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  4804. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  4805. var config []*models.HisXtDiagnoseConfig
  4806. for _, item := range diagnosis_ids {
  4807. id, _ := strconv.ParseInt(item, 10, 64)
  4808. diagnosisConfig, _ := service.FindDiagnoseById(id)
  4809. config = append(config, &diagnosisConfig)
  4810. }
  4811. var tempDiaginfos []models.OwnPayPatnDiagListD
  4812. for index, item := range config {
  4813. if index == 0 {
  4814. var tempDiaginfo models.OwnPayPatnDiagListD
  4815. tempDiaginfo.InoutDiagType = "1"
  4816. tempDiaginfo.DiagCode = item.CountryCode
  4817. tempDiaginfo.DiagName = item.CountryContentName
  4818. tempDiaginfo.DiagType = "1"
  4819. tempDiaginfo.DiagSrtNo = "1"
  4820. tempDiaginfo.MaindiagFlag = "1"
  4821. tempDiaginfo.ValiFlag = "1"
  4822. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  4823. } else {
  4824. var tempDiaginfo models.OwnPayPatnDiagListD
  4825. tempDiaginfo.DiagCode = item.CountryCode
  4826. tempDiaginfo.DiagName = item.CountryContentName
  4827. tempDiaginfo.DiagType = "2"
  4828. tempDiaginfo.DiagSrtNo = strconv.FormatInt(int64(index+1), 10)
  4829. tempDiaginfo.MaindiagFlag = "0"
  4830. tempDiaginfo.ValiFlag = "1"
  4831. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  4832. }
  4833. }
  4834. struct4202.ODiagListD = tempDiaginfos
  4835. result, requestLog := service.Gdyb4202(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4202)
  4836. saveLog(result, requestLog, "4202", "自费就诊和诊断信息上传")
  4837. var res2 ResultSix
  4838. var respJSON2 map[string]interface{}
  4839. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  4840. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4841. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4842. return
  4843. }
  4844. userJSONBytes2, _ := json.Marshal(respJSON2)
  4845. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  4846. utils.ErrorLog("解析失败:%v", err)
  4847. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4848. return
  4849. }
  4850. if res2.Infcode != 0 {
  4851. c.ServeSuccessJSON(map[string]interface{}{
  4852. "failed_code": -10,
  4853. "msg": res2.ErrMsg,
  4854. })
  4855. return
  4856. } else {
  4857. order.IsUploadDiagnose = 1
  4858. service.UpdateOrder(order)
  4859. c.ServeSuccessJSON(map[string]interface{}{
  4860. "msg": "上传成功",
  4861. })
  4862. }
  4863. }
  4864. func (c *HisApiController) Get4203() {
  4865. admin_user_id, _ := c.GetInt64("admin_user_id")
  4866. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  4867. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  4868. order_id, _ := c.GetInt64("order_id")
  4869. order, _ := service.GetHisOrderByIDTwo1111(order_id)
  4870. number := ""
  4871. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  4872. hospital, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  4873. if his.ID == 0 {
  4874. number = hospital.Number
  4875. } else {
  4876. number = his.Number
  4877. }
  4878. result, requestLog := service.Gdyb4203(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, number)
  4879. saveLog(result, requestLog, "4203", "自费就诊与结算明细上传完成")
  4880. var res2 ResultSix
  4881. var respJSON2 map[string]interface{}
  4882. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  4883. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4884. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4885. return
  4886. }
  4887. userJSONBytes2, _ := json.Marshal(respJSON2)
  4888. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  4889. utils.ErrorLog("解析失败:%v", err)
  4890. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4891. return
  4892. }
  4893. if res2.Infcode != 0 {
  4894. c.ServeSuccessJSON(map[string]interface{}{
  4895. "failed_code": -10,
  4896. "msg": res2.ErrMsg,
  4897. })
  4898. return
  4899. } else {
  4900. order.IsUploadSuccess = 1
  4901. service.UpdateOrderTwo(order)
  4902. c.ServeSuccessJSON(map[string]interface{}{
  4903. "msg": "上传成功",
  4904. })
  4905. }
  4906. }
  4907. func (c *HisApiController) Get4205() {
  4908. order_id, _ := c.GetInt64("order_id")
  4909. admin_user_id, _ := c.GetInt64("admin_user_id")
  4910. fapiao_code := c.GetString("fapiao_code")
  4911. order, _ := service.GetHisOrderByIDTwo1111(order_id)
  4912. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  4913. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  4914. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  4915. order_info, _ := service.GetHisOrderInfoByNumber(order.Number)
  4916. order_info_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  4917. //order_info = append(order_info, order_info_two...)
  4918. department, _ := service.GetDepartMentDetail(his.Departments)
  4919. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  4920. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  4921. if order.ID == 0 {
  4922. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  4923. return
  4924. }
  4925. var struct4201A models.Struct4201A
  4926. var fsiOPFLDs []models.FsiOwnpayPatnFeeListDDTO
  4927. for _, items := range order_info {
  4928. memo := make(map[string]interface{})
  4929. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  4930. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  4931. fsiOPFLD.MedType = pre.MedType
  4932. fsiOPFLD.FixmedinsCode = miConfig.Code
  4933. fsiOPFLD.FixmedinsName = miConfig.OrgName
  4934. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  4935. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  4936. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  4937. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  4938. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  4939. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  4940. fsiOPFLD.BkkpSn = items.HisDoctorAdviceInfo.FeedetlSn
  4941. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  4942. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  4943. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  4944. fsiOPFLD.BilgDeptName = department.Name
  4945. fsiOPFLD.BilgDeptCodg = department.Number
  4946. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  4947. fsiOPFLD.BilgDrName = doctor.UserName
  4948. fsiOPFLD.MedChrgitmType = "09"
  4949. memo["hosp_appr_flag"] = "1"
  4950. memo["invoice_no"] = fapiao_code
  4951. memo["memo"] = "自费"
  4952. bytesData, _ := json.Marshal(memo)
  4953. fsiOPFLD.Memo = string(bytesData)
  4954. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  4955. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  4956. fsiOPFLD.BkkpSn = items.HisPrescriptionProject.FeedetlSn
  4957. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  4958. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  4959. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  4960. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  4961. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  4962. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  4963. fsiOPFLD.BilgDeptName = department.Name
  4964. fsiOPFLD.BilgDeptCodg = department.Number
  4965. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  4966. fsiOPFLD.BilgDrName = doctor.UserName
  4967. switch items.HisPrescriptionProject.HisProject.CostClassify {
  4968. case 0:
  4969. break
  4970. case 1:
  4971. fsiOPFLD.MedChrgitmType = "14"
  4972. break
  4973. case 2:
  4974. fsiOPFLD.MedChrgitmType = "05"
  4975. break
  4976. case 3:
  4977. fsiOPFLD.MedChrgitmType = "03"
  4978. break
  4979. case 4:
  4980. fsiOPFLD.MedChrgitmType = "03"
  4981. break
  4982. case 5:
  4983. fsiOPFLD.MedChrgitmType = "08"
  4984. break
  4985. case 6:
  4986. fsiOPFLD.MedChrgitmType = "14"
  4987. break
  4988. case 7:
  4989. fsiOPFLD.MedChrgitmType = "14"
  4990. break
  4991. case 8:
  4992. fsiOPFLD.MedChrgitmType = "03"
  4993. break
  4994. case 9:
  4995. fsiOPFLD.MedChrgitmType = "14"
  4996. break
  4997. case 10:
  4998. fsiOPFLD.MedChrgitmType = "14"
  4999. break
  5000. case 11:
  5001. fsiOPFLD.MedChrgitmType = "06"
  5002. break
  5003. case 12:
  5004. fsiOPFLD.MedChrgitmType = "12"
  5005. break
  5006. case 13:
  5007. fsiOPFLD.MedChrgitmType = "01"
  5008. break
  5009. case 14:
  5010. fsiOPFLD.MedChrgitmType = "04"
  5011. break
  5012. case 15:
  5013. fsiOPFLD.MedChrgitmType = "14"
  5014. break
  5015. }
  5016. memo["hosp_appr_flag"] = "1"
  5017. memo["invoice_no"] = fapiao_code
  5018. memo["memo"] = "自费"
  5019. bytesData, _ := json.Marshal(memo)
  5020. fsiOPFLD.Memo = string(bytesData)
  5021. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  5022. } else if items.HisPrescriptionProject.Type == 3 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 {
  5023. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  5024. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  5025. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  5026. fsiOPFLD.BilgDeptName = department.Name
  5027. fsiOPFLD.BilgDeptCodg = department.Number
  5028. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  5029. fsiOPFLD.BilgDrName = doctor.UserName
  5030. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  5031. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  5032. fsiOPFLD.MedChrgitmType = "08"
  5033. memo["hosp_appr_flag"] = "1"
  5034. memo["invoice_no"] = fapiao_code
  5035. memo["memo"] = "自费"
  5036. bytesData, _ := json.Marshal(memo)
  5037. fsiOPFLD.Memo = string(bytesData)
  5038. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  5039. }
  5040. }
  5041. }
  5042. for _, items := range order_info_two {
  5043. memo := make(map[string]interface{})
  5044. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  5045. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  5046. fsiOPFLD.MedType = pre.MedType
  5047. fsiOPFLD.BkkpSn = items.FeedetlSn
  5048. fsiOPFLD.FixmedinsCode = miConfig.Code
  5049. fsiOPFLD.FixmedinsName = miConfig.OrgName
  5050. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  5051. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  5052. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  5053. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  5054. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  5055. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  5056. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  5057. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  5058. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  5059. fsiOPFLD.BilgDeptName = department.Name
  5060. fsiOPFLD.BilgDeptCodg = department.Number
  5061. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  5062. fsiOPFLD.BilgDrName = doctor.UserName
  5063. fsiOPFLD.MedChrgitmType = "09"
  5064. memo["hosp_appr_flag"] = "1"
  5065. memo["invoice_no"] = fapiao_code
  5066. memo["memo"] = "自费"
  5067. bytesData, _ := json.Marshal(memo)
  5068. fsiOPFLD.Memo = string(bytesData)
  5069. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  5070. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  5071. fsiOPFLD.BkkpSn = items.HisPrescriptionProject.FeedetlSn
  5072. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  5073. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  5074. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  5075. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  5076. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  5077. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  5078. fsiOPFLD.BilgDeptName = department.Name
  5079. fsiOPFLD.BilgDeptCodg = department.Number
  5080. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  5081. fsiOPFLD.BilgDrName = doctor.UserName
  5082. switch items.HisPrescriptionProject.HisProject.CostClassify {
  5083. case 0:
  5084. break
  5085. case 1:
  5086. fsiOPFLD.MedChrgitmType = "14"
  5087. break
  5088. case 2:
  5089. fsiOPFLD.MedChrgitmType = "05"
  5090. break
  5091. case 3:
  5092. fsiOPFLD.MedChrgitmType = "03"
  5093. break
  5094. case 4:
  5095. fsiOPFLD.MedChrgitmType = "03"
  5096. break
  5097. case 5:
  5098. fsiOPFLD.MedChrgitmType = "08"
  5099. break
  5100. case 6:
  5101. fsiOPFLD.MedChrgitmType = "14"
  5102. break
  5103. case 7:
  5104. fsiOPFLD.MedChrgitmType = "14"
  5105. break
  5106. case 8:
  5107. fsiOPFLD.MedChrgitmType = "03"
  5108. break
  5109. case 9:
  5110. fsiOPFLD.MedChrgitmType = "14"
  5111. break
  5112. case 10:
  5113. fsiOPFLD.MedChrgitmType = "14"
  5114. break
  5115. case 11:
  5116. fsiOPFLD.MedChrgitmType = "06"
  5117. break
  5118. case 12:
  5119. fsiOPFLD.MedChrgitmType = "12"
  5120. break
  5121. case 13:
  5122. fsiOPFLD.MedChrgitmType = "01"
  5123. break
  5124. case 14:
  5125. fsiOPFLD.MedChrgitmType = "04"
  5126. break
  5127. case 15:
  5128. fsiOPFLD.MedChrgitmType = "14"
  5129. break
  5130. }
  5131. memo["hosp_appr_flag"] = "1"
  5132. memo["invoice_no"] = fapiao_code
  5133. memo["memo"] = "自费"
  5134. bytesData, _ := json.Marshal(memo)
  5135. fsiOPFLD.Memo = string(bytesData)
  5136. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  5137. } else if items.HisPrescriptionProject.Type == 3 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 {
  5138. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  5139. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  5140. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  5141. fsiOPFLD.BilgDeptName = department.Name
  5142. fsiOPFLD.BilgDeptCodg = department.Number
  5143. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  5144. fsiOPFLD.BilgDrName = doctor.UserName
  5145. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  5146. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  5147. fsiOPFLD.MedChrgitmType = "08"
  5148. memo["hosp_appr_flag"] = "1"
  5149. memo["invoice_no"] = fapiao_code
  5150. memo["memo"] = "自费"
  5151. bytesData, _ := json.Marshal(memo)
  5152. fsiOPFLD.Memo = string(bytesData)
  5153. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  5154. }
  5155. }
  5156. }
  5157. fmt.Println(fsiOPFLDs)
  5158. struct4201A.Fopfd = fsiOPFLDs
  5159. fmt.Println(struct4201A.Fopfd)
  5160. var struct4202 models.Struct4202
  5161. timeLayout := "2006-01-02 15:04:05"
  5162. dataTimeStr := time.Unix(his.Ctime, 0).Format(timeLayout)
  5163. struct4202.OwnPayPatnMdtrtD.FixmedinsMdtrtID = his.Number
  5164. struct4202.OwnPayPatnMdtrtD.FixmedinsCode = miConfig.Code
  5165. struct4202.OwnPayPatnMdtrtD.FixmedinsName = miConfig.OrgName
  5166. struct4202.OwnPayPatnMdtrtD.PsnCertType = "01"
  5167. struct4202.OwnPayPatnMdtrtD.Certno = his.IdCardNo
  5168. struct4202.OwnPayPatnMdtrtD.PsnName = his.Name
  5169. struct4202.OwnPayPatnMdtrtD.Begntime = dataTimeStr
  5170. struct4202.OwnPayPatnMdtrtD.MedType = pre.MedType
  5171. struct4202.OwnPayPatnMdtrtD.ValiFlag = "1"
  5172. struct4202.OwnPayPatnMdtrtD.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  5173. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  5174. var config []*models.HisXtDiagnoseConfig
  5175. for _, item := range diagnosis_ids {
  5176. id, _ := strconv.ParseInt(item, 10, 64)
  5177. diagnosisConfig, _ := service.FindDiagnoseById(id)
  5178. config = append(config, &diagnosisConfig)
  5179. }
  5180. var tempDiaginfos []models.OwnPayPatnDiagListD
  5181. for index, item := range config {
  5182. if index == 0 {
  5183. var tempDiaginfo models.OwnPayPatnDiagListD
  5184. tempDiaginfo.InoutDiagType = "1"
  5185. tempDiaginfo.DiagCode = item.CountryCode
  5186. tempDiaginfo.DiagName = item.CountryContentName
  5187. tempDiaginfo.DiagType = "1"
  5188. tempDiaginfo.DiagSrtNo = "1"
  5189. tempDiaginfo.MaindiagFlag = "1"
  5190. tempDiaginfo.ValiFlag = "1"
  5191. tempDiaginfo.DiagDrName = doctor.UserName
  5192. tempDiaginfo.DiagDrCode = doctor.DoctorNumber
  5193. tempDiaginfo.DiagTime = time.Unix(pre.Ctime, 0).Format("2006-01-02 15:04:05")
  5194. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  5195. } else {
  5196. var tempDiaginfo models.OwnPayPatnDiagListD
  5197. tempDiaginfo.DiagCode = item.CountryCode
  5198. tempDiaginfo.DiagName = item.CountryContentName
  5199. tempDiaginfo.DiagType = "2"
  5200. tempDiaginfo.DiagSrtNo = strconv.FormatInt(int64(index+1), 10)
  5201. tempDiaginfo.MaindiagFlag = "0"
  5202. tempDiaginfo.ValiFlag = "1"
  5203. tempDiaginfo.DiagDrName = doctor.UserName
  5204. tempDiaginfo.DiagDrCode = doctor.DoctorNumber
  5205. tempDiaginfo.DiagTime = time.Unix(pre.Ctime, 0).Format("2006-01-02 15:04:05")
  5206. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  5207. }
  5208. }
  5209. struct4202.ODiagListD = tempDiaginfos
  5210. result, requestLog := service.Gdyb4205(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4202, struct4201A)
  5211. saveLog(result, requestLog, "4205", "自费就诊和诊断信息上传")
  5212. var res2 ResultSix
  5213. var respJSON2 map[string]interface{}
  5214. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  5215. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5216. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5217. return
  5218. }
  5219. userJSONBytes2, _ := json.Marshal(respJSON2)
  5220. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  5221. utils.ErrorLog("解析失败:%v", err)
  5222. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5223. return
  5224. }
  5225. if res2.Infcode != 0 {
  5226. c.ServeSuccessJSON(map[string]interface{}{
  5227. "failed_code": -10,
  5228. "msg": res2.ErrMsg,
  5229. })
  5230. return
  5231. } else {
  5232. order.IsUploadDiagnose = 1
  5233. order.IsUploadOrderInfo = 1
  5234. service.UpdateOrderTwo(order)
  5235. c.ServeSuccessJSON(map[string]interface{}{
  5236. "msg": "上传成功",
  5237. })
  5238. }
  5239. }
  5240. func (c *HisApiController) Get4207() {
  5241. admin_user_id, _ := c.GetInt64("admin_user_id")
  5242. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  5243. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  5244. order_id, _ := c.GetInt64("order_id")
  5245. order, _ := service.GetHisOrderByIDTwo(order_id)
  5246. //his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  5247. var struct4207 models.Struct4207
  5248. struct4207.PageNum = "1"
  5249. struct4207.PageSize = "1000"
  5250. struct4207.FixmedinsCode = miConfig.Code
  5251. struct4207.FixmedinsMdtrtID = order.Number
  5252. result, requestLog := service.Gdyb4207(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4207)
  5253. saveLog(result, requestLog, "4207", "查询")
  5254. var res2 ResultSix
  5255. var respJSON2 map[string]interface{}
  5256. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  5257. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5258. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5259. return
  5260. }
  5261. userJSONBytes2, _ := json.Marshal(respJSON2)
  5262. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  5263. utils.ErrorLog("解析失败:%v", err)
  5264. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5265. return
  5266. }
  5267. if res2.Infcode != 0 {
  5268. c.ServeSuccessJSON(map[string]interface{}{
  5269. "failed_code": -10,
  5270. "msg": res2.ErrMsg,
  5271. })
  5272. return
  5273. } else {
  5274. c.ServeSuccessJSON(map[string]interface{}{
  5275. "msg": "查询成功",
  5276. })
  5277. }
  5278. }
  5279. func (c *HisApiController) Get4208() {
  5280. admin_user_id, _ := c.GetInt64("admin_user_id")
  5281. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  5282. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  5283. order_id, _ := c.GetInt64("order_id")
  5284. order, _ := service.GetHisOrderByIDTwo(order_id)
  5285. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  5286. var struct4208 models.Struct4208
  5287. struct4208.PageNum = "1"
  5288. struct4208.PageSize = "1000"
  5289. struct4208.PsnCertType = "01"
  5290. struct4208.Certno = his.Certno
  5291. struct4208.MedType = order.MedType
  5292. struct4208.PsnName = his.Name
  5293. result, requestLog := service.Gdyb4208(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4208)
  5294. saveLog(result, requestLog, "4208", "查询")
  5295. var res2 ResultSix
  5296. var respJSON2 map[string]interface{}
  5297. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  5298. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5299. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5300. return
  5301. }
  5302. userJSONBytes2, _ := json.Marshal(respJSON2)
  5303. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  5304. utils.ErrorLog("解析失败:%v", err)
  5305. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5306. return
  5307. }
  5308. if res2.Infcode != 0 {
  5309. c.ServeSuccessJSON(map[string]interface{}{
  5310. "failed_code": -10,
  5311. "msg": res2.ErrMsg,
  5312. })
  5313. return
  5314. } else {
  5315. c.ServeSuccessJSON(map[string]interface{}{
  5316. "msg": "查询成功",
  5317. })
  5318. }
  5319. }
  5320. func (c *HisApiController) Get4209() {
  5321. admin_user_id, _ := c.GetInt64("admin_user_id")
  5322. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  5323. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  5324. order_id, _ := c.GetInt64("order_id")
  5325. order, _ := service.GetHisOrderByIDTwo(order_id)
  5326. //his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  5327. var struct4209 models.Struct4209
  5328. struct4209.FixmedinsMdtrtID = order.Number
  5329. struct4209.FixmedinsCode = miConfig.Code
  5330. struct4209.PageSize = "1000"
  5331. struct4209.PageNum = "1"
  5332. result, requestLog := service.Gdyb4209(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4209)
  5333. saveLog(result, requestLog, "4209", "查询")
  5334. var res2 ResultSix
  5335. var respJSON2 map[string]interface{}
  5336. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  5337. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5338. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5339. return
  5340. }
  5341. userJSONBytes2, _ := json.Marshal(respJSON2)
  5342. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  5343. utils.ErrorLog("解析失败:%v", err)
  5344. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5345. return
  5346. }
  5347. if res2.Infcode != 0 {
  5348. c.ServeSuccessJSON(map[string]interface{}{
  5349. "failed_code": -10,
  5350. "msg": res2.ErrMsg,
  5351. })
  5352. return
  5353. } else {
  5354. c.ServeSuccessJSON(map[string]interface{}{
  5355. "msg": "查询成功",
  5356. })
  5357. }
  5358. }
  5359. type Result3101 struct {
  5360. Infcode string `json:"infcode"`
  5361. InfRefmsgid string `json:"inf_refmsgid"`
  5362. RefmsgTime string `json:"refmsg_time"`
  5363. RespondTime string `json:"respond_time"`
  5364. Enctype string `json:"enctype"`
  5365. Signtype string `json:"signtype"`
  5366. ErrMsg string `json:"err_msg"`
  5367. Output struct {
  5368. Result []struct {
  5369. JudgeResultDetailDtos []struct {
  5370. VolaItemType string `json:"vola_item_type"`
  5371. MdtrtID string `json:"mdtrt_id"`
  5372. JrdID string `json:"jrd_id"`
  5373. PatnID string `json:"patn_id"`
  5374. RxID string `json:"rx_id"`
  5375. VolaAmt interface{} `json:"vola_amt"`
  5376. } `json:"judge_result_detail_dtos"`
  5377. RuleID string `json:"rule_id"`
  5378. VolaEvid string `json:"vola_evid"`
  5379. MdtrtID string `json:"mdtrt_id"`
  5380. RuleName string `json:"rule_name"`
  5381. VolaAmtStas string `json:"vola_amt_stas"`
  5382. JrID string `json:"jr_id"`
  5383. PatnID string `json:"patn_id"`
  5384. SevDeg string `json:"sev_deg"`
  5385. VolaAmt float64 `json:"vola_amt"`
  5386. VolaBhvrType string `json:"vola_bhvr_type"`
  5387. VolaCont string `json:"vola_cont"`
  5388. } `json:"result"`
  5389. } `json:"output"`
  5390. }
  5391. type Resultgd3101 struct {
  5392. Infcode int64 `json:"infcode"`
  5393. InfRefmsgid string `json:"inf_refmsgid"`
  5394. RefmsgTime string `json:"refmsg_time"`
  5395. RespondTime string `json:"respond_time"`
  5396. Enctype string `json:"enctype"`
  5397. Signtype string `json:"signtype"`
  5398. ErrMsg string `json:"err_msg"`
  5399. Output struct {
  5400. Result []struct {
  5401. JudgeResultDetailDtos []struct {
  5402. VolaItemType string `json:"vola_item_type"`
  5403. MdtrtID string `json:"mdtrt_id"`
  5404. JrdID string `json:"jrd_id"`
  5405. PatnID string `json:"patn_id"`
  5406. RxID string `json:"rx_id"`
  5407. VolaAmt interface{} `json:"vola_amt"`
  5408. } `json:"judge_result_detail_dtos"`
  5409. RuleID string `json:"rule_id"`
  5410. VolaEvid string `json:"vola_evid"`
  5411. MdtrtID string `json:"mdtrt_id"`
  5412. RuleName string `json:"rule_name"`
  5413. VolaAmtStas string `json:"vola_amt_stas"`
  5414. JrID string `json:"jr_id"`
  5415. PatnID string `json:"patn_id"`
  5416. SevDeg string `json:"sev_deg"`
  5417. VolaAmt float64 `json:"vola_amt"`
  5418. VolaBhvrType string `json:"vola_bhvr_type"`
  5419. VolaCont string `json:"vola_cont"`
  5420. } `json:"result"`
  5421. } `json:"output"`
  5422. }
  5423. func (c *HisApiController) ReadEleToken() {
  5424. admin_user_id, _ := c.GetInt64("admin_user_id")
  5425. his_patient_id, _ := c.GetInt64("his_patient_id")
  5426. adminUser := c.GetAdminUserInfo()
  5427. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5428. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5429. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  5430. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  5431. tokens := ReadEleCard(admin_user_id, c.GetAdminUserInfo().CurrentOrgId, c)
  5432. if len(tokens) > 0 {
  5433. c.ServeSuccessJSON(map[string]interface{}{
  5434. "msg": "读取成功",
  5435. })
  5436. } else {
  5437. c.ServeSuccessJSON(map[string]interface{}{
  5438. "failed_code": -10,
  5439. "msg": "读取失败",
  5440. })
  5441. }
  5442. } else if miConfig.MdtrtareaAdmvs == "341203" {
  5443. tokens := ReadEleCardforah(admin_user_id, c.GetAdminUserInfo().CurrentOrgId, c)
  5444. if len(tokens) > 0 {
  5445. c.ServeSuccessJSON(map[string]interface{}{
  5446. "msg": "读取成功",
  5447. })
  5448. } else {
  5449. c.ServeSuccessJSON(map[string]interface{}{
  5450. "failed_code": -10,
  5451. "msg": "读取失败",
  5452. })
  5453. }
  5454. } else if miConfig.MdtrtareaAdmvs == "150499" {
  5455. var api string
  5456. 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 +
  5457. "&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"
  5458. resp, requestErr := http.Get(api)
  5459. if requestErr != nil {
  5460. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5461. }
  5462. body, ioErr := ioutil.ReadAll(resp.Body)
  5463. if ioErr != nil {
  5464. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5465. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5466. }
  5467. var respJSON map[string]interface{}
  5468. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5469. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5470. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5471. return
  5472. }
  5473. var status string
  5474. status = respJSON["data"].(map[string]interface{})["status"].(string)
  5475. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  5476. var token string
  5477. var res ResultTwo //1101结果
  5478. var res10265 ResultTwo10265 //1101结果
  5479. if status == "0" { //读卡成功
  5480. var card_info string //卡信息
  5481. var busi_card_info string
  5482. token = respJSON["data"].(map[string]interface{})["token"].(string)
  5483. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  5484. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  5485. fmt.Println(card_info)
  5486. fmt.Println(busi_card_info)
  5487. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  5488. result, _ := json.Marshal(respJSON)
  5489. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  5490. utils.ErrorLog("解析失败:%v", err)
  5491. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5492. return
  5493. }
  5494. res.ErrMsg = res10265.ErrMsg
  5495. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  5496. res.Infcode = infocode
  5497. res.Output = res10265.Output
  5498. res.InfRefmsgid = res10265.InfRefmsgid
  5499. if res.Infcode == 0 {
  5500. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  5501. if err == gorm.ErrRecordNotFound {
  5502. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  5503. return
  5504. } else if err != nil {
  5505. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  5506. return
  5507. } else {
  5508. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  5509. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  5510. infoStr := string(Iinfos)
  5511. idetinfoStr := string(Idetinfos)
  5512. //date,age,_ := GetBirthdateAndAge(res.Output.Baseinfo.Certno),
  5513. b, age, _ := getBirthdateAndAge(res.Output.Baseinfo.Certno)
  5514. psn := &models.HisPsn{
  5515. PsnNo: res.Output.Baseinfo.PsnNo,
  5516. PatientId: patient.ID,
  5517. Certno: res.Output.Baseinfo.Certno,
  5518. Gend: res.Output.Baseinfo.Gend,
  5519. Naty: res.Output.Baseinfo.Naty,
  5520. PsnCertType: res.Output.Baseinfo.PsnCertType,
  5521. PsnName: res.Output.Baseinfo.PsnName,
  5522. Age: float64(age),
  5523. Brdy: b,
  5524. Idetinfo: idetinfoStr,
  5525. Insuinfo: infoStr,
  5526. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  5527. CardInfo: card_info,
  5528. VerifyNumber: token,
  5529. IdCardType: 4,
  5530. }
  5531. var rf []*ResultFive
  5532. json.Unmarshal([]byte(infoStr), &rf)
  5533. var insutypes []*ResultFive
  5534. var insutype string
  5535. var is390 int = 0
  5536. var is310 int = 0
  5537. for _, item := range rf {
  5538. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  5539. insutypes = append(insutypes, item)
  5540. }
  5541. }
  5542. if len(insutypes) == 1 {
  5543. insutype = insutypes[0].Insutype
  5544. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  5545. } else {
  5546. for _, i := range insutypes {
  5547. if i.Insutype == "390" {
  5548. is390 = 1
  5549. }
  5550. if i.Insutype == "310" {
  5551. is310 = 1
  5552. }
  5553. }
  5554. }
  5555. if is390 == 1 {
  5556. insutype = "390"
  5557. }
  5558. if is310 == 1 {
  5559. insutype = "310"
  5560. }
  5561. if len(insutypes) == 0 {
  5562. insutype = "310"
  5563. }
  5564. service.CreateHisPsn(psn)
  5565. c.ServeSuccessJSON(map[string]interface{}{
  5566. "patient": patient,
  5567. "number": token,
  5568. "insutype": insutype,
  5569. })
  5570. }
  5571. } else {
  5572. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  5573. return
  5574. }
  5575. } else { //读卡失败
  5576. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  5577. return
  5578. }
  5579. } else if miConfig.MdtrtareaAdmvs == "350500" {
  5580. _, outPutInfo, errMsg := service.ReadEleCardForSettle(miConfig.Code, roles.UserName, roles.AdminUserId)
  5581. if len(errMsg) == 0 {
  5582. type ELeData struct {
  5583. Data struct {
  5584. IdNo string `json:"idNo"`
  5585. IdType string `json:"idType"`
  5586. UserName string `json:"userName"`
  5587. EcToken string `json:"ecToken"`
  5588. InsuOrg string `json:"insuOrg"`
  5589. Gender string `json:"gender"`
  5590. Birthday string `json:"birthday"`
  5591. Nationality string `json:"nationality"`
  5592. Email string `json:"email"`
  5593. Extra string `json:"extra"`
  5594. } `json:"data"`
  5595. Code int `json:"code"`
  5596. Message string `json:"message"`
  5597. }
  5598. var ele ELeData
  5599. err := json.Unmarshal([]byte(outPutInfo), &ele)
  5600. if err != nil {
  5601. utils.ErrorLog("解析失败:%v", err)
  5602. }
  5603. token := ele.Data.EcToken
  5604. if len(token) > 0 {
  5605. psn := &models.HisPsn{
  5606. PsnNo: his.PsnNo,
  5607. Age: 0,
  5608. PatientId: his.PatientId,
  5609. Certno: his.Certno,
  5610. Brdy: his.Brdy,
  5611. Gend: his.Gend,
  5612. Naty: his.Naty,
  5613. PsnCertType: his.PsnCertType,
  5614. PsnName: his.PsnName,
  5615. Idetinfo: his.Idetinfo,
  5616. Insuinfo: his.Iinfo,
  5617. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  5618. CardInfo: outPutInfo,
  5619. VerifyNumber: token,
  5620. }
  5621. service.CreateHisPsn(psn)
  5622. }
  5623. if len(token) > 0 {
  5624. c.ServeSuccessJSON(map[string]interface{}{
  5625. "msg": "读取成功",
  5626. })
  5627. } else {
  5628. c.ServeSuccessJSON(map[string]interface{}{
  5629. "failed_code": -10,
  5630. "msg": "读取失败",
  5631. })
  5632. }
  5633. }
  5634. } else if miConfig.MdtrtareaAdmvs == "360302" {
  5635. _, result := GetELeInfoThree(miConfig.Code, "1", roles.UserName)
  5636. //json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  5637. type ELeData struct {
  5638. Data struct {
  5639. IdNo string `json:"idNo"`
  5640. IdType string `json:"idType"`
  5641. UserName string `json:"userName"`
  5642. EcToken string `json:"ecToken"`
  5643. InsuOrg string `json:"insuOrg"`
  5644. Gender string `json:"gender"`
  5645. Birthday string `json:"birthday"`
  5646. Nationality string `json:"nationality"`
  5647. Email string `json:"email"`
  5648. Extra string `json:"extra"`
  5649. } `json:"data"`
  5650. Code int `json:"code"`
  5651. Message string `json:"message"`
  5652. }
  5653. var ele ELeData
  5654. err := json.Unmarshal([]byte(result), &ele)
  5655. if err != nil {
  5656. utils.ErrorLog("解析失败:%v", err)
  5657. }
  5658. token := ele.Data.EcToken
  5659. token = Remove0000(token)
  5660. fmt.Println(ele.Data.UserName)
  5661. 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)
  5662. saveLog(result2, requestLog2, "1101", "获取人员信息")
  5663. var res ResultTwo
  5664. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  5665. utils.ErrorLog("解析失败:%v", err)
  5666. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5667. return
  5668. }
  5669. if res.Infcode == 0 {
  5670. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  5671. if err == gorm.ErrRecordNotFound {
  5672. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  5673. return
  5674. } else if err != nil {
  5675. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  5676. return
  5677. } else {
  5678. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  5679. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  5680. infoStr := string(Iinfos)
  5681. idetinfoStr := string(Idetinfos)
  5682. psn := &models.HisPsn{
  5683. PsnNo: res.Output.Baseinfo.PsnNo,
  5684. PatientId: patient.ID,
  5685. Certno: res.Output.Baseinfo.Certno,
  5686. Gend: res.Output.Baseinfo.Gend,
  5687. Naty: res.Output.Baseinfo.Naty,
  5688. PsnCertType: res.Output.Baseinfo.PsnCertType,
  5689. PsnName: res.Output.Baseinfo.PsnName,
  5690. Idetinfo: idetinfoStr,
  5691. Insuinfo: infoStr,
  5692. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  5693. CardInfo: "",
  5694. VerifyNumber: token,
  5695. }
  5696. service.CreateHisPsn(psn)
  5697. c.ServeSuccessJSON(map[string]interface{}{
  5698. "patient": patient,
  5699. "number": token,
  5700. })
  5701. }
  5702. } else {
  5703. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  5704. return
  5705. }
  5706. } else if miConfig.MdtrtareaAdmvs == "430800" {
  5707. idNo := c.GetString("idNo")
  5708. userName := c.GetString("userName")
  5709. ecToken := c.GetString("ecToken")
  5710. insuOrg := c.GetString("insuOrg")
  5711. result2, requestLog2 := service.Hnyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, insuOrg, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, ecToken, "", idNo, userName)
  5712. saveLog(result2, requestLog2, "1101", "获取人员信息")
  5713. var res ResultTwo
  5714. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  5715. utils.ErrorLog("解析失败:%v", err)
  5716. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5717. return
  5718. }
  5719. if res.Infcode == 0 {
  5720. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  5721. if err == gorm.ErrRecordNotFound {
  5722. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  5723. return
  5724. } else if err != nil {
  5725. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  5726. return
  5727. } else {
  5728. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  5729. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  5730. infoStr := string(Iinfos)
  5731. idetinfoStr := string(Idetinfos)
  5732. psn := &models.HisPsn{
  5733. PsnNo: res.Output.Baseinfo.PsnNo,
  5734. PatientId: patient.ID,
  5735. Certno: res.Output.Baseinfo.Certno,
  5736. Gend: res.Output.Baseinfo.Gend,
  5737. Naty: res.Output.Baseinfo.Naty,
  5738. PsnCertType: res.Output.Baseinfo.PsnCertType,
  5739. PsnName: res.Output.Baseinfo.PsnName,
  5740. Idetinfo: idetinfoStr,
  5741. Insuinfo: infoStr,
  5742. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  5743. CardInfo: "",
  5744. VerifyNumber: ecToken,
  5745. InsuplcAdmdvs: insuOrg,
  5746. }
  5747. service.CreateHisPsn(psn)
  5748. c.ServeSuccessJSON(map[string]interface{}{
  5749. "patient": patient,
  5750. "number": ecToken,
  5751. })
  5752. }
  5753. } else {
  5754. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  5755. return
  5756. }
  5757. } else if miConfig.MdtrtareaAdmvs == "450721" {
  5758. res := c.GetoleInfo()
  5759. if res.Infcode == 0 {
  5760. var result string
  5761. if res.Output.MdtrtCertType == "01" {
  5762. 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)
  5763. } else if res.Output.MdtrtCertType == "02" {
  5764. 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)
  5765. } else if res.Output.MdtrtCertType == "03" {
  5766. 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)
  5767. }
  5768. var dat map[string]interface{}
  5769. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5770. fmt.Println(dat)
  5771. } else {
  5772. fmt.Println(err)
  5773. }
  5774. userJSONBytes, _ := json.Marshal(dat)
  5775. var res2 ResultTwo
  5776. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  5777. utils.ErrorLog("解析失败:%v", err)
  5778. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5779. return
  5780. }
  5781. if res2.Infcode == 0 {
  5782. patient, err := service.GetPatientByNumber(res.Output.CertNo, c.GetAdminUserInfo().CurrentOrgId)
  5783. if err == gorm.ErrRecordNotFound {
  5784. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  5785. return
  5786. } else if err != nil {
  5787. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  5788. return
  5789. } else {
  5790. Iinfos, _ := json.Marshal(res2.Output.Iinfo)
  5791. Idetinfos, _ := json.Marshal(res2.Output.Idetinfo)
  5792. infoStr := string(Iinfos)
  5793. idetinfoStr := string(Idetinfos)
  5794. var rf []*ResultFive
  5795. json.Unmarshal([]byte(infoStr), &rf)
  5796. var insutypes []*ResultFive
  5797. var insutype string
  5798. var is390 int = 0
  5799. var is310 int = 0
  5800. //var insuplc_admdvs string
  5801. for _, item := range rf {
  5802. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  5803. insutypes = append(insutypes, item)
  5804. }
  5805. }
  5806. if len(insutypes) == 1 {
  5807. insutype = insutypes[0].Insutype
  5808. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  5809. } else {
  5810. for _, i := range insutypes {
  5811. if i.Insutype == "390" {
  5812. is390 = 1
  5813. }
  5814. if i.Insutype == "310" {
  5815. is310 = 1
  5816. }
  5817. }
  5818. }
  5819. if is390 == 1 {
  5820. insutype = "390"
  5821. }
  5822. if is310 == 1 {
  5823. insutype = "310"
  5824. }
  5825. if len(insutypes) == 0 {
  5826. insutype = "310"
  5827. }
  5828. psn := &models.HisPsn{
  5829. PsnNo: res2.Output.Baseinfo.PsnNo,
  5830. PatientId: patient.ID,
  5831. Certno: res2.Output.Baseinfo.Certno,
  5832. Gend: res2.Output.Baseinfo.Gend,
  5833. Naty: res2.Output.Baseinfo.Naty,
  5834. PsnCertType: res2.Output.Baseinfo.PsnCertType,
  5835. PsnName: res2.Output.Baseinfo.PsnName,
  5836. Idetinfo: idetinfoStr,
  5837. Insuinfo: infoStr,
  5838. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  5839. CardInfo: res.Output.CertNo + "|" + res.Output.CardSN,
  5840. VerifyNumber: res.Output.EcToken,
  5841. InsuplcAdmdvs: res.Output.InsuplcAdmdvs,
  5842. }
  5843. service.CreateHisPsn(psn)
  5844. c.ServeSuccessJSON(map[string]interface{}{
  5845. "patient": patient,
  5846. "number": res.Output.CardNo,
  5847. "insutype": insutype,
  5848. })
  5849. }
  5850. } else {
  5851. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  5852. return
  5853. }
  5854. } else {
  5855. c.ServeSuccessJSON(map[string]interface{}{
  5856. "failed_code": -10,
  5857. "msg": res.ErrMsg,
  5858. })
  5859. }
  5860. } else {
  5861. //if initFlag == 0 {
  5862. // c.TestGetBasBaseInit()
  5863. //}
  5864. //token := c.GetEleBaseInfo()
  5865. //token = Remove0000(token)
  5866. type ELeData struct {
  5867. Code string `json:"code"`
  5868. Data struct {
  5869. Aac002 string `json:"aac002"`
  5870. Aaz500 string `json:"aaz500"`
  5871. ActCardNo string `json:"actCardNo"`
  5872. Bab520 string `json:"bab520"`
  5873. Bkz543 string `json:"bkz543"`
  5874. BusinessType string `json:"businessType"`
  5875. CertfCodg string `json:"certfCodg"`
  5876. EcIndexNo string `json:"ecIndexNo"`
  5877. EcToken string `json:"ecToken"`
  5878. ID0000 string `json:"id0000"`
  5879. IDNo string `json:"idNo"`
  5880. IDType string `json:"idType"`
  5881. Idcode string `json:"idcode"`
  5882. IdentityToken string `json:"identity_token"`
  5883. InsuOrg string `json:"insuOrg"`
  5884. OfficeID string `json:"officeId"`
  5885. OfficeName string `json:"officeName"`
  5886. OperatorID string `json:"operatorId"`
  5887. OperatorName string `json:"operatorName"`
  5888. OrgID string `json:"orgId"`
  5889. UserName string `json:"userName"`
  5890. } `json:"data"`
  5891. Infno interface{} `json:"infno"`
  5892. Message string `json:"message"`
  5893. OrgID string `json:"orgId"`
  5894. TransType string `json:"transType"`
  5895. }
  5896. _, result := GetELeInfoThree(miConfig.Code, "1", roles.UserName)
  5897. fmt.Println(result)
  5898. outPutInfo := Remove0000(result)
  5899. fmt.Println(outPutInfo)
  5900. var ele ELeData
  5901. err := json.Unmarshal([]byte(outPutInfo), &ele)
  5902. if err != nil {
  5903. utils.ErrorLog("解析失败:%v", err)
  5904. }
  5905. token := ele.Data.EcToken
  5906. var result2 string
  5907. var requestLog2 string
  5908. if len(token) > 0 {
  5909. if strings.Contains(ele.Data.IDNo, "HKG") {
  5910. 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)
  5911. } else {
  5912. result2, requestLog2 = service.Gdyb1101ForEleCerttwo(miConfig.OrgName, roles.UserName, miConfig.Code, ele.Data.InsuOrg, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, token, ele.Data.UserName, ele.Data.IDNo)
  5913. }
  5914. saveLog(result2, requestLog2, "1101", "获取人员信息")
  5915. var res ResultTwo
  5916. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  5917. utils.ErrorLog("解析失败:%v", err)
  5918. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5919. return
  5920. }
  5921. if res.Infcode == 0 {
  5922. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  5923. if err == gorm.ErrRecordNotFound {
  5924. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  5925. return
  5926. } else if err != nil {
  5927. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  5928. return
  5929. } else {
  5930. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  5931. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  5932. infoStr := string(Iinfos)
  5933. idetinfoStr := string(Idetinfos)
  5934. psn := &models.HisPsn{
  5935. PsnNo: res.Output.Baseinfo.PsnNo,
  5936. PatientId: patient.ID,
  5937. Certno: res.Output.Baseinfo.Certno,
  5938. Gend: res.Output.Baseinfo.Gend,
  5939. Naty: res.Output.Baseinfo.Naty,
  5940. PsnCertType: res.Output.Baseinfo.PsnCertType,
  5941. PsnName: res.Output.Baseinfo.PsnName,
  5942. Idetinfo: idetinfoStr,
  5943. Insuinfo: infoStr,
  5944. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  5945. CardInfo: "",
  5946. VerifyNumber: token,
  5947. }
  5948. service.CreateHisPsn(psn)
  5949. c.ServeSuccessJSON(map[string]interface{}{
  5950. "msg": "读取成功",
  5951. })
  5952. }
  5953. } else {
  5954. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  5955. return
  5956. }
  5957. } else {
  5958. c.ServeSuccessJSON(map[string]interface{}{
  5959. "failed_code": -10,
  5960. "msg": "读取失败",
  5961. })
  5962. }
  5963. }
  5964. }
  5965. func (c *HisApiController) ReadEleFace() {
  5966. admin_user_id, _ := c.GetInt64("admin_user_id")
  5967. //his_patient_id, _ := c.GetInt64("his_patient_id")
  5968. adminUser := c.GetAdminUserInfo()
  5969. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5970. //roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5971. //his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  5972. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  5973. tokens := ReadEleFace(admin_user_id, c.GetAdminUserInfo().CurrentOrgId, c)
  5974. if len(tokens) > 0 {
  5975. c.ServeSuccessJSON(map[string]interface{}{
  5976. "msg": "读取成功",
  5977. })
  5978. } else {
  5979. c.ServeSuccessJSON(map[string]interface{}{
  5980. "failed_code": -10,
  5981. "msg": "读取失败",
  5982. })
  5983. }
  5984. }
  5985. }
  5986. func (c *HisApiController) Get9001() {
  5987. adminUser := c.GetAdminUserInfo()
  5988. admin_user_id, _ := c.GetInt64("admin_user_id")
  5989. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5990. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5991. if miConfig.MdtrtareaAdmvs == "350500" {
  5992. service.GetFjAuthorizationInfo(miConfig.Code)
  5993. } else if miConfig.MdtrtareaAdmvs == "131023" {
  5994. result, _ := service.HeBeiyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  5995. var dat map[string]interface{}
  5996. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5997. fmt.Println(dat)
  5998. } else {
  5999. fmt.Println(err)
  6000. }
  6001. userJSONBytes, _ := json.Marshal(dat)
  6002. var res models.Result9001
  6003. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6004. utils.ErrorLog("解析失败:%v", err)
  6005. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6006. return
  6007. }
  6008. } else if miConfig.MdtrtareaAdmvs == "341203" {
  6009. fmt.Println(miConfig.SecretKey)
  6010. var res models.Result9001Two
  6011. 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 +
  6012. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&cainfo=" + miConfig.Cainfo + "&url=" + miConfig.Url
  6013. resp, requestErr := http.Get(api)
  6014. if requestErr != nil {
  6015. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6016. return
  6017. }
  6018. body, ioErr := ioutil.ReadAll(resp.Body)
  6019. if ioErr != nil {
  6020. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6021. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6022. return
  6023. }
  6024. var respJSON map[string]interface{}
  6025. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6026. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6027. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6028. return
  6029. }
  6030. status := respJSON["data"].(map[string]interface{})["status"].(string)
  6031. if status == "0" {
  6032. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  6033. c.ServeSuccessJSON(map[string]interface{}{
  6034. "failed_code": -10,
  6035. "msg": err_msg,
  6036. })
  6037. return
  6038. }
  6039. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6040. result, _ := json.Marshal(respJSON)
  6041. fmt.Println("log")
  6042. fmt.Println(string(result))
  6043. if err := json.Unmarshal([]byte(result), &res); err != nil {
  6044. utils.ErrorLog("解析失败:%v", err)
  6045. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6046. return
  6047. }
  6048. if res.Infcode == 0 {
  6049. sign := models.HisSignIn{
  6050. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  6051. SignNo: res.Output.Signinoutb.SignNo,
  6052. SignTime: "",
  6053. Ctime: time.Now().Unix(),
  6054. Mtime: time.Now().Unix(),
  6055. Status: 1,
  6056. InputLog: "",
  6057. OutputLog: "",
  6058. FixmedinsCode: miConfig.Code,
  6059. }
  6060. err := service.CreateSignIn(&sign)
  6061. if err == nil {
  6062. c.ServeSuccessJSON(map[string]interface{}{
  6063. "msg": "签到成功",
  6064. })
  6065. }
  6066. } else {
  6067. c.ServeSuccessJSON(map[string]interface{}{
  6068. "failed_code": -10,
  6069. "msg": res.ErrMsg,
  6070. })
  6071. return
  6072. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  6073. //return
  6074. }
  6075. } else {
  6076. result, _ := service.Gdyb9001Two(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  6077. var dat map[string]interface{}
  6078. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  6079. fmt.Println(dat)
  6080. } else {
  6081. fmt.Println(err)
  6082. }
  6083. userJSONBytes, _ := json.Marshal(dat)
  6084. var res models.Result9001
  6085. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6086. utils.ErrorLog("解析失败:%v", err)
  6087. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6088. return
  6089. }
  6090. if res.Infcode == 0 {
  6091. sign := models.HisSignIn{
  6092. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  6093. SignNo: res.Output.Signinoutb.SignNo,
  6094. SignTime: res.Output.Signinoutb.SignTime,
  6095. Ctime: time.Now().Unix(),
  6096. Mtime: time.Now().Unix(),
  6097. Status: 1,
  6098. InputLog: "",
  6099. OutputLog: "",
  6100. FixmedinsCode: miConfig.Code,
  6101. }
  6102. err := service.CreateSignIn(&sign)
  6103. if err == nil {
  6104. c.ServeSuccessJSON(map[string]interface{}{
  6105. "msg": "签到成功",
  6106. })
  6107. }
  6108. }
  6109. }
  6110. }
  6111. 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) {
  6112. var res Result3101
  6113. adminUser := c.GetAdminUserInfo()
  6114. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6115. //his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  6116. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6117. //record_time := c.GetString("record_time")
  6118. //trig_scen := c.GetString("trig_scen")
  6119. timeLayout := "2006-01-02"
  6120. loc, _ := time.LoadLocation("Local")
  6121. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  6122. if err != nil {
  6123. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6124. return res
  6125. }
  6126. recordDateTime := theTime.Unix()
  6127. var patientPrescription models.HisPrescriptionInfo
  6128. //patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  6129. //if patientPrescription.ID == 0 {
  6130. patientPrescription, _ = service.FindLastPatientPrescriptionInfoTwo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  6131. //}
  6132. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  6133. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  6134. //
  6135. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  6136. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  6137. var pp models.PublicParams
  6138. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  6139. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  6140. pp.FixmedinsName = miConfig.OrgName
  6141. pp.FixmedinsCode = miConfig.Code
  6142. pp.RequestUrl = miConfig.Url
  6143. pp.Cainfo = miConfig.Cainfo
  6144. pp.SecretKey = miConfig.SecretKey
  6145. pp.AccessKey = miConfig.AccessKey
  6146. pp.OpterName = roles.UserName
  6147. var config []*models.HisXtDiagnoseConfig
  6148. for _, item := range diagnosis_ids {
  6149. id, _ := strconv.ParseInt(item, 10, 64)
  6150. diagnosisConfig, _ := service.FindDiagnoseById(id)
  6151. config = append(config, &diagnosisConfig)
  6152. }
  6153. var pd models.PatientDtos
  6154. pd.PatnID = his.PsnNo
  6155. pd.PatnName = his.Name
  6156. pd.Gend = his.Gend
  6157. pd.Brdy = his.Brdy
  6158. pd.Poolarea = miConfig.MdtrtareaAdmvs
  6159. pd.CurrMdtrtID = his.Number
  6160. var fed models.FsiEncounterDtos
  6161. fed.MdtrtID = his.Number
  6162. fed.MedinsID = miConfig.Code
  6163. fed.MedinsName = miConfig.OrgName
  6164. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  6165. fed.MedMdtrtType = "1"
  6166. fed.MedinsType = "1"
  6167. fed.MedinsLv = "11"
  6168. tm := time.Unix(his.RecordDate, 0)
  6169. s_tm := tm.Format("2006-01-02 15:04:05")
  6170. fed.AdmDate = s_tm
  6171. fed.DscgDate = s_tm
  6172. fed.DscgMainDiseCodg = config[0].CountryCode
  6173. fed.DscgMainDiseName = config[0].CountryContentName
  6174. //诊断信息
  6175. var fdds []*models.FsiDiagnoseDtos
  6176. for index, item := range config {
  6177. if index == 0 {
  6178. var fdd models.FsiDiagnoseDtos
  6179. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  6180. fdd.InoutDiseType = "1"
  6181. fdd.MaindiseFlag = "1"
  6182. fdd.DiseDate = s_tm
  6183. fdd.DiasSrtNo = "1"
  6184. fdd.DiseName = item.CountryContentName
  6185. fdd.DiseCodg = item.CountryCode
  6186. fdds = append(fdds, &fdd)
  6187. } else {
  6188. var fdd models.FsiDiagnoseDtos
  6189. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  6190. fdd.InoutDiseType = "1"
  6191. fdd.MaindiseFlag = "1"
  6192. fdd.DiseDate = s_tm
  6193. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  6194. fdd.DiseName = item.CountryContentName
  6195. fdd.DiseCodg = item.CountryCode
  6196. fdds = append(fdds, &fdd)
  6197. }
  6198. }
  6199. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  6200. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  6201. fed.AdmDeptName = department.Name
  6202. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  6203. fed.DscgDeptName = department.Name
  6204. fed.MedMdtrtType = "1"
  6205. fed.MedType = "11"
  6206. //if his.Insutype == "390" {
  6207. // fed.MedType = "1402"
  6208. //} else {
  6209. // fed.MedType = "9933"
  6210. //}
  6211. var orders []*models.FsiOrderDtos
  6212. if trig_scen == "2" {
  6213. //处方医嘱信息
  6214. for _, item := range prescriptions {
  6215. for _, subItem := range item.HisDoctorAdviceInfo {
  6216. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  6217. var order models.FsiOrderDtos
  6218. order.RxID = strconv.FormatInt(item.ID, 10)
  6219. order.Rxno = strconv.FormatInt(item.ID, 10)
  6220. order.LongDrordFlag = "0"
  6221. order.HilistType = "1"
  6222. order.ChrgType = "1"
  6223. order.DrordBhvr = "-"
  6224. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  6225. order.HosplistName = subItem.BaseDrugLib.DrugName
  6226. order.HilistLv = "1"
  6227. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  6228. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  6229. order.HosplistName = subItem.BaseDrugLib.DrugName
  6230. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  6231. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  6232. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  6233. order.OwnpayAmt = ""
  6234. order.SelfpayAmt = ""
  6235. order.Spec = ""
  6236. order.SpecUnt = ""
  6237. order.DrordBegnDate = s_tm
  6238. order.DrordStopDate = ""
  6239. order.DrordDrCodg = doctor_info.DoctorNumber
  6240. order.DrordDeptName = department.Name
  6241. order.DrordDeptCodg = department.Number
  6242. order.DrordDrName = doctor_info.UserName
  6243. order.DrordDrProfttl = "234"
  6244. order.CurrDrordFlag = "1"
  6245. orders = append(orders, &order)
  6246. }
  6247. }
  6248. for _, subItem := range item.HisPrescriptionProject {
  6249. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  6250. var order models.FsiOrderDtos
  6251. order.RxID = strconv.FormatInt(item.ID, 10)
  6252. order.Rxno = strconv.FormatInt(item.ID, 10)
  6253. order.LongDrordFlag = "0"
  6254. order.HilistType = "1"
  6255. order.ChrgType = "1"
  6256. order.DrordBhvr = "-"
  6257. order.HilistCode = subItem.HisProject.MedicalCode
  6258. order.HosplistName = subItem.HisProject.ProjectName
  6259. order.HilistLv = "1"
  6260. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  6261. order.HosplistCode = subItem.HisProject.MedicalCode
  6262. order.HosplistName = subItem.HisProject.ProjectName
  6263. order.Cnt = subItem.Count
  6264. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  6265. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  6266. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  6267. order.OwnpayAmt = ""
  6268. order.SelfpayAmt = ""
  6269. order.Spec = ""
  6270. order.SpecUnt = ""
  6271. order.DrordBegnDate = s_tm
  6272. order.DrordStopDate = ""
  6273. order.DrordDrCodg = doctor_info.DoctorNumber
  6274. order.DrordDeptName = department.Name
  6275. order.DrordDeptCodg = department.Number
  6276. order.DrordDrName = doctor_info.UserName
  6277. order.DrordDrProfttl = "234"
  6278. order.CurrDrordFlag = "1"
  6279. orders = append(orders, &order)
  6280. }
  6281. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  6282. var order models.FsiOrderDtos
  6283. order.RxID = strconv.FormatInt(item.ID, 10)
  6284. order.Rxno = strconv.FormatInt(item.ID, 10)
  6285. order.LongDrordFlag = "0"
  6286. order.HilistType = "1"
  6287. order.ChrgType = "1"
  6288. order.DrordBhvr = "-"
  6289. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  6290. order.HosplistName = subItem.GoodInfo.GoodName
  6291. order.HilistLv = "1"
  6292. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  6293. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  6294. order.HosplistName = subItem.GoodInfo.GoodName
  6295. order.Cnt = subItem.Count
  6296. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  6297. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  6298. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  6299. order.OwnpayAmt = ""
  6300. order.SelfpayAmt = ""
  6301. order.Spec = ""
  6302. order.SpecUnt = ""
  6303. order.DrordBegnDate = s_tm
  6304. order.DrordStopDate = ""
  6305. order.DrordDrCodg = doctor_info.DoctorNumber
  6306. order.DrordDeptName = department.Name
  6307. order.DrordDeptCodg = department.Number
  6308. order.DrordDrName = doctor_info.UserName
  6309. order.DrordDrProfttl = "234"
  6310. order.CurrDrordFlag = "1"
  6311. orders = append(orders, &order)
  6312. }
  6313. }
  6314. }
  6315. //处方医嘱信息
  6316. }
  6317. fed.MatnStas = "0"
  6318. fed.MedfeeSumamt = "0"
  6319. fed.OwnpayAmt = "0"
  6320. fed.SelfpayAmt = "0"
  6321. fed.AcctPayamt = "0"
  6322. fed.MaAmt = "0"
  6323. fed.HifpPayamt = "0"
  6324. fed.SetlTotlnum = "1"
  6325. fed.Insutype = his.Insutype
  6326. fed.ReimFlag = "0"
  6327. fed.OutSetlFlag = "0"
  6328. var fopd []*models.FsiOperationDtosData
  6329. data := make(map[string]interface{})
  6330. data["fed"] = fed
  6331. data["fdd"] = fdds
  6332. data["fod"] = orders
  6333. data["pd"] = pd
  6334. data["pp"] = pp
  6335. data["fopd"] = fopd
  6336. data["trig_scen"] = trig_scen
  6337. fmt.Println(data)
  6338. fmt.Println(fed)
  6339. fmt.Println(fdds)
  6340. fmt.Println(orders)
  6341. fmt.Println(pd)
  6342. fmt.Println(pp)
  6343. fmt.Println(fopd)
  6344. client := &http.Client{}
  6345. bytesData, _ := json.Marshal(data)
  6346. var req *http.Request
  6347. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  6348. if miConfig.MdtrtareaAdmvs == "320921" {
  6349. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  6350. } else {
  6351. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  6352. }
  6353. resp, _ := client.Do(req)
  6354. defer resp.Body.Close()
  6355. body, ioErr := ioutil.ReadAll(resp.Body)
  6356. if ioErr != nil {
  6357. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6358. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6359. return res
  6360. }
  6361. var respJSON map[string]interface{}
  6362. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6363. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6364. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6365. return res
  6366. }
  6367. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  6368. fmt.Println(respJSON)
  6369. result, _ := json.Marshal(respJSON)
  6370. fmt.Println(result)
  6371. if err := json.Unmarshal([]byte(result), &res); err != nil {
  6372. utils.ErrorLog("解析失败:%v", err)
  6373. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6374. return res
  6375. }
  6376. return res
  6377. } else {
  6378. //if miConfig.MdtrtareaAdmvs == "441202" {
  6379. output, input := service.Gdyb3101(pd, fed, fdds, orders, fopd, pp, trig_scen)
  6380. saveLog(output, input, "3101", "事前")
  6381. if err := json.Unmarshal([]byte(output), &res); err != nil {
  6382. utils.ErrorLog("解析失败:%v", err)
  6383. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6384. return
  6385. }
  6386. return res
  6387. //}
  6388. }
  6389. }
  6390. 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) {
  6391. adminUser := c.GetAdminUserInfo()
  6392. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6393. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  6394. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6395. //record_time := c.GetString("record_time")
  6396. //trig_scen := c.GetString("trig_scen")
  6397. timeLayout := "2006-01-02"
  6398. loc, _ := time.LoadLocation("Local")
  6399. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  6400. if err != nil {
  6401. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6402. return res
  6403. }
  6404. recordDateTime := theTime.Unix()
  6405. var patientPrescription models.HisPrescriptionInfo
  6406. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  6407. if patientPrescription.ID == 0 {
  6408. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  6409. }
  6410. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  6411. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  6412. //
  6413. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  6414. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  6415. var pp models.PublicParams
  6416. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  6417. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  6418. pp.FixmedinsName = miConfig.OrgName
  6419. pp.FixmedinsCode = miConfig.Code
  6420. pp.RequestUrl = miConfig.Url
  6421. pp.Cainfo = miConfig.Cainfo
  6422. pp.SecretKey = miConfig.SecretKey
  6423. pp.AccessKey = miConfig.AccessKey
  6424. pp.OpterName = roles.UserName
  6425. var config []*models.HisXtDiagnoseConfig
  6426. for _, item := range diagnosis_ids {
  6427. id, _ := strconv.ParseInt(item, 10, 64)
  6428. diagnosisConfig, _ := service.FindDiagnoseById(id)
  6429. config = append(config, &diagnosisConfig)
  6430. }
  6431. var pd models.PatientDtos
  6432. pd.PatnID = his.PsnNo
  6433. pd.PatnName = his.Name
  6434. pd.Gend = his.Gend
  6435. pd.Brdy = his.Brdy
  6436. pd.Poolarea = his.InsuplcAdmdvs
  6437. pd.CurrMdtrtID = his.Number
  6438. var fed models.FsiEncounterDtos
  6439. fed.MdtrtID = his.Number
  6440. fed.MedinsID = miConfig.Code
  6441. fed.MedinsName = miConfig.OrgName
  6442. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  6443. fed.MedMdtrtType = "1"
  6444. fed.MedinsType = "1"
  6445. fed.MedinsLv = "11"
  6446. tm := time.Unix(his.RecordDate, 0)
  6447. s_tm := tm.Format("2006-01-02 15:04:05")
  6448. fed.AdmDate = s_tm
  6449. fed.DscgDate = s_tm
  6450. fed.DscgMainDiseCodg = config[0].CountryCode
  6451. fed.DscgMainDiseName = config[0].CountryContentName
  6452. //诊断信息
  6453. var fdds []*models.FsiDiagnoseDtos
  6454. for index, item := range config {
  6455. if index == 0 {
  6456. var fdd models.FsiDiagnoseDtos
  6457. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  6458. fdd.InoutDiseType = "1"
  6459. fdd.MaindiseFlag = "1"
  6460. fdd.DiseDate = s_tm
  6461. fdd.DiasSrtNo = "1"
  6462. fdd.DiseName = item.CountryContentName
  6463. fdd.DiseCodg = item.CountryCode
  6464. fdds = append(fdds, &fdd)
  6465. } else {
  6466. var fdd models.FsiDiagnoseDtos
  6467. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  6468. fdd.InoutDiseType = "1"
  6469. fdd.MaindiseFlag = "1"
  6470. fdd.DiseDate = s_tm
  6471. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  6472. fdd.DiseName = item.CountryContentName
  6473. fdd.DiseCodg = item.CountryCode
  6474. fdds = append(fdds, &fdd)
  6475. }
  6476. }
  6477. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  6478. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  6479. fed.AdmDeptName = department.Name
  6480. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  6481. fed.DscgDeptName = department.Name
  6482. fed.MedMdtrtType = "1"
  6483. fed.MedType = "11"
  6484. //if his.Insutype == "390" {
  6485. // fed.MedType = "1402"
  6486. //} else {
  6487. // fed.MedType = "9933"
  6488. //}
  6489. var orders []*models.FsiOrderDtos
  6490. if trig_scen == "2" {
  6491. //处方医嘱信息
  6492. for _, item := range prescriptions {
  6493. for _, subItem := range item.HisDoctorAdviceInfo {
  6494. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  6495. var order models.FsiOrderDtos
  6496. order.RxID = strconv.FormatInt(item.ID, 10)
  6497. order.Rxno = strconv.FormatInt(item.ID, 10)
  6498. order.LongDrordFlag = "0"
  6499. order.HilistType = "1"
  6500. order.ChrgType = "1"
  6501. order.DrordBhvr = "-"
  6502. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  6503. order.HosplistName = subItem.BaseDrugLib.DrugName
  6504. order.HilistLv = "1"
  6505. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  6506. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  6507. order.HosplistName = subItem.BaseDrugLib.DrugName
  6508. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  6509. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  6510. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  6511. order.OwnpayAmt = ""
  6512. order.SelfpayAmt = ""
  6513. order.Spec = ""
  6514. order.SpecUnt = ""
  6515. order.DrordBegnDate = s_tm
  6516. order.DrordStopDate = ""
  6517. order.DrordDrCodg = doctor_info.DoctorNumber
  6518. order.DrordDeptName = department.Name
  6519. order.DrordDeptCodg = department.Number
  6520. order.DrordDrName = doctor_info.UserName
  6521. order.DrordDrProfttl = "234"
  6522. order.CurrDrordFlag = "1"
  6523. orders = append(orders, &order)
  6524. }
  6525. }
  6526. for _, subItem := range item.HisPrescriptionProject {
  6527. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  6528. var order models.FsiOrderDtos
  6529. order.RxID = strconv.FormatInt(item.ID, 10)
  6530. order.Rxno = strconv.FormatInt(item.ID, 10)
  6531. order.LongDrordFlag = "0"
  6532. order.HilistType = "1"
  6533. order.ChrgType = "1"
  6534. order.DrordBhvr = "-"
  6535. order.HilistCode = subItem.HisProject.MedicalCode
  6536. order.HosplistName = subItem.HisProject.ProjectName
  6537. order.HilistLv = "1"
  6538. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  6539. order.HosplistCode = subItem.HisProject.MedicalCode
  6540. order.HosplistName = subItem.HisProject.ProjectName
  6541. order.Cnt = subItem.Count
  6542. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  6543. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  6544. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  6545. order.OwnpayAmt = ""
  6546. order.SelfpayAmt = ""
  6547. order.Spec = ""
  6548. order.SpecUnt = ""
  6549. order.DrordBegnDate = s_tm
  6550. order.DrordStopDate = ""
  6551. order.DrordDrCodg = doctor_info.DoctorNumber
  6552. order.DrordDeptName = department.Name
  6553. order.DrordDeptCodg = department.Number
  6554. order.DrordDrName = doctor_info.UserName
  6555. order.DrordDrProfttl = "234"
  6556. order.CurrDrordFlag = "1"
  6557. orders = append(orders, &order)
  6558. }
  6559. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  6560. var order models.FsiOrderDtos
  6561. order.RxID = strconv.FormatInt(item.ID, 10)
  6562. order.Rxno = strconv.FormatInt(item.ID, 10)
  6563. order.LongDrordFlag = "0"
  6564. order.HilistType = "1"
  6565. order.ChrgType = "1"
  6566. order.DrordBhvr = "-"
  6567. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  6568. order.HosplistName = subItem.GoodInfo.GoodName
  6569. order.HilistLv = "1"
  6570. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  6571. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  6572. order.HosplistName = subItem.GoodInfo.GoodName
  6573. order.Cnt = subItem.Count
  6574. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  6575. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  6576. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  6577. order.OwnpayAmt = ""
  6578. order.SelfpayAmt = ""
  6579. order.Spec = ""
  6580. order.SpecUnt = ""
  6581. order.DrordBegnDate = s_tm
  6582. order.DrordStopDate = ""
  6583. order.DrordDrCodg = doctor_info.DoctorNumber
  6584. order.DrordDeptName = department.Name
  6585. order.DrordDeptCodg = department.Number
  6586. order.DrordDrName = doctor_info.UserName
  6587. order.DrordDrProfttl = "234"
  6588. order.CurrDrordFlag = "1"
  6589. orders = append(orders, &order)
  6590. }
  6591. }
  6592. }
  6593. //处方医嘱信息
  6594. }
  6595. fed.MatnStas = "0"
  6596. fed.MedfeeSumamt = "0"
  6597. fed.OwnpayAmt = "0"
  6598. fed.SelfpayAmt = "0"
  6599. fed.AcctPayamt = "0"
  6600. fed.MaAmt = "0"
  6601. fed.HifpPayamt = "0"
  6602. fed.SetlTotlnum = "1"
  6603. fed.Insutype = his.Insutype
  6604. fed.ReimFlag = "0"
  6605. fed.OutSetlFlag = "0"
  6606. var fopd []*models.FsiOperationDtosData
  6607. data := make(map[string]interface{})
  6608. data["fed"] = fed
  6609. data["fdd"] = fdds
  6610. data["fod"] = orders
  6611. data["pd"] = pd
  6612. data["pp"] = pp
  6613. data["fopd"] = fopd
  6614. data["trig_scen"] = trig_scen
  6615. fmt.Println(data)
  6616. fmt.Println(fed)
  6617. fmt.Println(fdds)
  6618. fmt.Println(orders)
  6619. fmt.Println(pd)
  6620. fmt.Println(pp)
  6621. fmt.Println(fopd)
  6622. client := &http.Client{}
  6623. bytesData, _ := json.Marshal(data)
  6624. var req *http.Request
  6625. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  6626. if miConfig.MdtrtareaAdmvs == "320921" {
  6627. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  6628. } else {
  6629. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  6630. }
  6631. resp, _ := client.Do(req)
  6632. defer resp.Body.Close()
  6633. body, ioErr := ioutil.ReadAll(resp.Body)
  6634. if ioErr != nil {
  6635. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6636. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6637. return res
  6638. }
  6639. var respJSON map[string]interface{}
  6640. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6641. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6642. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6643. return res
  6644. }
  6645. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  6646. fmt.Println(respJSON)
  6647. result, _ := json.Marshal(respJSON)
  6648. fmt.Println(result)
  6649. if err := json.Unmarshal([]byte(result), &res); err != nil {
  6650. utils.ErrorLog("解析失败:%v", err)
  6651. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6652. return res
  6653. }
  6654. return res
  6655. } else {
  6656. output, input := service.Gdyb3101(pd, fed, fdds, orders, fopd, pp, trig_scen)
  6657. saveLog(output, input, "3101", "事前")
  6658. if err := json.Unmarshal([]byte(output), &res); err != nil {
  6659. utils.ErrorLog("解析失败:%v", err)
  6660. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6661. return
  6662. }
  6663. return res
  6664. }
  6665. return res
  6666. }
  6667. func Check3102(c *HisApiController, patient_id int64, his_patient_id int64, admin_user_id int64, trig_scen string, order_id int64) (res Result3101) {
  6668. ////patient_id, _ := c.GetInt64("patient_id")
  6669. //order_id, _ := c.GetInt64("order_id")
  6670. ////his_patient_id, _ := c.GetInt64("his_patient_id")
  6671. ////admin_user_id, _ := c.GetInt64("admin_user_id")
  6672. //trig_scen := c.GetString("trig_scen")
  6673. adminUser := c.GetAdminUserInfo()
  6674. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6675. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  6676. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6677. record_time := c.GetString("record_time")
  6678. order, _ := service.GetHisOrderByID(order_id)
  6679. psn_info, _ := service.GetPsnByPatientId(patient_id)
  6680. timeLayout := "2006-01-02"
  6681. loc, _ := time.LoadLocation("Local")
  6682. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  6683. if err != nil {
  6684. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6685. return
  6686. }
  6687. recordDateTime := theTime.Unix()
  6688. var patientPrescription models.HisPrescriptionInfo
  6689. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  6690. if patientPrescription.ID == 0 {
  6691. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  6692. }
  6693. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  6694. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  6695. //
  6696. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  6697. prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  6698. var pp models.PublicParams
  6699. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  6700. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  6701. pp.FixmedinsName = miConfig.OrgName
  6702. pp.FixmedinsCode = miConfig.Code
  6703. pp.RequestUrl = miConfig.Url
  6704. pp.Cainfo = miConfig.Cainfo
  6705. pp.SecretKey = miConfig.SecretKey
  6706. pp.AccessKey = miConfig.AccessKey
  6707. pp.OpterName = roles.UserName
  6708. var config []*models.HisXtDiagnoseConfig
  6709. for _, item := range diagnosis_ids {
  6710. id, _ := strconv.ParseInt(item, 10, 64)
  6711. diagnosisConfig, _ := service.FindDiagnoseById(id)
  6712. config = append(config, &diagnosisConfig)
  6713. }
  6714. var pd models.PatientDtos
  6715. pd.PatnID = his.PsnNo
  6716. pd.PatnName = his.Name
  6717. pd.Gend = his.Gend
  6718. pd.Brdy = psn_info.Brdy
  6719. pd.Poolarea = his.InsuplcAdmdvs
  6720. pd.CurrMdtrtID = his.Number
  6721. var fed models.FsiEncounterDtos
  6722. fed.MdtrtID = his.Number
  6723. fed.MedinsID = miConfig.Code
  6724. fed.MedinsName = miConfig.OrgName
  6725. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  6726. fed.MedMdtrtType = "1"
  6727. fed.MedinsType = "1"
  6728. fed.MedinsLv = "11"
  6729. tm := time.Unix(his.RecordDate, 0)
  6730. s_tm := tm.Format("2006-01-02 15:04:05")
  6731. fed.AdmDate = s_tm
  6732. fed.DscgDate = s_tm
  6733. fed.DscgMainDiseCodg = config[0].CountryCode
  6734. fed.DscgMainDiseName = config[0].CountryContentName
  6735. //诊断信息
  6736. var fdds []*models.FsiDiagnoseDtos
  6737. for index, item := range config {
  6738. if index == 0 {
  6739. var fdd models.FsiDiagnoseDtos
  6740. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  6741. fdd.InoutDiseType = "1"
  6742. fdd.MaindiseFlag = "1"
  6743. fdd.DiseDate = s_tm
  6744. fdd.DiasSrtNo = "1"
  6745. fdd.DiseName = item.CountryContentName
  6746. fdd.DiseCodg = item.CountryCode
  6747. fdds = append(fdds, &fdd)
  6748. } else {
  6749. var fdd models.FsiDiagnoseDtos
  6750. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  6751. fdd.InoutDiseType = "1"
  6752. fdd.MaindiseFlag = "1"
  6753. fdd.DiseDate = s_tm
  6754. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  6755. fdd.DiseName = item.CountryContentName
  6756. fdd.DiseCodg = item.CountryCode
  6757. fdds = append(fdds, &fdd)
  6758. }
  6759. }
  6760. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  6761. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  6762. fed.AdmDeptName = department.Name
  6763. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  6764. fed.DscgDeptName = department.Name
  6765. fed.MedType = order.MedType
  6766. //处方医嘱信息
  6767. var orders []*models.FsiOrderDtos
  6768. //for _, item := range prescriptions {
  6769. // for _, subItem := range item.HisDoctorAdviceInfo {
  6770. // var order models.FsiOrderDtos
  6771. // order.RxID = strconv.FormatInt(item.ID, 10)
  6772. // order.Rxno = strconv.FormatInt(item.ID, 10)
  6773. // order.LongDrordFlag = "0"
  6774. // order.HilistType = "1"
  6775. // order.ChrgType = "1"
  6776. // order.DrordBhvr = "-"
  6777. // order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  6778. // order.HosplistName = subItem.BaseDrugLib.DrugName
  6779. // order.HilistLv = "1"
  6780. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  6781. // order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  6782. // order.HosplistName = subItem.BaseDrugLib.DrugName
  6783. // order.Cnt = strconv.FormatFloat(subItem.PrescribingNumber, 'E', -1, 64)
  6784. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  6785. // order.Sumamt = strconv.FormatFloat((subItem.Price * subItem.PrescribingNumber), 'E', -1, 64)
  6786. // order.OwnpayAmt = ""
  6787. // order.SelfpayAmt = ""
  6788. // order.Spec = ""
  6789. // order.SpecUnt = ""
  6790. // order.DrordBegnDate = s_tm
  6791. // order.DrordStopDate = ""
  6792. // order.DrordDrCodg = "1"
  6793. // order.DrordDeptName = department.Name
  6794. // order.DrordDrCodg = "1"
  6795. // order.DrordDrName = doctor_info.UserName
  6796. // order.DrordDrProfttl = ""
  6797. // order.CurrDrordFlag = "1"
  6798. // orders = append(orders, &order)
  6799. // }
  6800. // for _, subItem := range item.HisPrescriptionProject {
  6801. // if subItem.Type == 2 {
  6802. // var order models.FsiOrderDtos
  6803. // order.RxID = strconv.FormatInt(item.ID, 10)
  6804. // order.Rxno = strconv.FormatInt(item.ID, 10)
  6805. // order.LongDrordFlag = "0"
  6806. // order.HilistType = "1"
  6807. // order.ChrgType = "1"
  6808. // order.DrordBhvr = "-"
  6809. // order.HilistCode = subItem.HisProject.MedicalCode
  6810. // order.HosplistName = subItem.HisProject.ProjectName
  6811. // order.HilistLv = "1"
  6812. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  6813. // order.HosplistCode = subItem.HisProject.MedicalCode
  6814. // order.HosplistName = subItem.HisProject.ProjectName
  6815. // order.Cnt = subItem.Count
  6816. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  6817. //
  6818. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  6819. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  6820. // order.OwnpayAmt = ""
  6821. // order.SelfpayAmt = ""
  6822. // order.Spec = ""
  6823. // order.SpecUnt = ""
  6824. // order.DrordBegnDate = s_tm
  6825. // order.DrordStopDate = ""
  6826. // order.DrordDrCodg = "1"
  6827. // order.DrordDeptName = department.Name
  6828. // order.DrordDrCodg = "1"
  6829. // order.DrordDrName = doctor_info.UserName
  6830. // order.DrordDrProfttl = ""
  6831. // order.CurrDrordFlag = "1"
  6832. // orders = append(orders, &order)
  6833. //
  6834. // }
  6835. // if subItem.Type == 3 {
  6836. //
  6837. // var order models.FsiOrderDtos
  6838. // order.RxID = strconv.FormatInt(item.ID, 10)
  6839. // order.Rxno = strconv.FormatInt(item.ID, 10)
  6840. // order.LongDrordFlag = "0"
  6841. // order.HilistType = "1"
  6842. // order.ChrgType = "1"
  6843. // order.DrordBhvr = "-"
  6844. // order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  6845. // order.HosplistName = subItem.GoodInfo.GoodName
  6846. // order.HilistLv = "1"
  6847. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  6848. // order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  6849. // order.HosplistName = subItem.GoodInfo.GoodName
  6850. // order.Cnt = subItem.Count
  6851. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  6852. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  6853. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  6854. // order.OwnpayAmt = ""
  6855. // order.SelfpayAmt = ""
  6856. // order.Spec = ""
  6857. // order.SpecUnt = ""
  6858. // order.DrordBegnDate = s_tm
  6859. // order.DrordStopDate = ""
  6860. // order.DrordDrCodg = "1"
  6861. // order.DrordDeptName = department.Name
  6862. // order.DrordDrCodg = "1"
  6863. // order.DrordDrName = doctor_info.UserName
  6864. // order.DrordDrProfttl = ""
  6865. // order.CurrDrordFlag = "1"
  6866. // orders = append(orders, &order)
  6867. //
  6868. // }
  6869. // }
  6870. //}
  6871. for _, item := range prescriptions {
  6872. for _, subItem := range item.HisDoctorAdviceInfo {
  6873. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  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.BaseDrugLib.MedicalInsuranceNumber
  6882. order.HosplistName = subItem.BaseDrugLib.DrugName
  6883. order.HilistLv = "1"
  6884. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  6885. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  6886. order.HosplistName = subItem.BaseDrugLib.DrugName
  6887. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  6888. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  6889. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  6890. order.OwnpayAmt = ""
  6891. order.SelfpayAmt = ""
  6892. order.Spec = ""
  6893. order.SpecUnt = ""
  6894. order.DrordBegnDate = s_tm
  6895. order.DrordStopDate = ""
  6896. order.DrordDrCodg = doctor_info.DoctorNumber
  6897. order.DrordDeptName = department.Name
  6898. order.DrordDeptCodg = department.Number
  6899. order.DrordDrName = doctor_info.UserName
  6900. order.DrordDrProfttl = "234"
  6901. order.CurrDrordFlag = "1"
  6902. orders = append(orders, &order)
  6903. }
  6904. }
  6905. for _, subItem := range item.HisPrescriptionProject {
  6906. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  6907. var order models.FsiOrderDtos
  6908. order.RxID = strconv.FormatInt(item.ID, 10)
  6909. order.Rxno = strconv.FormatInt(item.ID, 10)
  6910. order.LongDrordFlag = "0"
  6911. order.HilistType = "1"
  6912. order.ChrgType = "1"
  6913. order.DrordBhvr = "-"
  6914. order.HilistCode = subItem.HisProject.MedicalCode
  6915. order.HosplistName = subItem.HisProject.ProjectName
  6916. order.HilistLv = "1"
  6917. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  6918. order.HosplistCode = subItem.HisProject.MedicalCode
  6919. order.HosplistName = subItem.HisProject.ProjectName
  6920. order.Cnt = subItem.Count
  6921. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  6922. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  6923. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  6924. order.OwnpayAmt = ""
  6925. order.SelfpayAmt = ""
  6926. order.Spec = ""
  6927. order.SpecUnt = ""
  6928. order.DrordBegnDate = s_tm
  6929. order.DrordStopDate = ""
  6930. order.DrordDrCodg = doctor_info.DoctorNumber
  6931. order.DrordDeptName = department.Name
  6932. order.DrordDeptCodg = department.Number
  6933. order.DrordDrName = doctor_info.UserName
  6934. order.DrordDrProfttl = "234"
  6935. order.CurrDrordFlag = "1"
  6936. orders = append(orders, &order)
  6937. }
  6938. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  6939. var order models.FsiOrderDtos
  6940. order.RxID = strconv.FormatInt(item.ID, 10)
  6941. order.Rxno = strconv.FormatInt(item.ID, 10)
  6942. order.LongDrordFlag = "0"
  6943. order.HilistType = "1"
  6944. order.ChrgType = "1"
  6945. order.DrordBhvr = "0"
  6946. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  6947. order.HosplistName = subItem.GoodInfo.GoodName
  6948. order.HilistLv = "1"
  6949. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  6950. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  6951. order.HosplistName = subItem.GoodInfo.GoodName
  6952. order.Cnt = subItem.Count
  6953. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  6954. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  6955. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  6956. order.OwnpayAmt = ""
  6957. order.SelfpayAmt = ""
  6958. order.Spec = ""
  6959. order.SpecUnt = ""
  6960. order.DrordBegnDate = s_tm
  6961. order.DrordStopDate = ""
  6962. order.DrordDrCodg = doctor_info.DoctorNumber
  6963. order.DrordDeptName = department.Name
  6964. order.DrordDeptCodg = department.Number
  6965. order.DrordDrName = doctor_info.UserName
  6966. order.DrordDrProfttl = "234"
  6967. order.CurrDrordFlag = "1"
  6968. orders = append(orders, &order)
  6969. }
  6970. }
  6971. }
  6972. //处方医嘱信息
  6973. fed.MatnStas = "0"
  6974. fed.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  6975. fed.OwnpayAmt = fmt.Sprintf("%.2f", order.FulamtOwnpayAmt)
  6976. fed.SelfpayAmt = fmt.Sprintf("%.2f", order.PreselfpayAmt)
  6977. fed.AcctPayamt = fmt.Sprintf("%.2f", order.AcctPay)
  6978. fed.MaAmt = fmt.Sprintf("%.2f", order.MafPay)
  6979. fed.HifpPayamt = fmt.Sprintf("%.2f", order.HifpPay)
  6980. fed.SetlTotlnum = "1"
  6981. fed.Insutype = his.Insutype
  6982. fed.ReimFlag = "0"
  6983. fed.OutSetlFlag = "0"
  6984. var fopd []*models.FsiOperationDtosData
  6985. data := make(map[string]interface{})
  6986. data["fed"] = fed
  6987. data["fdd"] = fdds
  6988. data["fod"] = orders
  6989. data["pd"] = pd
  6990. data["pp"] = pp
  6991. data["fopd"] = fopd
  6992. data["trig_scen"] = trig_scen
  6993. client := &http.Client{}
  6994. bytesData, _ := json.Marshal(data)
  6995. var req *http.Request
  6996. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  6997. if miConfig.MdtrtareaAdmvs == "320921" {
  6998. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  6999. } else {
  7000. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  7001. }
  7002. resp, _ := client.Do(req)
  7003. defer resp.Body.Close()
  7004. body, ioErr := ioutil.ReadAll(resp.Body)
  7005. if ioErr != nil {
  7006. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7007. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7008. return res
  7009. }
  7010. var respJSON map[string]interface{}
  7011. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7012. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7013. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7014. return res
  7015. }
  7016. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  7017. result, _ := json.Marshal(respJSON)
  7018. if err := json.Unmarshal([]byte(result), &res); err != nil {
  7019. utils.ErrorLog("解析失败:%v", err)
  7020. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7021. return res
  7022. }
  7023. return res
  7024. } else {
  7025. output, input := service.Gdyb3102(pd, fed, fdds, orders, fopd, pp, trig_scen)
  7026. saveLog(output, input, "3102", "事中")
  7027. if err := json.Unmarshal([]byte(output), &res); err != nil {
  7028. utils.ErrorLog("解析失败:%v", err)
  7029. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7030. return
  7031. }
  7032. return res
  7033. }
  7034. return res
  7035. }
  7036. 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) {
  7037. var res Resultgd3101
  7038. adminUser := c.GetAdminUserInfo()
  7039. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7040. //his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  7041. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7042. //record_time := c.GetString("record_time")
  7043. //trig_scen := c.GetString("trig_scen")
  7044. psn_info, _ := service.GetPsnByPatientId(patient_id)
  7045. timeLayout := "2006-01-02"
  7046. loc, _ := time.LoadLocation("Local")
  7047. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  7048. if err != nil {
  7049. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7050. return res
  7051. }
  7052. recordDateTime := theTime.Unix()
  7053. var patientPrescription models.HisPrescriptionInfo
  7054. //patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  7055. //if patientPrescription.ID == 0 {
  7056. patientPrescription, _ = service.FindLastPatientPrescriptionInfoTwo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  7057. //}
  7058. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  7059. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  7060. //
  7061. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  7062. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  7063. var pp models.PublicParams
  7064. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  7065. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  7066. pp.FixmedinsName = miConfig.OrgName
  7067. pp.FixmedinsCode = miConfig.Code
  7068. pp.RequestUrl = miConfig.Url
  7069. pp.Cainfo = miConfig.Cainfo
  7070. pp.SecretKey = miConfig.SecretKey
  7071. pp.AccessKey = miConfig.AccessKey
  7072. pp.OpterName = roles.UserName
  7073. var config []*models.HisXtDiagnoseConfig
  7074. for _, item := range diagnosis_ids {
  7075. id, _ := strconv.ParseInt(item, 10, 64)
  7076. diagnosisConfig, _ := service.FindDiagnoseById(id)
  7077. config = append(config, &diagnosisConfig)
  7078. }
  7079. var pd models.PatientDtos
  7080. pd.PatnID = his.PsnNo
  7081. pd.PatnName = his.Name
  7082. pd.Gend = his.Gend
  7083. pd.Brdy = psn_info.Brdy
  7084. pd.Poolarea = miConfig.MdtrtareaAdmvs
  7085. pd.CurrMdtrtID = his.Number
  7086. var fed models.FsiEncounterDtos
  7087. fed.MdtrtID = his.Number
  7088. fed.MedinsID = miConfig.Code
  7089. fed.MedinsName = miConfig.OrgName
  7090. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  7091. fed.MedMdtrtType = "1"
  7092. fed.MedinsType = "1"
  7093. fed.MedinsLv = "11"
  7094. tm := time.Unix(his.RecordDate, 0)
  7095. s_tm := tm.Format("2006-01-02 15:04:05")
  7096. fed.AdmDate = s_tm
  7097. fed.DscgDate = s_tm
  7098. fed.DscgMainDiseCodg = config[0].CountryCode
  7099. fed.DscgMainDiseName = config[0].CountryContentName
  7100. //诊断信息
  7101. var fdds []*models.FsiDiagnoseDtos
  7102. for index, item := range config {
  7103. if index == 0 {
  7104. var fdd models.FsiDiagnoseDtos
  7105. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  7106. fdd.InoutDiseType = "1"
  7107. fdd.MaindiseFlag = "1"
  7108. fdd.DiseDate = s_tm
  7109. fdd.DiasSrtNo = "1"
  7110. fdd.DiseName = item.CountryContentName
  7111. fdd.DiseCodg = item.CountryCode
  7112. fdds = append(fdds, &fdd)
  7113. } else {
  7114. var fdd models.FsiDiagnoseDtos
  7115. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  7116. fdd.InoutDiseType = "1"
  7117. fdd.MaindiseFlag = "1"
  7118. fdd.DiseDate = s_tm
  7119. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  7120. fdd.DiseName = item.CountryContentName
  7121. fdd.DiseCodg = item.CountryCode
  7122. fdds = append(fdds, &fdd)
  7123. }
  7124. }
  7125. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  7126. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  7127. fed.AdmDeptName = department.Name
  7128. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  7129. fed.DscgDeptName = department.Name
  7130. fed.MedMdtrtType = "1"
  7131. fed.MedType = "11"
  7132. //if his.Insutype == "390" {
  7133. // fed.MedType = "1402"
  7134. //} else {
  7135. // fed.MedType = "9933"
  7136. //}
  7137. var orders []*models.FsiOrderDtos
  7138. if trig_scen == "2" {
  7139. //处方医嘱信息
  7140. for _, item := range prescriptions {
  7141. for _, subItem := range item.HisDoctorAdviceInfo {
  7142. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  7143. spec := (subItem.BaseDrugLib.Dose + subItem.BaseDrugLib.DoseUnit) + "*" + strconv.FormatInt(subItem.BaseDrugLib.MinNumber, 10) + subItem.BaseDrugLib.MinUnit + "/" + subItem.BaseDrugLib.MaxUnit
  7144. var order models.FsiOrderDtos
  7145. order.RxID = strconv.FormatInt(item.ID, 10)
  7146. order.Rxno = strconv.FormatInt(item.ID, 10)
  7147. order.LongDrordFlag = "0"
  7148. order.HilistType = "1"
  7149. order.ChrgType = "1"
  7150. order.DrordBhvr = "0"
  7151. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  7152. order.HosplistName = subItem.BaseDrugLib.DrugName
  7153. order.HilistLv = "1"
  7154. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  7155. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  7156. order.HosplistName = subItem.BaseDrugLib.DrugName
  7157. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  7158. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  7159. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  7160. order.OwnpayAmt = ""
  7161. order.SelfpayAmt = ""
  7162. order.Spec = spec
  7163. order.SpecUnt = subItem.PrescribingNumberUnit
  7164. order.DrordBegnDate = s_tm
  7165. order.DrordStopDate = ""
  7166. order.DrordDrCodg = doctor_info.DoctorNumber
  7167. order.DrordDeptName = department.Name
  7168. order.DrordDeptCodg = department.Number
  7169. order.DrordDrName = doctor_info.UserName
  7170. order.DrordDrProfttl = "234"
  7171. order.CurrDrordFlag = "1"
  7172. orders = append(orders, &order)
  7173. }
  7174. }
  7175. for _, subItem := range item.HisPrescriptionProject {
  7176. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  7177. var order models.FsiOrderDtos
  7178. order.RxID = strconv.FormatInt(item.ID, 10)
  7179. order.Rxno = strconv.FormatInt(item.ID, 10)
  7180. order.LongDrordFlag = "0"
  7181. order.HilistType = "1"
  7182. order.ChrgType = "1"
  7183. order.DrordBhvr = "0"
  7184. order.HilistCode = subItem.HisProject.MedicalCode
  7185. order.HosplistName = subItem.HisProject.ProjectName
  7186. order.HilistLv = "1"
  7187. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  7188. order.HosplistCode = subItem.HisProject.MedicalCode
  7189. order.HosplistName = subItem.HisProject.ProjectName
  7190. order.Cnt = subItem.Count
  7191. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  7192. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  7193. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  7194. order.OwnpayAmt = ""
  7195. order.SelfpayAmt = ""
  7196. order.Spec = subItem.Unit
  7197. order.SpecUnt = subItem.Unit
  7198. order.DrordBegnDate = s_tm
  7199. order.DrordStopDate = ""
  7200. order.DrordDrCodg = doctor_info.DoctorNumber
  7201. order.DrordDeptName = department.Name
  7202. order.DrordDeptCodg = department.Number
  7203. order.DrordDrName = doctor_info.UserName
  7204. order.DrordDrProfttl = "234"
  7205. order.CurrDrordFlag = "1"
  7206. orders = append(orders, &order)
  7207. }
  7208. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  7209. var order models.FsiOrderDtos
  7210. order.RxID = strconv.FormatInt(item.ID, 10)
  7211. order.Rxno = strconv.FormatInt(item.ID, 10)
  7212. order.LongDrordFlag = "0"
  7213. order.HilistType = "1"
  7214. order.ChrgType = "1"
  7215. order.DrordBhvr = "0"
  7216. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  7217. order.HosplistName = subItem.GoodInfo.GoodName
  7218. order.HilistLv = "1"
  7219. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  7220. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  7221. order.HosplistName = subItem.GoodInfo.GoodName
  7222. order.Cnt = subItem.Count
  7223. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  7224. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  7225. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  7226. order.OwnpayAmt = ""
  7227. order.SelfpayAmt = ""
  7228. order.Spec = subItem.GoodInfo.SpecificationName
  7229. order.SpecUnt = subItem.Unit
  7230. order.DrordBegnDate = s_tm
  7231. order.DrordStopDate = ""
  7232. order.DrordDrCodg = doctor_info.DoctorNumber
  7233. order.DrordDeptName = department.Name
  7234. order.DrordDeptCodg = department.Number
  7235. order.DrordDrName = doctor_info.UserName
  7236. order.DrordDrProfttl = "234"
  7237. order.CurrDrordFlag = "1"
  7238. orders = append(orders, &order)
  7239. }
  7240. }
  7241. }
  7242. //处方医嘱信息
  7243. }
  7244. fed.MatnStas = "0"
  7245. fed.MedfeeSumamt = "0"
  7246. fed.OwnpayAmt = "0"
  7247. fed.SelfpayAmt = "0"
  7248. fed.AcctPayamt = "0"
  7249. fed.MaAmt = "0"
  7250. fed.HifpPayamt = "0"
  7251. fed.SetlTotlnum = "1"
  7252. fed.Insutype = his.Insutype
  7253. fed.ReimFlag = "0"
  7254. fed.OutSetlFlag = "0"
  7255. var fopd []*models.FsiOperationDtosData
  7256. data := make(map[string]interface{})
  7257. data["fed"] = fed
  7258. data["fdd"] = fdds
  7259. data["fod"] = orders
  7260. data["pd"] = pd
  7261. data["pp"] = pp
  7262. data["fopd"] = fopd
  7263. data["trig_scen"] = trig_scen
  7264. fmt.Println(data)
  7265. fmt.Println(fed)
  7266. fmt.Println(fdds)
  7267. fmt.Println(orders)
  7268. fmt.Println(pd)
  7269. fmt.Println(pp)
  7270. fmt.Println(fopd)
  7271. client := &http.Client{}
  7272. bytesData, _ := json.Marshal(data)
  7273. var req *http.Request
  7274. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7275. if miConfig.MdtrtareaAdmvs == "320921" {
  7276. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  7277. } else {
  7278. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  7279. }
  7280. resp, _ := client.Do(req)
  7281. defer resp.Body.Close()
  7282. body, ioErr := ioutil.ReadAll(resp.Body)
  7283. if ioErr != nil {
  7284. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7285. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7286. return res
  7287. }
  7288. var respJSON map[string]interface{}
  7289. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7290. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7291. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7292. return res
  7293. }
  7294. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  7295. fmt.Println(respJSON)
  7296. result, _ := json.Marshal(respJSON)
  7297. fmt.Println(result)
  7298. if err := json.Unmarshal([]byte(result), &res); err != nil {
  7299. utils.ErrorLog("解析失败:%v", err)
  7300. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7301. return res
  7302. }
  7303. return res
  7304. } else {
  7305. //if miConfig.MdtrtareaAdmvs == "441202" {
  7306. output, input := service.Gdyb3101(pd, fed, fdds, orders, fopd, pp, trig_scen)
  7307. saveLog(output, input, "3101", "事前")
  7308. if err := json.Unmarshal([]byte(output), &res); err != nil {
  7309. utils.ErrorLog("解析失败:%v", err)
  7310. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7311. return
  7312. }
  7313. return res
  7314. //}
  7315. }
  7316. }
  7317. 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) {
  7318. adminUser := c.GetAdminUserInfo()
  7319. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7320. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  7321. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7322. //record_time := c.GetString("record_time")
  7323. //trig_scen := c.GetString("trig_scen")
  7324. psn_info, _ := service.GetPsnByPatientId(patient_id)
  7325. timeLayout := "2006-01-02"
  7326. loc, _ := time.LoadLocation("Local")
  7327. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  7328. if err != nil {
  7329. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7330. return res
  7331. }
  7332. recordDateTime := theTime.Unix()
  7333. var patientPrescription models.HisPrescriptionInfo
  7334. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  7335. if patientPrescription.ID == 0 {
  7336. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  7337. }
  7338. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  7339. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  7340. //
  7341. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  7342. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  7343. var pp models.PublicParams
  7344. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  7345. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  7346. pp.FixmedinsName = miConfig.OrgName
  7347. pp.FixmedinsCode = miConfig.Code
  7348. pp.RequestUrl = miConfig.Url
  7349. pp.Cainfo = miConfig.Cainfo
  7350. pp.SecretKey = miConfig.SecretKey
  7351. pp.AccessKey = miConfig.AccessKey
  7352. pp.OpterName = roles.UserName
  7353. var config []*models.HisXtDiagnoseConfig
  7354. for _, item := range diagnosis_ids {
  7355. id, _ := strconv.ParseInt(item, 10, 64)
  7356. diagnosisConfig, _ := service.FindDiagnoseById(id)
  7357. config = append(config, &diagnosisConfig)
  7358. }
  7359. var pd models.PatientDtos
  7360. pd.PatnID = his.PsnNo
  7361. pd.PatnName = his.Name
  7362. pd.Gend = his.Gend
  7363. pd.Brdy = psn_info.Brdy
  7364. pd.Poolarea = his.InsuplcAdmdvs
  7365. pd.CurrMdtrtID = his.Number
  7366. var fed models.FsiEncounterDtos
  7367. fed.MdtrtID = his.Number
  7368. fed.MedinsID = miConfig.Code
  7369. fed.MedinsName = miConfig.OrgName
  7370. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  7371. fed.MedMdtrtType = "1"
  7372. fed.MedinsType = "1"
  7373. fed.MedinsLv = "11"
  7374. tm := time.Unix(his.RecordDate, 0)
  7375. s_tm := tm.Format("2006-01-02 15:04:05")
  7376. fed.AdmDate = s_tm
  7377. fed.DscgDate = s_tm
  7378. fed.DscgMainDiseCodg = config[0].CountryCode
  7379. fed.DscgMainDiseName = config[0].CountryContentName
  7380. //诊断信息
  7381. var fdds []*models.FsiDiagnoseDtos
  7382. for index, item := range config {
  7383. if index == 0 {
  7384. var fdd models.FsiDiagnoseDtos
  7385. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  7386. fdd.InoutDiseType = "1"
  7387. fdd.MaindiseFlag = "1"
  7388. fdd.DiseDate = s_tm
  7389. fdd.DiasSrtNo = "1"
  7390. fdd.DiseName = item.CountryContentName
  7391. fdd.DiseCodg = item.CountryCode
  7392. fdds = append(fdds, &fdd)
  7393. } else {
  7394. var fdd models.FsiDiagnoseDtos
  7395. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  7396. fdd.InoutDiseType = "1"
  7397. fdd.MaindiseFlag = "1"
  7398. fdd.DiseDate = s_tm
  7399. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  7400. fdd.DiseName = item.CountryContentName
  7401. fdd.DiseCodg = item.CountryCode
  7402. fdds = append(fdds, &fdd)
  7403. }
  7404. }
  7405. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  7406. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  7407. fed.AdmDeptName = department.Name
  7408. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  7409. fed.DscgDeptName = department.Name
  7410. fed.MedMdtrtType = "1"
  7411. fed.MedType = "11"
  7412. //if his.Insutype == "390" {
  7413. // fed.MedType = "1402"
  7414. //} else {
  7415. // fed.MedType = "9933"
  7416. //}
  7417. var orders []*models.FsiOrderDtos
  7418. if trig_scen == "2" {
  7419. //处方医嘱信息
  7420. for _, item := range prescriptions {
  7421. for _, subItem := range item.HisDoctorAdviceInfo {
  7422. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  7423. spec := (subItem.BaseDrugLib.Dose + subItem.BaseDrugLib.DoseUnit) + "*" + strconv.FormatInt(subItem.BaseDrugLib.MinNumber, 10) + subItem.BaseDrugLib.MinUnit + "/" + subItem.BaseDrugLib.MaxUnit
  7424. var order models.FsiOrderDtos
  7425. order.RxID = strconv.FormatInt(item.ID, 10)
  7426. order.Rxno = strconv.FormatInt(item.ID, 10)
  7427. order.LongDrordFlag = "0"
  7428. order.HilistType = "1"
  7429. order.ChrgType = "1"
  7430. order.DrordBhvr = "0"
  7431. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  7432. order.HosplistName = subItem.BaseDrugLib.DrugName
  7433. order.HilistLv = "1"
  7434. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  7435. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  7436. order.HosplistName = subItem.BaseDrugLib.DrugName
  7437. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  7438. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  7439. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  7440. order.OwnpayAmt = ""
  7441. order.SelfpayAmt = ""
  7442. order.Spec = spec
  7443. order.SpecUnt = subItem.PrescribingNumberUnit
  7444. order.DrordBegnDate = s_tm
  7445. order.DrordStopDate = ""
  7446. order.DrordDrCodg = doctor_info.DoctorNumber
  7447. order.DrordDeptName = department.Name
  7448. order.DrordDeptCodg = department.Number
  7449. order.DrordDrName = doctor_info.UserName
  7450. order.DrordDrProfttl = "234"
  7451. order.CurrDrordFlag = "1"
  7452. orders = append(orders, &order)
  7453. }
  7454. }
  7455. for _, subItem := range item.HisPrescriptionProject {
  7456. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  7457. var order models.FsiOrderDtos
  7458. order.RxID = strconv.FormatInt(item.ID, 10)
  7459. order.Rxno = strconv.FormatInt(item.ID, 10)
  7460. order.LongDrordFlag = "0"
  7461. order.HilistType = "1"
  7462. order.ChrgType = "1"
  7463. order.DrordBhvr = "0"
  7464. order.HilistCode = subItem.HisProject.MedicalCode
  7465. order.HosplistName = subItem.HisProject.ProjectName
  7466. order.HilistLv = "1"
  7467. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  7468. order.HosplistCode = subItem.HisProject.MedicalCode
  7469. order.HosplistName = subItem.HisProject.ProjectName
  7470. order.Cnt = subItem.Count
  7471. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  7472. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  7473. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  7474. order.OwnpayAmt = ""
  7475. order.SelfpayAmt = ""
  7476. order.Spec = subItem.Unit
  7477. order.SpecUnt = subItem.Unit
  7478. order.DrordBegnDate = s_tm
  7479. order.DrordStopDate = ""
  7480. order.DrordDrCodg = doctor_info.DoctorNumber
  7481. order.DrordDeptName = department.Name
  7482. order.DrordDeptCodg = department.Number
  7483. order.DrordDrName = doctor_info.UserName
  7484. order.DrordDrProfttl = "234"
  7485. order.CurrDrordFlag = "1"
  7486. orders = append(orders, &order)
  7487. }
  7488. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  7489. var order models.FsiOrderDtos
  7490. order.RxID = strconv.FormatInt(item.ID, 10)
  7491. order.Rxno = strconv.FormatInt(item.ID, 10)
  7492. order.LongDrordFlag = "0"
  7493. order.HilistType = "1"
  7494. order.ChrgType = "1"
  7495. order.DrordBhvr = "0"
  7496. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  7497. order.HosplistName = subItem.GoodInfo.GoodName
  7498. order.HilistLv = "1"
  7499. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  7500. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  7501. order.HosplistName = subItem.GoodInfo.GoodName
  7502. order.Cnt = subItem.Count
  7503. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  7504. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  7505. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  7506. order.OwnpayAmt = ""
  7507. order.SelfpayAmt = ""
  7508. order.Spec = subItem.GoodInfo.SpecificationName
  7509. order.SpecUnt = subItem.Unit
  7510. order.DrordBegnDate = s_tm
  7511. order.DrordStopDate = ""
  7512. order.DrordDrCodg = doctor_info.DoctorNumber
  7513. order.DrordDeptName = department.Name
  7514. order.DrordDeptCodg = department.Number
  7515. order.DrordDrName = doctor_info.UserName
  7516. order.DrordDrProfttl = "234"
  7517. order.CurrDrordFlag = "1"
  7518. orders = append(orders, &order)
  7519. }
  7520. }
  7521. }
  7522. //处方医嘱信息
  7523. }
  7524. fed.MatnStas = "0"
  7525. fed.MedfeeSumamt = "0"
  7526. fed.OwnpayAmt = "0"
  7527. fed.SelfpayAmt = "0"
  7528. fed.AcctPayamt = "0"
  7529. fed.MaAmt = "0"
  7530. fed.HifpPayamt = "0"
  7531. fed.SetlTotlnum = "1"
  7532. fed.Insutype = his.Insutype
  7533. fed.ReimFlag = "0"
  7534. fed.OutSetlFlag = "0"
  7535. var fopd []*models.FsiOperationDtosData
  7536. data := make(map[string]interface{})
  7537. data["fed"] = fed
  7538. data["fdd"] = fdds
  7539. data["fod"] = orders
  7540. data["pd"] = pd
  7541. data["pp"] = pp
  7542. data["fopd"] = fopd
  7543. data["trig_scen"] = trig_scen
  7544. fmt.Println(data)
  7545. fmt.Println(fed)
  7546. fmt.Println(fdds)
  7547. fmt.Println(orders)
  7548. fmt.Println(pd)
  7549. fmt.Println(pp)
  7550. fmt.Println(fopd)
  7551. client := &http.Client{}
  7552. bytesData, _ := json.Marshal(data)
  7553. var req *http.Request
  7554. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7555. if miConfig.MdtrtareaAdmvs == "320921" {
  7556. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  7557. } else {
  7558. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  7559. }
  7560. resp, _ := client.Do(req)
  7561. defer resp.Body.Close()
  7562. body, ioErr := ioutil.ReadAll(resp.Body)
  7563. if ioErr != nil {
  7564. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7565. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7566. return res
  7567. }
  7568. var respJSON map[string]interface{}
  7569. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7570. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7571. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7572. return res
  7573. }
  7574. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  7575. fmt.Println(respJSON)
  7576. result, _ := json.Marshal(respJSON)
  7577. fmt.Println(result)
  7578. if err := json.Unmarshal([]byte(result), &res); err != nil {
  7579. utils.ErrorLog("解析失败:%v", err)
  7580. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7581. return res
  7582. }
  7583. return res
  7584. } else {
  7585. output, input := service.Gdyb3101(pd, fed, fdds, orders, fopd, pp, trig_scen)
  7586. saveLog(output, input, "3101", "事前")
  7587. if err := json.Unmarshal([]byte(output), &res); err != nil {
  7588. utils.ErrorLog("解析失败:%v", err)
  7589. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7590. return
  7591. }
  7592. return res
  7593. }
  7594. return res
  7595. }
  7596. func Checkgd3102(c *HisApiController, patient_id int64, his_patient_id int64, admin_user_id int64, trig_scen string, order_id int64) (res Resultgd3101) {
  7597. ////patient_id, _ := c.GetInt64("patient_id")
  7598. //order_id, _ := c.GetInt64("order_id")
  7599. ////his_patient_id, _ := c.GetInt64("his_patient_id")
  7600. ////admin_user_id, _ := c.GetInt64("admin_user_id")
  7601. //trig_scen := c.GetString("trig_scen")
  7602. psn_info, _ := service.GetPsnByPatientId(patient_id)
  7603. utils.ErrorLog("解析失败:%v", psn_info)
  7604. adminUser := c.GetAdminUserInfo()
  7605. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7606. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  7607. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7608. record_time := c.GetString("record_time")
  7609. order, _ := service.GetHisOrderByID(order_id)
  7610. timeLayout := "2006-01-02"
  7611. loc, _ := time.LoadLocation("Local")
  7612. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  7613. if err != nil {
  7614. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7615. return
  7616. }
  7617. recordDateTime := theTime.Unix()
  7618. var patientPrescription models.HisPrescriptionInfo
  7619. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  7620. if patientPrescription.ID == 0 {
  7621. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  7622. }
  7623. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  7624. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  7625. //
  7626. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  7627. prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  7628. var pp models.PublicParams
  7629. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  7630. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  7631. pp.FixmedinsName = miConfig.OrgName
  7632. pp.FixmedinsCode = miConfig.Code
  7633. pp.RequestUrl = miConfig.Url
  7634. pp.Cainfo = miConfig.Cainfo
  7635. pp.SecretKey = miConfig.SecretKey
  7636. pp.AccessKey = miConfig.AccessKey
  7637. pp.OpterName = roles.UserName
  7638. var config []*models.HisXtDiagnoseConfig
  7639. for _, item := range diagnosis_ids {
  7640. id, _ := strconv.ParseInt(item, 10, 64)
  7641. diagnosisConfig, _ := service.FindDiagnoseById(id)
  7642. config = append(config, &diagnosisConfig)
  7643. }
  7644. var pd models.PatientDtos
  7645. pd.PatnID = his.PsnNo
  7646. pd.PatnName = his.Name
  7647. pd.Gend = his.Gend
  7648. pd.Brdy = psn_info.Brdy
  7649. pd.Poolarea = his.InsuplcAdmdvs
  7650. pd.CurrMdtrtID = his.Number
  7651. var fed models.FsiEncounterDtos
  7652. fed.MdtrtID = his.Number
  7653. fed.MedinsID = miConfig.Code
  7654. fed.MedinsName = miConfig.OrgName
  7655. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  7656. fed.MedMdtrtType = "1"
  7657. fed.MedinsType = "1"
  7658. fed.MedinsLv = "11"
  7659. tm := time.Unix(his.RecordDate, 0)
  7660. s_tm := tm.Format("2006-01-02 15:04:05")
  7661. fed.AdmDate = s_tm
  7662. fed.DscgDate = s_tm
  7663. fed.DscgMainDiseCodg = config[0].CountryCode
  7664. fed.DscgMainDiseName = config[0].CountryContentName
  7665. //诊断信息
  7666. var fdds []*models.FsiDiagnoseDtos
  7667. for index, item := range config {
  7668. if index == 0 {
  7669. var fdd models.FsiDiagnoseDtos
  7670. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  7671. fdd.InoutDiseType = "1"
  7672. fdd.MaindiseFlag = "1"
  7673. fdd.DiseDate = s_tm
  7674. fdd.DiasSrtNo = "1"
  7675. fdd.DiseName = item.CountryContentName
  7676. fdd.DiseCodg = item.CountryCode
  7677. fdds = append(fdds, &fdd)
  7678. } else {
  7679. var fdd models.FsiDiagnoseDtos
  7680. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  7681. fdd.InoutDiseType = "1"
  7682. fdd.MaindiseFlag = "1"
  7683. fdd.DiseDate = s_tm
  7684. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  7685. fdd.DiseName = item.CountryContentName
  7686. fdd.DiseCodg = item.CountryCode
  7687. fdds = append(fdds, &fdd)
  7688. }
  7689. }
  7690. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  7691. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  7692. fed.AdmDeptName = department.Name
  7693. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  7694. fed.DscgDeptName = department.Name
  7695. fed.MedType = order.MedType
  7696. //处方医嘱信息
  7697. var orders []*models.FsiOrderDtos
  7698. //for _, item := range prescriptions {
  7699. // for _, subItem := range item.HisDoctorAdviceInfo {
  7700. // var order models.FsiOrderDtos
  7701. // order.RxID = strconv.FormatInt(item.ID, 10)
  7702. // order.Rxno = strconv.FormatInt(item.ID, 10)
  7703. // order.LongDrordFlag = "0"
  7704. // order.HilistType = "1"
  7705. // order.ChrgType = "1"
  7706. // order.DrordBhvr = "-"
  7707. // order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  7708. // order.HosplistName = subItem.BaseDrugLib.DrugName
  7709. // order.HilistLv = "1"
  7710. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  7711. // order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  7712. // order.HosplistName = subItem.BaseDrugLib.DrugName
  7713. // order.Cnt = strconv.FormatFloat(subItem.PrescribingNumber, 'E', -1, 64)
  7714. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  7715. // order.Sumamt = strconv.FormatFloat((subItem.Price * subItem.PrescribingNumber), 'E', -1, 64)
  7716. // order.OwnpayAmt = ""
  7717. // order.SelfpayAmt = ""
  7718. // order.Spec = ""
  7719. // order.SpecUnt = ""
  7720. // order.DrordBegnDate = s_tm
  7721. // order.DrordStopDate = ""
  7722. // order.DrordDrCodg = "1"
  7723. // order.DrordDeptName = department.Name
  7724. // order.DrordDrCodg = "1"
  7725. // order.DrordDrName = doctor_info.UserName
  7726. // order.DrordDrProfttl = ""
  7727. // order.CurrDrordFlag = "1"
  7728. // orders = append(orders, &order)
  7729. // }
  7730. // for _, subItem := range item.HisPrescriptionProject {
  7731. // if subItem.Type == 2 {
  7732. // var order models.FsiOrderDtos
  7733. // order.RxID = strconv.FormatInt(item.ID, 10)
  7734. // order.Rxno = strconv.FormatInt(item.ID, 10)
  7735. // order.LongDrordFlag = "0"
  7736. // order.HilistType = "1"
  7737. // order.ChrgType = "1"
  7738. // order.DrordBhvr = "-"
  7739. // order.HilistCode = subItem.HisProject.MedicalCode
  7740. // order.HosplistName = subItem.HisProject.ProjectName
  7741. // order.HilistLv = "1"
  7742. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  7743. // order.HosplistCode = subItem.HisProject.MedicalCode
  7744. // order.HosplistName = subItem.HisProject.ProjectName
  7745. // order.Cnt = subItem.Count
  7746. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  7747. //
  7748. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  7749. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  7750. // order.OwnpayAmt = ""
  7751. // order.SelfpayAmt = ""
  7752. // order.Spec = ""
  7753. // order.SpecUnt = ""
  7754. // order.DrordBegnDate = s_tm
  7755. // order.DrordStopDate = ""
  7756. // order.DrordDrCodg = "1"
  7757. // order.DrordDeptName = department.Name
  7758. // order.DrordDrCodg = "1"
  7759. // order.DrordDrName = doctor_info.UserName
  7760. // order.DrordDrProfttl = ""
  7761. // order.CurrDrordFlag = "1"
  7762. // orders = append(orders, &order)
  7763. //
  7764. // }
  7765. // if subItem.Type == 3 {
  7766. //
  7767. // var order models.FsiOrderDtos
  7768. // order.RxID = strconv.FormatInt(item.ID, 10)
  7769. // order.Rxno = strconv.FormatInt(item.ID, 10)
  7770. // order.LongDrordFlag = "0"
  7771. // order.HilistType = "1"
  7772. // order.ChrgType = "1"
  7773. // order.DrordBhvr = "-"
  7774. // order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  7775. // order.HosplistName = subItem.GoodInfo.GoodName
  7776. // order.HilistLv = "1"
  7777. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  7778. // order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  7779. // order.HosplistName = subItem.GoodInfo.GoodName
  7780. // order.Cnt = subItem.Count
  7781. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  7782. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  7783. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  7784. // order.OwnpayAmt = ""
  7785. // order.SelfpayAmt = ""
  7786. // order.Spec = ""
  7787. // order.SpecUnt = ""
  7788. // order.DrordBegnDate = s_tm
  7789. // order.DrordStopDate = ""
  7790. // order.DrordDrCodg = "1"
  7791. // order.DrordDeptName = department.Name
  7792. // order.DrordDrCodg = "1"
  7793. // order.DrordDrName = doctor_info.UserName
  7794. // order.DrordDrProfttl = ""
  7795. // order.CurrDrordFlag = "1"
  7796. // orders = append(orders, &order)
  7797. //
  7798. // }
  7799. // }
  7800. //}
  7801. for _, item := range prescriptions {
  7802. for _, subItem := range item.HisDoctorAdviceInfo {
  7803. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  7804. spec := (subItem.BaseDrugLib.Dose + subItem.BaseDrugLib.DoseUnit) + "*" + strconv.FormatInt(subItem.BaseDrugLib.MinNumber, 10) + subItem.BaseDrugLib.MinUnit + "/" + subItem.BaseDrugLib.MaxUnit
  7805. var order models.FsiOrderDtos
  7806. order.RxID = strconv.FormatInt(item.ID, 10)
  7807. order.Rxno = strconv.FormatInt(item.ID, 10)
  7808. order.LongDrordFlag = "0"
  7809. order.HilistType = "1"
  7810. order.ChrgType = "1"
  7811. order.DrordBhvr = "0"
  7812. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  7813. order.HosplistName = subItem.BaseDrugLib.DrugName
  7814. order.HilistLv = "1"
  7815. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  7816. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  7817. order.HosplistName = subItem.BaseDrugLib.DrugName
  7818. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  7819. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  7820. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  7821. order.OwnpayAmt = ""
  7822. order.SelfpayAmt = ""
  7823. order.Spec = spec
  7824. order.SpecUnt = subItem.PrescribingNumberUnit
  7825. order.DrordBegnDate = s_tm
  7826. order.DrordStopDate = ""
  7827. order.DrordDrCodg = doctor_info.DoctorNumber
  7828. order.DrordDeptName = department.Name
  7829. order.DrordDeptCodg = department.Number
  7830. order.DrordDrName = doctor_info.UserName
  7831. order.DrordDrProfttl = "234"
  7832. order.CurrDrordFlag = "1"
  7833. orders = append(orders, &order)
  7834. }
  7835. }
  7836. for _, subItem := range item.HisPrescriptionProject {
  7837. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  7838. var order models.FsiOrderDtos
  7839. order.RxID = strconv.FormatInt(item.ID, 10)
  7840. order.Rxno = strconv.FormatInt(item.ID, 10)
  7841. order.LongDrordFlag = "0"
  7842. order.HilistType = "1"
  7843. order.ChrgType = "1"
  7844. order.DrordBhvr = "0"
  7845. order.HilistCode = subItem.HisProject.MedicalCode
  7846. order.HosplistName = subItem.HisProject.ProjectName
  7847. order.HilistLv = "1"
  7848. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  7849. order.HosplistCode = subItem.HisProject.MedicalCode
  7850. order.HosplistName = subItem.HisProject.ProjectName
  7851. order.Cnt = subItem.Count
  7852. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  7853. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  7854. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  7855. order.OwnpayAmt = ""
  7856. order.SelfpayAmt = ""
  7857. order.Spec = subItem.Unit
  7858. order.SpecUnt = subItem.Unit
  7859. order.DrordBegnDate = s_tm
  7860. order.DrordStopDate = ""
  7861. order.DrordDrCodg = doctor_info.DoctorNumber
  7862. order.DrordDeptName = department.Name
  7863. order.DrordDeptCodg = department.Number
  7864. order.DrordDrName = doctor_info.UserName
  7865. order.DrordDrProfttl = "234"
  7866. order.CurrDrordFlag = "1"
  7867. orders = append(orders, &order)
  7868. }
  7869. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  7870. var order models.FsiOrderDtos
  7871. order.RxID = strconv.FormatInt(item.ID, 10)
  7872. order.Rxno = strconv.FormatInt(item.ID, 10)
  7873. order.LongDrordFlag = "0"
  7874. order.HilistType = "1"
  7875. order.ChrgType = "1"
  7876. order.DrordBhvr = "0"
  7877. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  7878. order.HosplistName = subItem.GoodInfo.GoodName
  7879. order.HilistLv = "1"
  7880. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  7881. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  7882. order.HosplistName = subItem.GoodInfo.GoodName
  7883. order.Cnt = subItem.Count
  7884. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  7885. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  7886. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  7887. order.OwnpayAmt = ""
  7888. order.SelfpayAmt = ""
  7889. order.Spec = subItem.GoodInfo.SpecificationName
  7890. order.SpecUnt = subItem.Unit
  7891. order.DrordBegnDate = s_tm
  7892. order.DrordStopDate = ""
  7893. order.DrordDrCodg = doctor_info.DoctorNumber
  7894. order.DrordDeptName = department.Name
  7895. order.DrordDeptCodg = department.Number
  7896. order.DrordDrName = doctor_info.UserName
  7897. order.DrordDrProfttl = "234"
  7898. order.CurrDrordFlag = "1"
  7899. orders = append(orders, &order)
  7900. }
  7901. }
  7902. }
  7903. //处方医嘱信息
  7904. fed.MatnStas = "0"
  7905. fed.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  7906. fed.OwnpayAmt = fmt.Sprintf("%.2f", order.FulamtOwnpayAmt)
  7907. fed.SelfpayAmt = fmt.Sprintf("%.2f", order.PreselfpayAmt)
  7908. fed.AcctPayamt = fmt.Sprintf("%.2f", order.AcctPay)
  7909. fed.MaAmt = fmt.Sprintf("%.2f", order.MafPay)
  7910. fed.HifpPayamt = fmt.Sprintf("%.2f", order.HifpPay)
  7911. fed.SetlTotlnum = "1"
  7912. fed.Insutype = his.Insutype
  7913. fed.ReimFlag = "0"
  7914. fed.OutSetlFlag = "0"
  7915. var fopd []*models.FsiOperationDtosData
  7916. data := make(map[string]interface{})
  7917. data["fed"] = fed
  7918. data["fdd"] = fdds
  7919. data["fod"] = orders
  7920. data["pd"] = pd
  7921. data["pp"] = pp
  7922. data["fopd"] = fopd
  7923. data["trig_scen"] = trig_scen
  7924. client := &http.Client{}
  7925. bytesData, _ := json.Marshal(data)
  7926. var req *http.Request
  7927. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7928. if miConfig.MdtrtareaAdmvs == "320921" {
  7929. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  7930. } else {
  7931. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  7932. }
  7933. resp, _ := client.Do(req)
  7934. defer resp.Body.Close()
  7935. body, ioErr := ioutil.ReadAll(resp.Body)
  7936. if ioErr != nil {
  7937. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7938. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7939. return res
  7940. }
  7941. var respJSON map[string]interface{}
  7942. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7943. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7944. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7945. return res
  7946. }
  7947. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  7948. result, _ := json.Marshal(respJSON)
  7949. if err := json.Unmarshal([]byte(result), &res); err != nil {
  7950. utils.ErrorLog("解析失败:%v", err)
  7951. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7952. return res
  7953. }
  7954. return res
  7955. } else {
  7956. output, input := service.Gdyb3102(pd, fed, fdds, orders, fopd, pp, trig_scen)
  7957. saveLog(output, input, "3102", "事中")
  7958. if err := json.Unmarshal([]byte(output), &res); err != nil {
  7959. utils.ErrorLog("解析失败:%v", err)
  7960. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7961. return
  7962. }
  7963. return res
  7964. }
  7965. return res
  7966. }
  7967. func (c *HisApiController) Check() {
  7968. psn_no := c.GetString("psn_no")
  7969. in := c.GetString("in")
  7970. mt := c.GetString("mt")
  7971. baseParams := models.BaseParams{
  7972. SecretKey: "MSDBYGxXm1Mtyi3PtOUB7n1ktcxwyW57",
  7973. FixmedinsCode: "H15049901371",
  7974. InsuplcAdmdvs: "150499",
  7975. MdtrtareaAdmvs: "150499",
  7976. OrgName: "赤峰费森血液透析中心",
  7977. Doctor: "1111",
  7978. }
  7979. service.Gdyb2001(baseParams, psn_no, in, mt)
  7980. }
  7981. func (c *HisApiController) GetPsnNcdsInfo() {
  7982. admin_user_id, _ := c.GetInt64("admin_user_id")
  7983. patient_id, _ := c.GetInt64("patient_id")
  7984. //id, _ := c.GetInt64("id")
  7985. adminUser := c.GetAdminUserInfo()
  7986. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7987. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  7988. //patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  7989. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7990. //psn_record, _ := service.GetP(id)
  7991. psn_info, _ := service.GetPsnByPatientId(patient_id)
  7992. //psn_record, _ := service.GetPsnNCDSRecordById(id)
  7993. //
  7994. //if psn_record.ID == 0 {
  7995. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  7996. // return
  7997. //}
  7998. var res Result5301
  7999. var res10265 Result5301For10265
  8000. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  8001. psn_info, _ := service.GetPsnByPatientId(patient_id)
  8002. var api string
  8003. if miConfig.MdtrtareaAdmvs == "320921" {
  8004. 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 +
  8005. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  8006. } else {
  8007. 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 +
  8008. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  8009. }
  8010. resp, requestErr := http.Get(api)
  8011. if requestErr != nil {
  8012. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8013. return
  8014. }
  8015. body, ioErr := ioutil.ReadAll(resp.Body)
  8016. if ioErr != nil {
  8017. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8018. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8019. return
  8020. }
  8021. var respJSON map[string]interface{}
  8022. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8023. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8024. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8025. return
  8026. }
  8027. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8028. result, _ := json.Marshal(respJSON)
  8029. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  8030. utils.ErrorLog("解析失败:%v", err)
  8031. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8032. return
  8033. }
  8034. res.ErrMsg = res10265.ErrMsg
  8035. res.Output = res10265.Output
  8036. res.InfRefmsgid = res10265.InfRefmsgid
  8037. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  8038. res.Infcode = infocode
  8039. } else if miConfig.MdtrtareaAdmvs == "341203" {
  8040. psn_info, _ := service.GetPsnByPatientId(patient_id)
  8041. var api string
  8042. api = miConfig.SecretKey + "ahyb/5301?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName +
  8043. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  8044. resp, requestErr := http.Get(api)
  8045. if requestErr != nil {
  8046. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8047. return
  8048. }
  8049. body, ioErr := ioutil.ReadAll(resp.Body)
  8050. if ioErr != nil {
  8051. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8052. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8053. return
  8054. }
  8055. var respJSON map[string]interface{}
  8056. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8057. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8058. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8059. return
  8060. }
  8061. status := respJSON["data"].(map[string]interface{})["status"].(string)
  8062. if status == "0" {
  8063. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  8064. c.ServeSuccessJSON(map[string]interface{}{
  8065. "failed_code": -10,
  8066. "msg": err_msg,
  8067. })
  8068. return
  8069. }
  8070. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8071. result, _ := json.Marshal(respJSON)
  8072. if err := json.Unmarshal([]byte(result), &res); err != nil {
  8073. utils.ErrorLog("解析失败:%v", err)
  8074. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8075. return
  8076. }
  8077. } else if miConfig.MdtrtareaAdmvs == "360302" {
  8078. p, _ := service.GetHisPatientById(patient_id)
  8079. result, _ := service.Jxyb5301(p.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, "")
  8080. var dat map[string]interface{}
  8081. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8082. fmt.Println(dat)
  8083. } else {
  8084. fmt.Println(err)
  8085. }
  8086. userJSONBytes, _ := json.Marshal(dat)
  8087. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8088. utils.ErrorLog("解析失败:%v", err)
  8089. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8090. return
  8091. }
  8092. } else if miConfig.MdtrtareaAdmvs == "430800" {
  8093. p, _ := service.GetHisPatientById(patient_id)
  8094. result, _ := service.Hnyb5301(p.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, "")
  8095. var dat map[string]interface{}
  8096. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8097. fmt.Println(dat)
  8098. } else {
  8099. fmt.Println(err)
  8100. }
  8101. userJSONBytes, _ := json.Marshal(dat)
  8102. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8103. utils.ErrorLog("解析失败:%v", err)
  8104. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8105. return
  8106. }
  8107. } else if miConfig.MdtrtareaAdmvs == "420200" {
  8108. p, _ := service.GetHisPatientById(patient_id)
  8109. api := "http://192.168.0.197:9532/" + "/hbyb/5301?psn_no=" + p.PsnNo +
  8110. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  8111. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  8112. resp, requestErr := http.Get(api)
  8113. if requestErr != nil {
  8114. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8115. return
  8116. }
  8117. body, ioErr := ioutil.ReadAll(resp.Body)
  8118. if ioErr != nil {
  8119. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8120. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8121. return
  8122. }
  8123. var respJSON map[string]interface{}
  8124. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8125. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8126. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8127. return
  8128. }
  8129. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8130. result, _ := json.Marshal(respJSON)
  8131. if err := json.Unmarshal([]byte(result), &res); err != nil {
  8132. utils.ErrorLog("解析失败:%v", err)
  8133. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8134. return
  8135. }
  8136. } else if miConfig.MdtrtareaAdmvs == "420902" {
  8137. p, _ := service.GetHisPatientById(patient_id)
  8138. api := miConfig.Url + "hbyb/5301?psn_no=" + p.PsnNo +
  8139. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  8140. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  8141. resp, requestErr := http.Get(api)
  8142. if requestErr != nil {
  8143. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8144. return
  8145. }
  8146. body, ioErr := ioutil.ReadAll(resp.Body)
  8147. if ioErr != nil {
  8148. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8149. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8150. return
  8151. }
  8152. var respJSON map[string]interface{}
  8153. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8154. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8155. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8156. return
  8157. }
  8158. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8159. result, _ := json.Marshal(respJSON)
  8160. if err := json.Unmarshal([]byte(result), &res); err != nil {
  8161. utils.ErrorLog("解析失败:%v", err)
  8162. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8163. return
  8164. }
  8165. } else if miConfig.MdtrtareaAdmvs == "421182" {
  8166. p, _ := service.GetHisPatientById(patient_id)
  8167. api := miConfig.Url + "/hbyb/5301?psn_no=" + p.PsnNo +
  8168. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  8169. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  8170. resp, requestErr := http.Get(api)
  8171. if requestErr != nil {
  8172. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8173. return
  8174. }
  8175. body, ioErr := ioutil.ReadAll(resp.Body)
  8176. if ioErr != nil {
  8177. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8178. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8179. return
  8180. }
  8181. var respJSON map[string]interface{}
  8182. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8183. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8184. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8185. return
  8186. }
  8187. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8188. result, _ := json.Marshal(respJSON)
  8189. if err := json.Unmarshal([]byte(result), &res); err != nil {
  8190. utils.ErrorLog("解析失败:%v", err)
  8191. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8192. return
  8193. }
  8194. } else if miConfig.MdtrtareaAdmvs == "420902" {
  8195. p, _ := service.GetHisPatientById(patient_id)
  8196. api := miConfig.Url + "/hbyb/5301?psn_no=" + p.PsnNo +
  8197. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  8198. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  8199. resp, requestErr := http.Get(api)
  8200. if requestErr != nil {
  8201. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8202. return
  8203. }
  8204. body, ioErr := ioutil.ReadAll(resp.Body)
  8205. if ioErr != nil {
  8206. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8207. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8208. return
  8209. }
  8210. var respJSON map[string]interface{}
  8211. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8212. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8213. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8214. return
  8215. }
  8216. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8217. result, _ := json.Marshal(respJSON)
  8218. if err := json.Unmarshal([]byte(result), &res); err != nil {
  8219. utils.ErrorLog("解析失败:%v", err)
  8220. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8221. return
  8222. }
  8223. } else if miConfig.MdtrtareaAdmvs == "421300" {
  8224. p, _ := service.GetHisPatientById(patient_id)
  8225. api := "http://192.168.124.4:9532/" + "/hbyb/5301?psn_no=" + p.PsnNo +
  8226. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  8227. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  8228. resp, requestErr := http.Get(api)
  8229. if requestErr != nil {
  8230. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8231. return
  8232. }
  8233. body, ioErr := ioutil.ReadAll(resp.Body)
  8234. if ioErr != nil {
  8235. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8236. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8237. return
  8238. }
  8239. var respJSON map[string]interface{}
  8240. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8241. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8242. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8243. return
  8244. }
  8245. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8246. result, _ := json.Marshal(respJSON)
  8247. if err := json.Unmarshal([]byte(result), &res); err != nil {
  8248. utils.ErrorLog("解析失败:%v", err)
  8249. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8250. return
  8251. }
  8252. } else if miConfig.MdtrtareaAdmvs == "441799" {
  8253. p, _ := service.GetHisPatientById(patient_id)
  8254. api := miConfig.Url + "gdyb/5301?psn_no=" + p.PsnNo +
  8255. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  8256. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  8257. resp, requestErr := http.Get(api)
  8258. if requestErr != nil {
  8259. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8260. return
  8261. }
  8262. body, ioErr := ioutil.ReadAll(resp.Body)
  8263. if ioErr != nil {
  8264. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8265. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8266. return
  8267. }
  8268. var respJSON map[string]interface{}
  8269. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8270. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8271. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8272. return
  8273. }
  8274. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8275. result, _ := json.Marshal(respJSON)
  8276. if err := json.Unmarshal([]byte(result), &res); err != nil {
  8277. utils.ErrorLog("解析失败:%v", err)
  8278. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8279. return
  8280. }
  8281. } else {
  8282. result := service.Gdyb5301(psn_info.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  8283. var dat map[string]interface{}
  8284. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8285. fmt.Println(dat)
  8286. } else {
  8287. fmt.Println(err)
  8288. }
  8289. userJSONBytes, _ := json.Marshal(dat)
  8290. if miConfig.Code == "H15049901371" {
  8291. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  8292. utils.ErrorLog("解析失败:%v", err)
  8293. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8294. return
  8295. }
  8296. res.InfRefmsgid = res10265.InfRefmsgid
  8297. res.Output = res10265.Output
  8298. res.ErrMsg = res10265.ErrMsg
  8299. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  8300. res.Infcode = infocode
  8301. } else {
  8302. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8303. utils.ErrorLog("解析失败:%v", err)
  8304. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8305. return
  8306. }
  8307. }
  8308. }
  8309. if res.Infcode == 0 {
  8310. c.ServeSuccessJSON(map[string]interface{}{
  8311. "result": res.Output.Result,
  8312. })
  8313. }
  8314. }
  8315. func (c *HisApiController) CheckInsutype() {
  8316. his_patient_id, _ := c.GetInt64("his_patient_id")
  8317. admin_user_id, _ := c.GetInt64("admin_user_id")
  8318. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8319. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  8320. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8321. result := service.Gdyb90100(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  8322. var dat map[string]interface{}
  8323. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8324. fmt.Println(dat)
  8325. } else {
  8326. fmt.Println(err)
  8327. }
  8328. userJSONBytes, _ := json.Marshal(dat)
  8329. var res Result90100
  8330. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8331. utils.ErrorLog("解析失败:%v", err)
  8332. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8333. return
  8334. }
  8335. if res.Infcode != 0 {
  8336. c.ServeSuccessJSON(map[string]interface{}{
  8337. "failed_code": -10,
  8338. "msg": res.ErrMsg,
  8339. })
  8340. return
  8341. } else {
  8342. fmt.Println(res)
  8343. }
  8344. }
  8345. func (c *HisApiController) CheckCardPWD() {
  8346. card_pwd := c.GetString("card_pwd")
  8347. his_patient_id, _ := c.GetInt64("his_patient_id")
  8348. admin_user_id, _ := c.GetInt64("admin_user_id")
  8349. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8350. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8351. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  8352. psn, _ := service.GetPsnByPatientId(his.PatientId)
  8353. bas := strings.Split(psn.CardInfo, "|")
  8354. basNumber := bas[2]
  8355. if psn.InsuplcAdmdvs[:4] == "4403" {
  8356. result := service.Gdyb90991(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, card_pwd, basNumber)
  8357. var dat map[string]interface{}
  8358. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8359. fmt.Println(dat)
  8360. } else {
  8361. fmt.Println(err)
  8362. }
  8363. userJSONBytes, _ := json.Marshal(dat)
  8364. var res Result90991
  8365. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8366. utils.ErrorLog("解析失败:%v", err)
  8367. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8368. return
  8369. }
  8370. if res.Infcode != 0 {
  8371. c.ServeSuccessJSON(map[string]interface{}{
  8372. "failed_code": -10,
  8373. "msg": res.ErrMsg,
  8374. })
  8375. return
  8376. } else {
  8377. if res.Output.Result.SscnoCheckStat == "0" && res.Output.Result.CardStat != "10" {
  8378. var msg string
  8379. switch res.Output.Result.CardStat {
  8380. case "00":
  8381. msg = "未激活"
  8382. break
  8383. case "10":
  8384. msg = "激活"
  8385. break
  8386. case "20":
  8387. msg = "窗口挂失"
  8388. break
  8389. case "21":
  8390. msg = "电话挂失"
  8391. break
  8392. case "22":
  8393. msg = "单位网上申报挂失"
  8394. break
  8395. case "23":
  8396. msg = "保健办挂失"
  8397. break
  8398. case "24":
  8399. msg = "个人网上挂失"
  8400. break
  8401. case "25":
  8402. msg = "网上服务大厅挂失"
  8403. break
  8404. case "30":
  8405. msg = "注销"
  8406. break
  8407. case "40":
  8408. msg = "回收"
  8409. break
  8410. case "99":
  8411. msg = "制卡中(无效卡)"
  8412. break
  8413. }
  8414. c.ServeSuccessJSON(map[string]interface{}{
  8415. "failed_code": -10,
  8416. "msg": msg,
  8417. })
  8418. return
  8419. } else {
  8420. c.ServeSuccessJSON(map[string]interface{}{
  8421. "msg": "校验成功",
  8422. })
  8423. return
  8424. }
  8425. }
  8426. } else {
  8427. c.ServeSuccessJSON(map[string]interface{}{
  8428. "msg": "校验成功",
  8429. })
  8430. return
  8431. }
  8432. }
  8433. func (c *HisApiController) CheckCardPWDTwo() {
  8434. //card_pwd := c.GetString("card_pwd")
  8435. //his_patient_id, _ := c.GetInt64("his_patient_id")
  8436. admin_user_id, _ := c.GetInt64("admin_user_id")
  8437. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8438. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8439. result := service.Gdyb90991("44030000000629690364", miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, "000000", "BDM421363")
  8440. var dat map[string]interface{}
  8441. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8442. fmt.Println(dat)
  8443. } else {
  8444. fmt.Println(err)
  8445. }
  8446. userJSONBytes, _ := json.Marshal(dat)
  8447. var res Result90991
  8448. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8449. utils.ErrorLog("解析失败:%v", err)
  8450. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8451. return
  8452. }
  8453. if res.Infcode != 0 {
  8454. c.ServeSuccessJSON(map[string]interface{}{
  8455. "failed_code": -10,
  8456. "msg": res.ErrMsg,
  8457. })
  8458. return
  8459. } else {
  8460. if res.Output.Result.SscnoCheckStat == "0" {
  8461. var msg string
  8462. switch res.Output.Result.CardStat {
  8463. case "00":
  8464. msg = "未激活"
  8465. break
  8466. case "10":
  8467. msg = "激活"
  8468. break
  8469. case "20":
  8470. msg = "窗口挂失"
  8471. break
  8472. case "21":
  8473. msg = "电话挂失"
  8474. break
  8475. case "22":
  8476. msg = "单位网上申报挂失"
  8477. break
  8478. case "23":
  8479. msg = "保健办挂失"
  8480. break
  8481. case "24":
  8482. msg = "个人网上挂失"
  8483. break
  8484. case "25":
  8485. msg = "网上服务大厅挂失"
  8486. break
  8487. case "30":
  8488. msg = "注销"
  8489. break
  8490. case "40":
  8491. msg = "回收"
  8492. break
  8493. case "99":
  8494. msg = "制卡中(无效卡)"
  8495. break
  8496. }
  8497. c.ServeSuccessJSON(map[string]interface{}{
  8498. "failed_code": -10,
  8499. "msg": msg,
  8500. })
  8501. return
  8502. } else {
  8503. c.ServeSuccessJSON(map[string]interface{}{
  8504. "msg": "校验成功",
  8505. })
  8506. return
  8507. }
  8508. }
  8509. }
  8510. type ELeCertData struct {
  8511. Data struct {
  8512. Extra string `json:"extra"`
  8513. IDNo string `json:"idNo"`
  8514. IDType string `json:"idType"`
  8515. EcToken string `json:"ecToken"`
  8516. InsuOrg string `json:"insuOrg"`
  8517. UserName string `json:"userName"`
  8518. EcIndexNo string `json:"ecIndexNo"`
  8519. Gender string `json:"gender"`
  8520. Birthday string `json:"birthday"`
  8521. Nationality string `json:"nationality"`
  8522. Email string `json:"email"`
  8523. } `json:"OutData"`
  8524. }
  8525. func (c *HisApiController) ReadCard() {
  8526. id_card_type, _ := c.GetInt64("id_card_type")
  8527. admin_user_id, _ := c.GetInt64("admin_user_id")
  8528. certificates, _ := c.GetInt64("certificates")
  8529. //insuplc_admdvs_str := c.GetString("insuplc_admdvs")
  8530. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8531. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8532. switch id_card_type {
  8533. case 1:
  8534. if miConfig.MdtrtareaAdmvs == "421300" {
  8535. var res ResultTwo
  8536. api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  8537. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  8538. "&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)
  8539. resp, requestErr := http.Get(api)
  8540. if requestErr != nil {
  8541. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8542. return
  8543. }
  8544. body, ioErr := ioutil.ReadAll(resp.Body)
  8545. if ioErr != nil {
  8546. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8547. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8548. return
  8549. }
  8550. var respJSON map[string]interface{}
  8551. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8552. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8553. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8554. return
  8555. }
  8556. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8557. result, _ := json.Marshal(respJSON)
  8558. fmt.Println("log")
  8559. fmt.Println(string(result))
  8560. if err := json.Unmarshal([]byte(result), &res); err != nil {
  8561. utils.ErrorLog("解析失败:%v", err)
  8562. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8563. return
  8564. }
  8565. if res.Infcode == 0 {
  8566. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  8567. if err == gorm.ErrRecordNotFound {
  8568. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  8569. return
  8570. } else if err != nil {
  8571. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  8572. return
  8573. } else {
  8574. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  8575. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  8576. infoStr := string(Iinfos)
  8577. idetinfoStr := string(Idetinfos)
  8578. var rf []*ResultFive
  8579. json.Unmarshal([]byte(infoStr), &rf)
  8580. var insutypes []*ResultFive
  8581. var insutype string
  8582. var is390 int = 0
  8583. var is310 int = 0
  8584. for _, item := range rf {
  8585. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  8586. insutypes = append(insutypes, item)
  8587. }
  8588. }
  8589. if len(insutypes) == 1 {
  8590. insutype = insutypes[0].Insutype
  8591. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  8592. } else {
  8593. for _, i := range insutypes {
  8594. if i.Insutype == "390" {
  8595. is390 = 1
  8596. }
  8597. if i.Insutype == "310" {
  8598. is310 = 1
  8599. }
  8600. }
  8601. }
  8602. if is390 == 1 {
  8603. insutype = "390"
  8604. }
  8605. if is310 == 1 {
  8606. insutype = "310"
  8607. }
  8608. if len(insutypes) == 0 {
  8609. insutype = "390"
  8610. }
  8611. var insuplc_admdvs string
  8612. for _, item := range rf {
  8613. if item.Insutype == insutype {
  8614. insuplc_admdvs = item.InsuplcAdmdvs
  8615. }
  8616. }
  8617. if strings.Contains(insuplc_admdvs, "4213") {
  8618. insuplc_admdvs = miConfig.MdtrtareaAdmvs
  8619. }
  8620. psn := &models.HisPsn{
  8621. PsnNo: res.Output.Baseinfo.PsnNo,
  8622. PatientId: patient.ID,
  8623. Certno: res.Output.Baseinfo.Certno,
  8624. Gend: res.Output.Baseinfo.Gend,
  8625. Naty: res.Output.Baseinfo.Naty,
  8626. PsnCertType: res.Output.Baseinfo.PsnCertType,
  8627. PsnName: res.Output.Baseinfo.PsnName,
  8628. Idetinfo: idetinfoStr,
  8629. Insuinfo: infoStr,
  8630. InsuplcAdmdvs: insuplc_admdvs,
  8631. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  8632. }
  8633. service.CreateHisPsn(psn)
  8634. c.ServeSuccessJSON(map[string]interface{}{
  8635. "patient": patient,
  8636. "number": res.Output.Baseinfo.Certno,
  8637. })
  8638. }
  8639. } else {
  8640. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  8641. return
  8642. }
  8643. } else if miConfig.MdtrtareaAdmvs == "420200" {
  8644. var res ResultTwo
  8645. api := "http://192.168.0.197:9532/" + "hbyb/1101?cert_no=" + "" +
  8646. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  8647. "&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)
  8648. resp, requestErr := http.Get(api)
  8649. if requestErr != nil {
  8650. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8651. return
  8652. }
  8653. body, ioErr := ioutil.ReadAll(resp.Body)
  8654. if ioErr != nil {
  8655. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8656. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8657. return
  8658. }
  8659. var respJSON map[string]interface{}
  8660. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8661. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8662. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8663. return
  8664. }
  8665. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8666. result, _ := json.Marshal(respJSON)
  8667. fmt.Println("log")
  8668. fmt.Println(string(result))
  8669. if err := json.Unmarshal([]byte(result), &res); err != nil {
  8670. utils.ErrorLog("解析失败:%v", err)
  8671. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8672. return
  8673. }
  8674. if res.Infcode == 0 {
  8675. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  8676. if err == gorm.ErrRecordNotFound {
  8677. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  8678. return
  8679. } else if err != nil {
  8680. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  8681. return
  8682. } else {
  8683. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  8684. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  8685. infoStr := string(Iinfos)
  8686. idetinfoStr := string(Idetinfos)
  8687. psn := &models.HisPsn{
  8688. PsnNo: res.Output.Baseinfo.PsnNo,
  8689. PatientId: patient.ID,
  8690. Certno: res.Output.Baseinfo.Certno,
  8691. Gend: res.Output.Baseinfo.Gend,
  8692. Naty: res.Output.Baseinfo.Naty,
  8693. PsnCertType: res.Output.Baseinfo.PsnCertType,
  8694. PsnName: res.Output.Baseinfo.PsnName,
  8695. Idetinfo: idetinfoStr,
  8696. Insuinfo: infoStr,
  8697. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  8698. }
  8699. service.CreateHisPsn(psn)
  8700. var rf []*ResultFive
  8701. json.Unmarshal([]byte(infoStr), &rf)
  8702. var insutypes []*ResultFive
  8703. var insutype string
  8704. var is390 int = 0
  8705. var is310 int = 0
  8706. for _, item := range rf {
  8707. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  8708. insutypes = append(insutypes, item)
  8709. }
  8710. }
  8711. if len(insutypes) == 1 {
  8712. insutype = insutypes[0].Insutype
  8713. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  8714. } else {
  8715. for _, i := range insutypes {
  8716. if i.Insutype == "390" {
  8717. is390 = 1
  8718. }
  8719. if i.Insutype == "310" {
  8720. is310 = 1
  8721. }
  8722. }
  8723. }
  8724. if is390 == 1 {
  8725. insutype = "390"
  8726. }
  8727. if is310 == 1 {
  8728. insutype = "310"
  8729. }
  8730. if len(insutypes) == 0 {
  8731. insutype = "310"
  8732. }
  8733. c.ServeSuccessJSON(map[string]interface{}{
  8734. "patient": patient,
  8735. "number": res.Output.Baseinfo.Certno,
  8736. "insutype": insutype,
  8737. })
  8738. }
  8739. } else {
  8740. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  8741. return
  8742. }
  8743. } else if miConfig.MdtrtareaAdmvs == "420902" {
  8744. var res ResultTwo
  8745. api := miConfig.Url + "hbyb/1101?cert_no=" + "" +
  8746. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  8747. "&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)
  8748. resp, requestErr := http.Get(api)
  8749. if requestErr != nil {
  8750. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8751. return
  8752. }
  8753. body, ioErr := ioutil.ReadAll(resp.Body)
  8754. if ioErr != nil {
  8755. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8756. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8757. return
  8758. }
  8759. var respJSON map[string]interface{}
  8760. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8761. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8762. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8763. return
  8764. }
  8765. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8766. result, _ := json.Marshal(respJSON)
  8767. fmt.Println("log")
  8768. fmt.Println(string(result))
  8769. if err := json.Unmarshal([]byte(result), &res); err != nil {
  8770. utils.ErrorLog("解析失败:%v", err)
  8771. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8772. return
  8773. }
  8774. if res.Infcode == 0 {
  8775. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  8776. if err == gorm.ErrRecordNotFound {
  8777. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  8778. return
  8779. } else if err != nil {
  8780. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  8781. return
  8782. } else {
  8783. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  8784. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  8785. infoStr := string(Iinfos)
  8786. idetinfoStr := string(Idetinfos)
  8787. var rf []*ResultFive
  8788. json.Unmarshal([]byte(infoStr), &rf)
  8789. var insutypes []*ResultFive
  8790. var insutype string
  8791. var is390 int = 0
  8792. var is310 int = 0
  8793. for _, item := range rf {
  8794. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  8795. insutypes = append(insutypes, item)
  8796. }
  8797. }
  8798. if len(insutypes) == 1 {
  8799. insutype = insutypes[0].Insutype
  8800. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  8801. } else {
  8802. for _, i := range insutypes {
  8803. if i.Insutype == "390" {
  8804. is390 = 1
  8805. }
  8806. if i.Insutype == "310" {
  8807. is310 = 1
  8808. }
  8809. }
  8810. }
  8811. if is390 == 1 {
  8812. insutype = "390"
  8813. }
  8814. if is310 == 1 {
  8815. insutype = "310"
  8816. }
  8817. if len(insutypes) == 0 {
  8818. insutype = "390"
  8819. }
  8820. var insuplc_admdvs string
  8821. for _, item := range rf {
  8822. if item.Insutype == insutype {
  8823. insuplc_admdvs = item.InsuplcAdmdvs
  8824. }
  8825. }
  8826. psn := &models.HisPsn{
  8827. PsnNo: res.Output.Baseinfo.PsnNo,
  8828. PatientId: patient.ID,
  8829. Certno: res.Output.Baseinfo.Certno,
  8830. Gend: res.Output.Baseinfo.Gend,
  8831. Naty: res.Output.Baseinfo.Naty,
  8832. PsnCertType: res.Output.Baseinfo.PsnCertType,
  8833. PsnName: res.Output.Baseinfo.PsnName,
  8834. Idetinfo: idetinfoStr,
  8835. Insuinfo: infoStr,
  8836. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  8837. InsuplcAdmdvs: insuplc_admdvs,
  8838. }
  8839. service.CreateHisPsn(psn)
  8840. for _, item := range rf {
  8841. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  8842. insutypes = append(insutypes, item)
  8843. }
  8844. }
  8845. if len(insutypes) == 1 {
  8846. insutype = insutypes[0].Insutype
  8847. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  8848. } else {
  8849. for _, i := range insutypes {
  8850. if i.Insutype == "390" {
  8851. is390 = 1
  8852. }
  8853. if i.Insutype == "310" {
  8854. is310 = 1
  8855. }
  8856. }
  8857. }
  8858. if is390 == 1 {
  8859. insutype = "390"
  8860. }
  8861. if is310 == 1 {
  8862. insutype = "310"
  8863. }
  8864. if len(insutypes) == 0 {
  8865. insutype = "310"
  8866. }
  8867. c.ServeSuccessJSON(map[string]interface{}{
  8868. "patient": patient,
  8869. "number": res.Output.Baseinfo.Certno,
  8870. "insutype": insutype,
  8871. })
  8872. }
  8873. } else {
  8874. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  8875. return
  8876. }
  8877. } else if miConfig.MdtrtareaAdmvs == "421182" {
  8878. var res ResultTwo
  8879. api := "http://192.168.0:9532/" + "hbyb/1101?cert_no=" + "" +
  8880. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  8881. "&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)
  8882. resp, requestErr := http.Get(api)
  8883. if requestErr != nil {
  8884. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8885. return
  8886. }
  8887. body, ioErr := ioutil.ReadAll(resp.Body)
  8888. if ioErr != nil {
  8889. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8890. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8891. return
  8892. }
  8893. var respJSON map[string]interface{}
  8894. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8895. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8896. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8897. return
  8898. }
  8899. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8900. result, _ := json.Marshal(respJSON)
  8901. fmt.Println("log")
  8902. fmt.Println(string(result))
  8903. if err := json.Unmarshal([]byte(result), &res); err != nil {
  8904. utils.ErrorLog("解析失败:%v", err)
  8905. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8906. return
  8907. }
  8908. if res.Infcode == 0 {
  8909. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  8910. if err == gorm.ErrRecordNotFound {
  8911. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  8912. return
  8913. } else if err != nil {
  8914. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  8915. return
  8916. } else {
  8917. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  8918. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  8919. infoStr := string(Iinfos)
  8920. idetinfoStr := string(Idetinfos)
  8921. b, age, _ := getBirthdateAndAge(res.Output.Baseinfo.Certno)
  8922. psn := &models.HisPsn{
  8923. PsnNo: res.Output.Baseinfo.PsnNo,
  8924. PatientId: patient.ID,
  8925. Certno: res.Output.Baseinfo.Certno,
  8926. Brdy: b,
  8927. Age: float64(age),
  8928. Gend: res.Output.Baseinfo.Gend,
  8929. Naty: res.Output.Baseinfo.Naty,
  8930. PsnCertType: res.Output.Baseinfo.PsnCertType,
  8931. PsnName: res.Output.Baseinfo.PsnName,
  8932. Idetinfo: idetinfoStr,
  8933. Insuinfo: infoStr,
  8934. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  8935. }
  8936. service.CreateHisPsn(psn)
  8937. var rf []*ResultFive
  8938. json.Unmarshal([]byte(infoStr), &rf)
  8939. var insutypes []*ResultFive
  8940. var insutype string
  8941. var is390 int = 0
  8942. var is310 int = 0
  8943. for _, item := range rf {
  8944. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  8945. insutypes = append(insutypes, item)
  8946. }
  8947. }
  8948. if len(insutypes) == 1 {
  8949. insutype = insutypes[0].Insutype
  8950. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  8951. } else {
  8952. for _, i := range insutypes {
  8953. if i.Insutype == "390" {
  8954. is390 = 1
  8955. }
  8956. if i.Insutype == "310" {
  8957. is310 = 1
  8958. }
  8959. }
  8960. }
  8961. if is390 == 1 {
  8962. insutype = "390"
  8963. }
  8964. if is310 == 1 {
  8965. insutype = "310"
  8966. }
  8967. if len(insutypes) == 0 {
  8968. insutype = "310"
  8969. }
  8970. c.ServeSuccessJSON(map[string]interface{}{
  8971. "patient": patient,
  8972. "number": res.Output.Baseinfo.Certno,
  8973. "insutype": insutype,
  8974. })
  8975. }
  8976. } else {
  8977. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  8978. return
  8979. }
  8980. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  8981. var api string
  8982. if miConfig.MdtrtareaAdmvs == "320921" {
  8983. 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 +
  8984. "&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
  8985. fmt.Println(api)
  8986. } else {
  8987. 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 +
  8988. "&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)
  8989. }
  8990. resp, requestErr := http.Get(api)
  8991. if requestErr != nil {
  8992. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8993. return
  8994. }
  8995. body, ioErr := ioutil.ReadAll(resp.Body)
  8996. if ioErr != nil {
  8997. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8998. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8999. return
  9000. }
  9001. var respJSON map[string]interface{}
  9002. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9003. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9004. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9005. return
  9006. }
  9007. var status string
  9008. status = respJSON["data"].(map[string]interface{})["status"].(string)
  9009. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  9010. //console.log()
  9011. fmt.Println("type===")
  9012. fmt.Println(card_type)
  9013. var token string
  9014. var res ResultTwo //1101结果
  9015. var res10265 ResultTwo10265 //1101结果
  9016. var card_info string //卡信息
  9017. var busi_card_info string
  9018. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  9019. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  9020. if status == "0" { //读卡成功
  9021. if card_type == "1" {
  9022. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  9023. result, _ := json.Marshal(respJSON)
  9024. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  9025. utils.ErrorLog("解析失败:%v", err)
  9026. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9027. return
  9028. }
  9029. res.ErrMsg = res10265.ErrMsg
  9030. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  9031. res.Infcode = infocode
  9032. res.Output = res10265.Output
  9033. res.InfRefmsgid = res10265.InfRefmsgid
  9034. } else {
  9035. //var card_info string //卡信息
  9036. //var busi_card_info string
  9037. token = respJSON["data"].(map[string]interface{})["token"].(string)
  9038. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  9039. //fmt.Println(card_info)
  9040. //fmt.Println(busi_card_info)
  9041. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  9042. result, _ := json.Marshal(respJSON)
  9043. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  9044. utils.ErrorLog("解析失败:%v", err)
  9045. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9046. return
  9047. }
  9048. res.ErrMsg = res10265.ErrMsg
  9049. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  9050. res.Infcode = infocode
  9051. res.Output = res10265.Output
  9052. res.InfRefmsgid = res10265.InfRefmsgid
  9053. }
  9054. if res.Infcode == 0 {
  9055. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  9056. if err == gorm.ErrRecordNotFound {
  9057. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  9058. return
  9059. } else if err != nil {
  9060. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  9061. return
  9062. } else {
  9063. if card_type == "1" {
  9064. bas := strings.Split(card_info, "|")
  9065. basNumber := bas[2]
  9066. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9067. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9068. infoStr := string(Iinfos)
  9069. idetinfoStr := string(Idetinfos)
  9070. b, age, _ := getBirthdateAndAge(res.Output.Baseinfo.Certno)
  9071. psn := &models.HisPsn{
  9072. PsnNo: res.Output.Baseinfo.PsnNo,
  9073. PatientId: patient.ID,
  9074. Certno: res.Output.Baseinfo.Certno,
  9075. Brdy: b,
  9076. Age: float64(age),
  9077. Gend: res.Output.Baseinfo.Gend,
  9078. Naty: res.Output.Baseinfo.Naty,
  9079. PsnCertType: res.Output.Baseinfo.PsnCertType,
  9080. PsnName: res.Output.Baseinfo.PsnName,
  9081. Idetinfo: idetinfoStr,
  9082. Insuinfo: infoStr,
  9083. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9084. CardInfo: card_info,
  9085. VerifyNumber: busi_card_info,
  9086. }
  9087. service.CreateHisPsn(psn)
  9088. var rf []*ResultFive
  9089. json.Unmarshal([]byte(infoStr), &rf)
  9090. var insutypes []*ResultFive
  9091. var insutype string
  9092. var is390 int = 0
  9093. var is310 int = 0
  9094. for _, item := range rf {
  9095. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  9096. insutypes = append(insutypes, item)
  9097. }
  9098. }
  9099. if len(insutypes) == 1 {
  9100. insutype = insutypes[0].Insutype
  9101. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  9102. } else {
  9103. for _, i := range insutypes {
  9104. if i.Insutype == "390" {
  9105. is390 = 1
  9106. }
  9107. if i.Insutype == "310" {
  9108. is310 = 1
  9109. }
  9110. }
  9111. }
  9112. if is390 == 1 {
  9113. insutype = "390"
  9114. }
  9115. if is310 == 1 {
  9116. insutype = "310"
  9117. }
  9118. if len(insutypes) == 0 {
  9119. insutype = "310"
  9120. }
  9121. c.ServeSuccessJSON(map[string]interface{}{
  9122. "patient": patient,
  9123. "number": basNumber,
  9124. "insutype": insutype,
  9125. })
  9126. } else {
  9127. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9128. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9129. infoStr := string(Iinfos)
  9130. idetinfoStr := string(Idetinfos)
  9131. psn := &models.HisPsn{
  9132. PsnNo: res.Output.Baseinfo.PsnNo,
  9133. PatientId: patient.ID,
  9134. Certno: res.Output.Baseinfo.Certno,
  9135. Gend: res.Output.Baseinfo.Gend,
  9136. Naty: res.Output.Baseinfo.Naty,
  9137. PsnCertType: res.Output.Baseinfo.PsnCertType,
  9138. PsnName: res.Output.Baseinfo.PsnName,
  9139. Idetinfo: idetinfoStr,
  9140. Insuinfo: infoStr,
  9141. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9142. CardInfo: card_info,
  9143. VerifyNumber: token,
  9144. }
  9145. service.CreateHisPsn(psn)
  9146. c.ServeSuccessJSON(map[string]interface{}{
  9147. "patient": patient,
  9148. "number": token,
  9149. })
  9150. }
  9151. }
  9152. } else {
  9153. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9154. return
  9155. }
  9156. } else { //读卡失败
  9157. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9158. return
  9159. }
  9160. } else if miConfig.MdtrtareaAdmvs == "350500" {
  9161. cardnum, cardCode, id_card_no, name, errmsg := c.GetFjBasBaseInfo()
  9162. cardnum = DeleteExtraSpaceTwo(cardnum)
  9163. cardCode = DeleteExtraSpaceTwo(cardCode)
  9164. id_card_no = DeleteExtraSpaceTwo(id_card_no)
  9165. name = DeleteExtraSpaceTwo(name)
  9166. errmsg = DeleteExtraSpaceTwo(errmsg)
  9167. cardnum = Remove0000(cardnum)
  9168. cardCode = Remove0000(cardCode)
  9169. id_card_no = Remove0000(id_card_no)
  9170. name = Remove0000(name)
  9171. errmsg = Remove0000(errmsg)
  9172. patient, _ := service.GetPatientByIDCard(id_card_no, miConfig.UserOrgId)
  9173. basStr := cardnum + "|" + cardCode + "|" + id_card_no + "|" + name
  9174. //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)
  9175. //fmt.Println(result2)
  9176. //fmt.Println(requestLog2)
  9177. //fmt.Println(errMsgLog2)
  9178. 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)
  9179. saveLog(result, requestLog, "1101", "获取人员信息")
  9180. fmt.Println(errMsgLog)
  9181. if len(errMsgLog) > 0 {
  9182. } else {
  9183. var dat map[string]interface{}
  9184. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9185. fmt.Println(dat)
  9186. } else {
  9187. fmt.Println(err)
  9188. }
  9189. userJSONBytes, _ := json.Marshal(dat)
  9190. var res ResultTwo
  9191. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9192. utils.ErrorLog("解析失败:%v", err)
  9193. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9194. return
  9195. }
  9196. res.ErrMsg = errMsgLog
  9197. if res.Infcode == 0 {
  9198. patient, err := service.GetPatientByNumber(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  9199. if err == gorm.ErrRecordNotFound {
  9200. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  9201. return
  9202. } else if err != nil {
  9203. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  9204. return
  9205. } else {
  9206. fmt.Println(res)
  9207. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9208. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9209. infoStr := string(Iinfos)
  9210. idetinfoStr := string(Idetinfos)
  9211. var rf []*ResultFive
  9212. json.Unmarshal([]byte(infoStr), &rf)
  9213. var insutypes []*ResultFive
  9214. var insutype string
  9215. var is390 int = 0
  9216. var is310 int = 0
  9217. for _, item := range rf {
  9218. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  9219. insutypes = append(insutypes, item)
  9220. }
  9221. }
  9222. if len(insutypes) == 1 {
  9223. insutype = insutypes[0].Insutype
  9224. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  9225. } else {
  9226. for _, i := range insutypes {
  9227. if i.Insutype == "390" {
  9228. is390 = 1
  9229. }
  9230. if i.Insutype == "310" {
  9231. is310 = 1
  9232. }
  9233. }
  9234. }
  9235. if is390 == 1 {
  9236. insutype = "390"
  9237. }
  9238. if is310 == 1 {
  9239. insutype = "310"
  9240. }
  9241. if len(insutypes) == 0 {
  9242. insutype = "390"
  9243. }
  9244. var insuplc_admdvs string
  9245. for _, item := range rf {
  9246. if item.Insutype == insutype {
  9247. insuplc_admdvs = item.InsuplcAdmdvs
  9248. }
  9249. }
  9250. psn := &models.HisPsn{
  9251. PsnNo: res.Output.Baseinfo.PsnNo,
  9252. PatientId: patient.ID,
  9253. Certno: res.Output.Baseinfo.Certno,
  9254. Gend: res.Output.Baseinfo.Gend,
  9255. Naty: res.Output.Baseinfo.Naty,
  9256. PsnCertType: res.Output.Baseinfo.PsnCertType,
  9257. PsnName: res.Output.Baseinfo.PsnName,
  9258. Idetinfo: idetinfoStr,
  9259. Insuinfo: infoStr,
  9260. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9261. CardInfo: basStr,
  9262. VerifyNumber: "",
  9263. InsuplcAdmdvs: insuplc_admdvs,
  9264. }
  9265. service.CreateHisPsn(psn)
  9266. c.ServeSuccessJSON(map[string]interface{}{
  9267. "patient": patient,
  9268. "number": cardnum,
  9269. "insutype": insutype,
  9270. })
  9271. }
  9272. } else {
  9273. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9274. return
  9275. }
  9276. }
  9277. } else if miConfig.MdtrtareaAdmvs == "360302" {
  9278. fmt.Println(initFlag)
  9279. fmt.Println("initFlag")
  9280. if initFlag == 0 {
  9281. c.TestGetJiangXiBasBaseInit()
  9282. }
  9283. basStr := c.GetBasBaseInfo()
  9284. if len(basStr) == 0 {
  9285. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  9286. return
  9287. }
  9288. fmt.Println(basStr)
  9289. bas := strings.Split(basStr, "|")
  9290. basNumber := bas[1]
  9291. fmt.Println(basNumber)
  9292. card_sn := bas[3]
  9293. fmt.Println(card_sn)
  9294. 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, "")
  9295. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  9296. var dat map[string]interface{}
  9297. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9298. fmt.Println(dat)
  9299. } else {
  9300. fmt.Println(err)
  9301. }
  9302. userJSONBytes, _ := json.Marshal(dat)
  9303. var res ResultTwo
  9304. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9305. utils.ErrorLog("解析失败:%v", err)
  9306. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9307. return
  9308. }
  9309. if res.Infcode == 0 {
  9310. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  9311. if err == gorm.ErrRecordNotFound {
  9312. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  9313. return
  9314. } else if err != nil {
  9315. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  9316. return
  9317. } else {
  9318. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9319. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9320. infoStr := string(Iinfos)
  9321. idetinfoStr := string(Idetinfos)
  9322. var rf []*ResultFive
  9323. json.Unmarshal([]byte(infoStr), &rf)
  9324. var insutypes []*ResultFive
  9325. var insutype string
  9326. var is390 int = 0
  9327. var is310 int = 0
  9328. var insuplc_admdvs string
  9329. for _, item := range rf {
  9330. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  9331. insutypes = append(insutypes, item)
  9332. }
  9333. }
  9334. if len(insutypes) == 1 {
  9335. insutype = insutypes[0].Insutype
  9336. insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  9337. } else {
  9338. for _, i := range insutypes {
  9339. if i.Insutype == "390" {
  9340. is390 = 1
  9341. }
  9342. if i.Insutype == "310" {
  9343. is310 = 1
  9344. }
  9345. }
  9346. }
  9347. if is390 == 1 {
  9348. insutype = "390"
  9349. }
  9350. if is310 == 1 {
  9351. insutype = "310"
  9352. }
  9353. if len(insutypes) == 0 {
  9354. insutype = "310"
  9355. }
  9356. for _, item := range rf {
  9357. if item.Insutype == insutype && item.PsnInsuStas == "1" {
  9358. insuplc_admdvs = item.InsuplcAdmdvs
  9359. }
  9360. }
  9361. psn := &models.HisPsn{
  9362. PsnNo: res.Output.Baseinfo.PsnNo,
  9363. PatientId: patient.ID,
  9364. Certno: res.Output.Baseinfo.Certno,
  9365. Gend: res.Output.Baseinfo.Gend,
  9366. Naty: res.Output.Baseinfo.Naty,
  9367. PsnCertType: res.Output.Baseinfo.PsnCertType,
  9368. PsnName: res.Output.Baseinfo.PsnName,
  9369. Idetinfo: idetinfoStr,
  9370. Insuinfo: infoStr,
  9371. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9372. CardInfo: basStr,
  9373. InsuplcAdmdvs: insuplc_admdvs,
  9374. VerifyNumber: "",
  9375. }
  9376. service.CreateHisPsn(psn)
  9377. c.ServeSuccessJSON(map[string]interface{}{
  9378. "patient": patient,
  9379. "number": basNumber,
  9380. "insutype": insutype,
  9381. })
  9382. }
  9383. } else {
  9384. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9385. return
  9386. }
  9387. } else if miConfig.MdtrtareaAdmvs == "430800" {
  9388. fmt.Println(initFlag)
  9389. fmt.Println("initFlag")
  9390. if initFlag == 0 {
  9391. c.TestGetHnBasBaseInit()
  9392. }
  9393. basStr := c.GetBasBaseInfo()
  9394. if len(basStr) == 0 {
  9395. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  9396. return
  9397. }
  9398. fmt.Println(basStr)
  9399. bas := strings.Split(basStr, "|")
  9400. basNumber := bas[1]
  9401. fmt.Println(basNumber)
  9402. card_sn := bas[3]
  9403. card_no := bas[2]
  9404. fmt.Println(card_sn)
  9405. name := bas[4]
  9406. name = ConvertToString(name, "gbk", "utf-8")
  9407. 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)
  9408. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  9409. var dat map[string]interface{}
  9410. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9411. fmt.Println(dat)
  9412. } else {
  9413. fmt.Println(err)
  9414. }
  9415. userJSONBytes, _ := json.Marshal(dat)
  9416. var res ResultTwo
  9417. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9418. utils.ErrorLog("解析失败:%v", err)
  9419. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9420. return
  9421. }
  9422. if res.Infcode == 0 {
  9423. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  9424. if err == gorm.ErrRecordNotFound {
  9425. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  9426. return
  9427. } else if err != nil {
  9428. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  9429. return
  9430. } else {
  9431. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9432. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9433. infoStr := string(Iinfos)
  9434. idetinfoStr := string(Idetinfos)
  9435. psn := &models.HisPsn{
  9436. PsnNo: res.Output.Baseinfo.PsnNo,
  9437. PatientId: patient.ID,
  9438. Certno: res.Output.Baseinfo.Certno,
  9439. Gend: res.Output.Baseinfo.Gend,
  9440. Naty: res.Output.Baseinfo.Naty,
  9441. PsnCertType: res.Output.Baseinfo.PsnCertType,
  9442. PsnName: res.Output.Baseinfo.PsnName,
  9443. Idetinfo: idetinfoStr,
  9444. Insuinfo: infoStr,
  9445. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9446. CardInfo: basStr,
  9447. VerifyNumber: "",
  9448. }
  9449. service.CreateHisPsn(psn)
  9450. var rf []*ResultFive
  9451. json.Unmarshal([]byte(infoStr), &rf)
  9452. var insutypes []*ResultFive
  9453. var insutype string
  9454. var is390 int = 0
  9455. var is310 int = 0
  9456. for _, item := range rf {
  9457. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  9458. insutypes = append(insutypes, item)
  9459. }
  9460. }
  9461. if len(insutypes) == 1 {
  9462. insutype = insutypes[0].Insutype
  9463. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  9464. } else {
  9465. for _, i := range insutypes {
  9466. if i.Insutype == "390" {
  9467. is390 = 1
  9468. }
  9469. if i.Insutype == "310" {
  9470. is310 = 1
  9471. }
  9472. }
  9473. }
  9474. if is390 == 1 {
  9475. insutype = "390"
  9476. }
  9477. if is310 == 1 {
  9478. insutype = "310"
  9479. }
  9480. if len(insutypes) == 0 {
  9481. insutype = "310"
  9482. }
  9483. c.ServeSuccessJSON(map[string]interface{}{
  9484. "patient": patient,
  9485. "number": basNumber,
  9486. "insutype": insutype,
  9487. })
  9488. }
  9489. } else {
  9490. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9491. return
  9492. }
  9493. } else if miConfig.MdtrtareaAdmvs == "150499" {
  9494. var api string
  9495. 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 +
  9496. "&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
  9497. fmt.Println(api)
  9498. resp, requestErr := http.Get(api)
  9499. if requestErr != nil {
  9500. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9501. return
  9502. }
  9503. body, ioErr := ioutil.ReadAll(resp.Body)
  9504. if ioErr != nil {
  9505. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9506. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9507. return
  9508. }
  9509. var respJSON map[string]interface{}
  9510. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9511. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9512. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9513. return
  9514. }
  9515. var res ResultTwo //1101结果
  9516. var res10265 ResultTwo10265 //1101结果
  9517. var card_info string //卡信息
  9518. token := respJSON["data"].(map[string]interface{})["token"].(string)
  9519. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  9520. result, _ := json.Marshal(respJSON)
  9521. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  9522. utils.ErrorLog("解析失败:%v", err)
  9523. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9524. return
  9525. }
  9526. res.ErrMsg = res10265.ErrMsg
  9527. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  9528. res.Infcode = infocode
  9529. res.Output = res10265.Output
  9530. res.InfRefmsgid = res10265.InfRefmsgid
  9531. if res.Infcode == 0 {
  9532. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  9533. if err == gorm.ErrRecordNotFound {
  9534. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  9535. return
  9536. } else if err != nil {
  9537. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  9538. return
  9539. } else {
  9540. bas := strings.Split(card_info, "|")
  9541. basNumber := bas[2]
  9542. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9543. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9544. infoStr := string(Iinfos)
  9545. idetinfoStr := string(Idetinfos)
  9546. psn := &models.HisPsn{
  9547. PsnNo: res.Output.Baseinfo.PsnNo,
  9548. PatientId: patient.ID,
  9549. Certno: res.Output.Baseinfo.Certno,
  9550. Gend: res.Output.Baseinfo.Gend,
  9551. Naty: res.Output.Baseinfo.Naty,
  9552. PsnCertType: res.Output.Baseinfo.PsnCertType,
  9553. PsnName: res.Output.Baseinfo.PsnName,
  9554. Idetinfo: idetinfoStr,
  9555. Insuinfo: infoStr,
  9556. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9557. CardInfo: card_info,
  9558. VerifyNumber: token,
  9559. }
  9560. service.CreateHisPsn(psn)
  9561. var rf []*ResultFive
  9562. json.Unmarshal([]byte(infoStr), &rf)
  9563. var insutypes []*ResultFive
  9564. var insutype string
  9565. var is390 int = 0
  9566. var is310 int = 0
  9567. for _, item := range rf {
  9568. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  9569. insutypes = append(insutypes, item)
  9570. }
  9571. }
  9572. if len(insutypes) == 1 {
  9573. insutype = insutypes[0].Insutype
  9574. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  9575. } else {
  9576. for _, i := range insutypes {
  9577. if i.Insutype == "390" {
  9578. is390 = 1
  9579. }
  9580. if i.Insutype == "310" {
  9581. is310 = 1
  9582. }
  9583. }
  9584. }
  9585. if is390 == 1 {
  9586. insutype = "390"
  9587. }
  9588. if is310 == 1 {
  9589. insutype = "310"
  9590. }
  9591. if len(insutypes) == 0 {
  9592. insutype = "310"
  9593. }
  9594. c.ServeSuccessJSON(map[string]interface{}{
  9595. "patient": patient,
  9596. "number": basNumber,
  9597. "insutype": insutype,
  9598. })
  9599. }
  9600. } else {
  9601. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9602. return
  9603. }
  9604. } else if miConfig.MdtrtareaAdmvs == "450721" {
  9605. res := c.GetoleInfo()
  9606. if res.Infcode == 0 {
  9607. var result string
  9608. if res.Output.MdtrtCertType == "01" {
  9609. 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)
  9610. } else if res.Output.MdtrtCertType == "02" {
  9611. 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)
  9612. } else if res.Output.MdtrtCertType == "03" {
  9613. 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)
  9614. }
  9615. var dat map[string]interface{}
  9616. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9617. fmt.Println(dat)
  9618. } else {
  9619. fmt.Println(err)
  9620. }
  9621. userJSONBytes, _ := json.Marshal(dat)
  9622. var res2 ResultTwo
  9623. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  9624. utils.ErrorLog("解析失败:%v", err)
  9625. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9626. return
  9627. }
  9628. if res2.Infcode == 0 {
  9629. patient, err := service.GetPatientByNumber(res.Output.CertNo, c.GetAdminUserInfo().CurrentOrgId)
  9630. if err == gorm.ErrRecordNotFound {
  9631. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  9632. return
  9633. } else if err != nil {
  9634. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  9635. return
  9636. } else {
  9637. Iinfos, _ := json.Marshal(res2.Output.Iinfo)
  9638. Idetinfos, _ := json.Marshal(res2.Output.Idetinfo)
  9639. infoStr := string(Iinfos)
  9640. idetinfoStr := string(Idetinfos)
  9641. var rf []*ResultFive
  9642. json.Unmarshal([]byte(infoStr), &rf)
  9643. var insutypes []*ResultFive
  9644. var insutype string
  9645. var is390 int = 0
  9646. var is310 int = 0
  9647. //var insuplc_admdvs string
  9648. for _, item := range rf {
  9649. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  9650. insutypes = append(insutypes, item)
  9651. }
  9652. }
  9653. if len(insutypes) == 1 {
  9654. insutype = insutypes[0].Insutype
  9655. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  9656. } else {
  9657. for _, i := range insutypes {
  9658. if i.Insutype == "390" {
  9659. is390 = 1
  9660. }
  9661. if i.Insutype == "310" {
  9662. is310 = 1
  9663. }
  9664. }
  9665. }
  9666. if is390 == 1 {
  9667. insutype = "390"
  9668. }
  9669. if is310 == 1 {
  9670. insutype = "310"
  9671. }
  9672. if len(insutypes) == 0 {
  9673. insutype = "310"
  9674. }
  9675. psn := &models.HisPsn{
  9676. PsnNo: res2.Output.Baseinfo.PsnNo,
  9677. PatientId: patient.ID,
  9678. Certno: res2.Output.Baseinfo.Certno,
  9679. Gend: res2.Output.Baseinfo.Gend,
  9680. Naty: res2.Output.Baseinfo.Naty,
  9681. PsnCertType: res2.Output.Baseinfo.PsnCertType,
  9682. PsnName: res2.Output.Baseinfo.PsnName,
  9683. Idetinfo: idetinfoStr,
  9684. Insuinfo: infoStr,
  9685. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9686. CardInfo: res.Output.CertNo + "|" + res.Output.CardSN,
  9687. VerifyNumber: res.Output.EcToken,
  9688. InsuplcAdmdvs: res.Output.InsuplcAdmdvs,
  9689. }
  9690. if res.Output.MdtrtCertType == "01" {
  9691. psn.VerifyNumber = res.Output.EcToken
  9692. //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)
  9693. } else if res.Output.MdtrtCertType == "02" {
  9694. psn.VerifyNumber = res.Output.MdtrtCertNo
  9695. //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)
  9696. } else if res.Output.MdtrtCertType == "03" {
  9697. psn.VerifyNumber = res.Output.MdtrtCertNo
  9698. //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)
  9699. }
  9700. var balc float64
  9701. for _, item := range rf {
  9702. if item.Insutype == insutype {
  9703. balc = item.Balc
  9704. }
  9705. }
  9706. service.CreateHisPsn(psn)
  9707. c.ServeSuccessJSON(map[string]interface{}{
  9708. "patient": patient,
  9709. "number": res.Output.CardNo,
  9710. "insutype": insutype,
  9711. "blac": balc,
  9712. "desc": idetinfoStr,
  9713. })
  9714. }
  9715. } else {
  9716. c.ServeSuccessJSON(map[string]interface{}{
  9717. "failed_code": -10,
  9718. "msg": res2.ErrMsg,
  9719. })
  9720. }
  9721. } else {
  9722. c.ServeSuccessJSON(map[string]interface{}{
  9723. "failed_code": -10,
  9724. "msg": res.ErrMsg,
  9725. })
  9726. }
  9727. } else if miConfig.MdtrtareaAdmvs == "341203" {
  9728. var api string
  9729. api = miConfig.SecretKey + "ahyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  9730. "&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
  9731. fmt.Println(api)
  9732. resp, requestErr := http.Get(api)
  9733. if requestErr != nil {
  9734. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9735. return
  9736. }
  9737. body, ioErr := ioutil.ReadAll(resp.Body)
  9738. if ioErr != nil {
  9739. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9740. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9741. return
  9742. }
  9743. var respJSON map[string]interface{}
  9744. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9745. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9746. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9747. return
  9748. }
  9749. var status string
  9750. status = respJSON["data"].(map[string]interface{})["status"].(string)
  9751. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  9752. //console.log()
  9753. fmt.Println("type===")
  9754. fmt.Println(card_type)
  9755. var token string
  9756. var res ResultTwo //1101结果
  9757. //var res10265 ResultTwoesultTwo10265 //1101结果
  9758. var card_info string //卡信息
  9759. var busi_card_info string
  9760. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  9761. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  9762. if status == "0" { //读卡成功
  9763. if card_type == "1" {
  9764. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  9765. result, _ := json.Marshal(respJSON)
  9766. if err := json.Unmarshal([]byte(result), &res); err != nil {
  9767. utils.ErrorLog("解析失败:%v", err)
  9768. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9769. return
  9770. }
  9771. } else {
  9772. token = respJSON["data"].(map[string]interface{})["token"].(string)
  9773. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  9774. result, _ := json.Marshal(respJSON)
  9775. if err := json.Unmarshal([]byte(result), &res); err != nil {
  9776. utils.ErrorLog("解析失败:%v", err)
  9777. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9778. return
  9779. }
  9780. }
  9781. if res.Infcode == 0 {
  9782. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  9783. if err == gorm.ErrRecordNotFound {
  9784. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  9785. return
  9786. } else if err != nil {
  9787. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  9788. return
  9789. } else {
  9790. if card_type == "1" {
  9791. bas := strings.Split(card_info, "|")
  9792. basNumber := bas[2]
  9793. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9794. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9795. infoStr := string(Iinfos)
  9796. idetinfoStr := string(Idetinfos)
  9797. psn := &models.HisPsn{
  9798. PsnNo: res.Output.Baseinfo.PsnNo,
  9799. PatientId: patient.ID,
  9800. Certno: res.Output.Baseinfo.Certno,
  9801. Gend: res.Output.Baseinfo.Gend,
  9802. Naty: res.Output.Baseinfo.Naty,
  9803. PsnCertType: res.Output.Baseinfo.PsnCertType,
  9804. PsnName: res.Output.Baseinfo.PsnName,
  9805. Idetinfo: idetinfoStr,
  9806. Insuinfo: infoStr,
  9807. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9808. CardInfo: card_info,
  9809. VerifyNumber: busi_card_info,
  9810. }
  9811. service.CreateHisPsn(psn)
  9812. var rf []*ResultFive
  9813. json.Unmarshal([]byte(infoStr), &rf)
  9814. var insutypes []*ResultFive
  9815. var insutype string
  9816. var is390 int = 0
  9817. var is310 int = 0
  9818. for _, item := range rf {
  9819. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  9820. insutypes = append(insutypes, item)
  9821. }
  9822. }
  9823. if len(insutypes) == 1 {
  9824. insutype = insutypes[0].Insutype
  9825. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  9826. } else {
  9827. for _, i := range insutypes {
  9828. if i.Insutype == "390" {
  9829. is390 = 1
  9830. }
  9831. if i.Insutype == "310" {
  9832. is310 = 1
  9833. }
  9834. }
  9835. }
  9836. if is390 == 1 {
  9837. insutype = "390"
  9838. }
  9839. if is310 == 1 {
  9840. insutype = "310"
  9841. }
  9842. if len(insutypes) == 0 {
  9843. insutype = "310"
  9844. }
  9845. c.ServeSuccessJSON(map[string]interface{}{
  9846. "patient": patient,
  9847. "number": basNumber,
  9848. "insutype": insutype,
  9849. })
  9850. } else {
  9851. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9852. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9853. infoStr := string(Iinfos)
  9854. idetinfoStr := string(Idetinfos)
  9855. psn := &models.HisPsn{
  9856. PsnNo: res.Output.Baseinfo.PsnNo,
  9857. PatientId: patient.ID,
  9858. Certno: res.Output.Baseinfo.Certno,
  9859. Gend: res.Output.Baseinfo.Gend,
  9860. Naty: res.Output.Baseinfo.Naty,
  9861. PsnCertType: res.Output.Baseinfo.PsnCertType,
  9862. PsnName: res.Output.Baseinfo.PsnName,
  9863. Idetinfo: idetinfoStr,
  9864. Insuinfo: infoStr,
  9865. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9866. CardInfo: card_info,
  9867. VerifyNumber: token,
  9868. }
  9869. service.CreateHisPsn(psn)
  9870. c.ServeSuccessJSON(map[string]interface{}{
  9871. "patient": patient,
  9872. "number": token,
  9873. })
  9874. }
  9875. }
  9876. } else {
  9877. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9878. return
  9879. }
  9880. } else { //读卡失败
  9881. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9882. return
  9883. }
  9884. } else {
  9885. if initFlag == 0 {
  9886. c.TestGetBasBaseInit()
  9887. }
  9888. basStr := c.GetBasBaseInfo()
  9889. if len(basStr) == 0 {
  9890. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  9891. return
  9892. }
  9893. fmt.Println(basStr)
  9894. bas := strings.Split(basStr, "|")
  9895. basNumber := bas[1]
  9896. fmt.Println(basNumber)
  9897. card_sn := bas[3]
  9898. fmt.Println(card_sn)
  9899. cardNumber := bas[2]
  9900. fmt.Println(cardNumber)
  9901. patient, _ := service.GetPatientByIDCard(basNumber, miConfig.UserOrgId)
  9902. var result string
  9903. if bas[0][:2] == "44" {
  9904. 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)
  9905. } else {
  9906. 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)
  9907. }
  9908. var dat map[string]interface{}
  9909. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9910. fmt.Println(dat)
  9911. } else {
  9912. fmt.Println(err)
  9913. }
  9914. userJSONBytes, _ := json.Marshal(dat)
  9915. var res ResultTwo
  9916. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9917. utils.ErrorLog("解析失败:%v", err)
  9918. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9919. return
  9920. }
  9921. if res.Infcode == 0 {
  9922. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  9923. if err == gorm.ErrRecordNotFound {
  9924. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  9925. return
  9926. } else if err != nil {
  9927. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  9928. return
  9929. } else {
  9930. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9931. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9932. infoStr := string(Iinfos)
  9933. idetinfoStr := string(Idetinfos)
  9934. var rf []*ResultFive
  9935. json.Unmarshal([]byte(infoStr), &rf)
  9936. var insutypes []*ResultFive
  9937. var insutype string
  9938. var is390 int = 0
  9939. var is310 int = 0
  9940. var insuplc_admdvs string
  9941. for _, item := range rf {
  9942. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  9943. insutypes = append(insutypes, item)
  9944. }
  9945. }
  9946. if len(insutypes) == 1 {
  9947. insutype = insutypes[0].Insutype
  9948. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  9949. } else {
  9950. for _, i := range insutypes {
  9951. if i.Insutype == "390" {
  9952. is390 = 1
  9953. }
  9954. if i.Insutype == "310" {
  9955. is310 = 1
  9956. }
  9957. }
  9958. }
  9959. if is390 == 1 {
  9960. insutype = "390"
  9961. }
  9962. if is310 == 1 {
  9963. insutype = "310"
  9964. }
  9965. if len(insutypes) == 0 {
  9966. insutype = "310"
  9967. }
  9968. for _, item := range rf {
  9969. if item.Insutype == insutype {
  9970. insuplc_admdvs = item.InsuplcAdmdvs
  9971. }
  9972. }
  9973. psn := &models.HisPsn{
  9974. PsnNo: res.Output.Baseinfo.PsnNo,
  9975. PatientId: patient.ID,
  9976. Certno: res.Output.Baseinfo.Certno,
  9977. Gend: res.Output.Baseinfo.Gend,
  9978. Naty: res.Output.Baseinfo.Naty,
  9979. PsnCertType: res.Output.Baseinfo.PsnCertType,
  9980. PsnName: res.Output.Baseinfo.PsnName,
  9981. Idetinfo: idetinfoStr,
  9982. Insuinfo: infoStr,
  9983. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9984. CardInfo: basStr,
  9985. VerifyNumber: "",
  9986. InsuplcAdmdvs: insuplc_admdvs,
  9987. }
  9988. service.CreateHisPsn(psn)
  9989. c.ServeSuccessJSON(map[string]interface{}{
  9990. "patient": patient,
  9991. "number": basNumber,
  9992. })
  9993. }
  9994. } else {
  9995. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9996. return
  9997. }
  9998. break
  9999. }
  10000. case 2:
  10001. if miConfig.MdtrtareaAdmvs == "430800" {
  10002. if initFlag == 0 {
  10003. c.TestGetHnBasBaseInit()
  10004. }
  10005. SFZStr := c.GetSFZBaseInfo()
  10006. if len(SFZStr) == 0 {
  10007. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  10008. return
  10009. }
  10010. fmt.Println(SFZStr)
  10011. id_card_str := strings.Split(SFZStr, "^")
  10012. card_no := id_card_str[0]
  10013. patient, _ := service.GetPatientByNumber(card_no, c.GetAdminUserInfo().CurrentOrgId)
  10014. //name := id_card_str[1]
  10015. //name = ConvertToString(name, "gbk", "utf-8")
  10016. 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)
  10017. var dat map[string]interface{}
  10018. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10019. fmt.Println(dat)
  10020. } else {
  10021. fmt.Println(err)
  10022. }
  10023. userJSONBytes, _ := json.Marshal(dat)
  10024. var res ResultTwo
  10025. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10026. utils.ErrorLog("解析失败:%v", err)
  10027. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10028. return
  10029. }
  10030. if res.Infcode == 0 {
  10031. patient, err := service.GetPatientByNumber(card_no, c.GetAdminUserInfo().CurrentOrgId)
  10032. if err == gorm.ErrRecordNotFound {
  10033. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  10034. return
  10035. } else if err != nil {
  10036. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  10037. return
  10038. } else {
  10039. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  10040. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  10041. infoStr := string(Iinfos)
  10042. idetinfoStr := string(Idetinfos)
  10043. var rf []*ResultFive
  10044. json.Unmarshal([]byte(infoStr), &rf)
  10045. var insutypes []*ResultFive
  10046. var insutype string
  10047. var is390 int = 0
  10048. var is310 int = 0
  10049. for _, item := range rf {
  10050. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  10051. insutypes = append(insutypes, item)
  10052. }
  10053. }
  10054. if len(insutypes) == 1 {
  10055. insutype = insutypes[0].Insutype
  10056. } else {
  10057. for _, i := range insutypes {
  10058. if i.Insutype == "390" {
  10059. is390 = 1
  10060. }
  10061. if i.Insutype == "310" {
  10062. is310 = 1
  10063. }
  10064. }
  10065. }
  10066. if is390 == 1 {
  10067. insutype = "390"
  10068. }
  10069. if is310 == 1 {
  10070. insutype = "310"
  10071. }
  10072. if len(insutypes) == 0 {
  10073. insutype = "310"
  10074. }
  10075. var InsuplcAdmdvs string
  10076. for _, item := range rf {
  10077. if item.Insutype == insutype {
  10078. InsuplcAdmdvs = item.InsuplcAdmdvs
  10079. }
  10080. }
  10081. psn := &models.HisPsn{
  10082. PsnNo: res.Output.Baseinfo.PsnNo,
  10083. PatientId: patient.ID,
  10084. Certno: res.Output.Baseinfo.Certno,
  10085. Gend: res.Output.Baseinfo.Gend,
  10086. Naty: res.Output.Baseinfo.Naty,
  10087. PsnCertType: res.Output.Baseinfo.PsnCertType,
  10088. PsnName: res.Output.Baseinfo.PsnName,
  10089. Idetinfo: idetinfoStr,
  10090. Insuinfo: infoStr,
  10091. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10092. CardInfo: SFZStr,
  10093. VerifyNumber: "",
  10094. InsuplcAdmdvs: InsuplcAdmdvs,
  10095. }
  10096. service.CreateHisPsn(psn)
  10097. c.ServeSuccessJSON(map[string]interface{}{
  10098. "patient": patient,
  10099. "number": card_no,
  10100. "insutype": insutype,
  10101. })
  10102. }
  10103. } else {
  10104. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10105. return
  10106. }
  10107. } else if miConfig.MdtrtareaAdmvs == "420200" {
  10108. var res ResultTwo
  10109. api := "http://192.168.0.197:9532/" + "hbyb/1101?cert_no=" + "" +
  10110. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  10111. "&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)
  10112. resp, requestErr := http.Get(api)
  10113. if requestErr != nil {
  10114. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10115. return
  10116. }
  10117. body, ioErr := ioutil.ReadAll(resp.Body)
  10118. if ioErr != nil {
  10119. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10120. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10121. return
  10122. }
  10123. var respJSON map[string]interface{}
  10124. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  10125. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10126. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10127. return
  10128. }
  10129. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10130. result, _ := json.Marshal(respJSON)
  10131. fmt.Println("log")
  10132. fmt.Println(string(result))
  10133. if err := json.Unmarshal([]byte(result), &res); err != nil {
  10134. utils.ErrorLog("解析失败:%v", err)
  10135. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10136. return
  10137. }
  10138. if res.Infcode == 0 {
  10139. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  10140. if err == gorm.ErrRecordNotFound {
  10141. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  10142. return
  10143. } else if err != nil {
  10144. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  10145. return
  10146. } else {
  10147. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  10148. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  10149. infoStr := string(Iinfos)
  10150. idetinfoStr := string(Idetinfos)
  10151. psn := &models.HisPsn{
  10152. PsnNo: res.Output.Baseinfo.PsnNo,
  10153. PatientId: patient.ID,
  10154. Certno: res.Output.Baseinfo.Certno,
  10155. Gend: res.Output.Baseinfo.Gend,
  10156. Naty: res.Output.Baseinfo.Naty,
  10157. PsnCertType: res.Output.Baseinfo.PsnCertType,
  10158. PsnName: res.Output.Baseinfo.PsnName,
  10159. Idetinfo: idetinfoStr,
  10160. Insuinfo: infoStr,
  10161. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10162. }
  10163. service.CreateHisPsn(psn)
  10164. c.ServeSuccessJSON(map[string]interface{}{
  10165. "patient": patient,
  10166. "number": res.Output.Baseinfo.Certno,
  10167. })
  10168. }
  10169. } else {
  10170. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10171. return
  10172. }
  10173. } else if miConfig.MdtrtareaAdmvs == "421182" {
  10174. var res ResultTwo
  10175. api := miConfig.Url + "hbyb/1101?cert_no=" + "" +
  10176. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  10177. "&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)
  10178. resp, requestErr := http.Get(api)
  10179. if requestErr != nil {
  10180. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10181. return
  10182. }
  10183. body, ioErr := ioutil.ReadAll(resp.Body)
  10184. if ioErr != nil {
  10185. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10186. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10187. return
  10188. }
  10189. var respJSON map[string]interface{}
  10190. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  10191. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10192. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10193. return
  10194. }
  10195. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10196. result, _ := json.Marshal(respJSON)
  10197. fmt.Println("log")
  10198. fmt.Println(string(result))
  10199. if err := json.Unmarshal([]byte(result), &res); err != nil {
  10200. utils.ErrorLog("解析失败:%v", err)
  10201. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10202. return
  10203. }
  10204. if res.Infcode == 0 {
  10205. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  10206. if err == gorm.ErrRecordNotFound {
  10207. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  10208. return
  10209. } else if err != nil {
  10210. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  10211. return
  10212. } else {
  10213. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  10214. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  10215. infoStr := string(Iinfos)
  10216. idetinfoStr := string(Idetinfos)
  10217. psn := &models.HisPsn{
  10218. PsnNo: res.Output.Baseinfo.PsnNo,
  10219. PatientId: patient.ID,
  10220. Certno: res.Output.Baseinfo.Certno,
  10221. Gend: res.Output.Baseinfo.Gend,
  10222. Naty: res.Output.Baseinfo.Naty,
  10223. PsnCertType: res.Output.Baseinfo.PsnCertType,
  10224. PsnName: res.Output.Baseinfo.PsnName,
  10225. Idetinfo: idetinfoStr,
  10226. Insuinfo: infoStr,
  10227. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10228. }
  10229. service.CreateHisPsn(psn)
  10230. c.ServeSuccessJSON(map[string]interface{}{
  10231. "patient": patient,
  10232. "number": res.Output.Baseinfo.Certno,
  10233. })
  10234. }
  10235. } else {
  10236. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10237. return
  10238. }
  10239. } else if miConfig.MdtrtareaAdmvs == "420902" {
  10240. var res ResultTwo
  10241. api := miConfig.Url + "hbyb/1101?cert_no=" + "" +
  10242. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  10243. "&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)
  10244. resp, requestErr := http.Get(api)
  10245. if requestErr != nil {
  10246. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10247. return
  10248. }
  10249. body, ioErr := ioutil.ReadAll(resp.Body)
  10250. if ioErr != nil {
  10251. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10252. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10253. return
  10254. }
  10255. var respJSON map[string]interface{}
  10256. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  10257. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10258. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10259. return
  10260. }
  10261. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10262. result, _ := json.Marshal(respJSON)
  10263. fmt.Println("log")
  10264. fmt.Println(string(result))
  10265. if err := json.Unmarshal([]byte(result), &res); err != nil {
  10266. utils.ErrorLog("解析失败:%v", err)
  10267. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10268. return
  10269. }
  10270. if res.Infcode == 0 {
  10271. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  10272. if err == gorm.ErrRecordNotFound {
  10273. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  10274. return
  10275. } else if err != nil {
  10276. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  10277. return
  10278. } else {
  10279. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  10280. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  10281. infoStr := string(Iinfos)
  10282. idetinfoStr := string(Idetinfos)
  10283. var rf []*ResultFive
  10284. json.Unmarshal([]byte(infoStr), &rf)
  10285. var insutypes []*ResultFive
  10286. var insutype string
  10287. var is390 int = 0
  10288. var is310 int = 0
  10289. for _, item := range rf {
  10290. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  10291. insutypes = append(insutypes, item)
  10292. }
  10293. }
  10294. if len(insutypes) == 1 {
  10295. insutype = insutypes[0].Insutype
  10296. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  10297. } else {
  10298. for _, i := range insutypes {
  10299. if i.Insutype == "390" {
  10300. is390 = 1
  10301. }
  10302. if i.Insutype == "310" {
  10303. is310 = 1
  10304. }
  10305. }
  10306. }
  10307. if is390 == 1 {
  10308. insutype = "390"
  10309. }
  10310. if is310 == 1 {
  10311. insutype = "310"
  10312. }
  10313. if len(insutypes) == 0 {
  10314. insutype = "390"
  10315. }
  10316. var insuplc_admdvs string
  10317. for _, item := range rf {
  10318. if item.Insutype == insutype {
  10319. insuplc_admdvs = item.InsuplcAdmdvs
  10320. }
  10321. }
  10322. psn := &models.HisPsn{
  10323. PsnNo: res.Output.Baseinfo.PsnNo,
  10324. PatientId: patient.ID,
  10325. Certno: res.Output.Baseinfo.Certno,
  10326. Gend: res.Output.Baseinfo.Gend,
  10327. Naty: res.Output.Baseinfo.Naty,
  10328. PsnCertType: res.Output.Baseinfo.PsnCertType,
  10329. PsnName: res.Output.Baseinfo.PsnName,
  10330. Idetinfo: idetinfoStr,
  10331. Insuinfo: infoStr,
  10332. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10333. InsuplcAdmdvs: insuplc_admdvs,
  10334. }
  10335. service.CreateHisPsn(psn)
  10336. c.ServeSuccessJSON(map[string]interface{}{
  10337. "patient": patient,
  10338. "number": res.Output.Baseinfo.Certno,
  10339. })
  10340. }
  10341. } else {
  10342. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10343. return
  10344. }
  10345. } else if miConfig.MdtrtareaAdmvs == "450721" {
  10346. res := c.GetoleInfo()
  10347. if res.Infcode == 0 {
  10348. var result string
  10349. if res.Output.MdtrtCertType == "01" {
  10350. 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)
  10351. } else if res.Output.MdtrtCertType == "02" {
  10352. 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)
  10353. } else if res.Output.MdtrtCertType == "03" {
  10354. 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)
  10355. }
  10356. var dat map[string]interface{}
  10357. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10358. fmt.Println(dat)
  10359. } else {
  10360. fmt.Println(err)
  10361. }
  10362. userJSONBytes, _ := json.Marshal(dat)
  10363. var res2 ResultTwo
  10364. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  10365. utils.ErrorLog("解析失败:%v", err)
  10366. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10367. return
  10368. }
  10369. if res2.Infcode == 0 {
  10370. patient, err := service.GetPatientByNumber(res.Output.CertNo, c.GetAdminUserInfo().CurrentOrgId)
  10371. if err == gorm.ErrRecordNotFound {
  10372. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  10373. return
  10374. } else if err != nil {
  10375. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  10376. return
  10377. } else {
  10378. Iinfos, _ := json.Marshal(res2.Output.Iinfo)
  10379. Idetinfos, _ := json.Marshal(res2.Output.Idetinfo)
  10380. infoStr := string(Iinfos)
  10381. idetinfoStr := string(Idetinfos)
  10382. var rf []*ResultFive
  10383. json.Unmarshal([]byte(infoStr), &rf)
  10384. var insutypes []*ResultFive
  10385. var insutype string
  10386. var is390 int = 0
  10387. var is310 int = 0
  10388. //var insuplc_admdvs string
  10389. for _, item := range rf {
  10390. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  10391. insutypes = append(insutypes, item)
  10392. }
  10393. }
  10394. if len(insutypes) == 1 {
  10395. insutype = insutypes[0].Insutype
  10396. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  10397. } else {
  10398. for _, i := range insutypes {
  10399. if i.Insutype == "390" {
  10400. is390 = 1
  10401. }
  10402. if i.Insutype == "310" {
  10403. is310 = 1
  10404. }
  10405. }
  10406. }
  10407. if is390 == 1 {
  10408. insutype = "390"
  10409. }
  10410. if is310 == 1 {
  10411. insutype = "310"
  10412. }
  10413. if len(insutypes) == 0 {
  10414. insutype = "310"
  10415. }
  10416. psn := &models.HisPsn{
  10417. PsnNo: res2.Output.Baseinfo.PsnNo,
  10418. PatientId: patient.ID,
  10419. //Brdy: res2.Output.Baseinfo.Brdy,
  10420. Certno: res2.Output.Baseinfo.Certno,
  10421. Gend: res2.Output.Baseinfo.Gend,
  10422. Naty: res2.Output.Baseinfo.Naty,
  10423. PsnCertType: res2.Output.Baseinfo.PsnCertType,
  10424. PsnName: res2.Output.Baseinfo.PsnName,
  10425. Idetinfo: idetinfoStr,
  10426. Insuinfo: infoStr,
  10427. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10428. CardInfo: res.Output.CertNo + "|" + res.Output.CardSN,
  10429. VerifyNumber: res.Output.EcToken,
  10430. InsuplcAdmdvs: res.Output.InsuplcAdmdvs,
  10431. }
  10432. service.CreateHisPsn(psn)
  10433. var balc float64
  10434. for _, item := range rf {
  10435. if item.Insutype == insutype {
  10436. balc = item.Balc
  10437. }
  10438. }
  10439. c.ServeSuccessJSON(map[string]interface{}{
  10440. "patient": patient,
  10441. "number": res.Output.CardNo,
  10442. "insutype": insutype,
  10443. "blac": balc,
  10444. "desc": idetinfoStr,
  10445. })
  10446. }
  10447. } else {
  10448. c.ServeSuccessJSON(map[string]interface{}{
  10449. "failed_code": -10,
  10450. "msg": res2.ErrMsg,
  10451. })
  10452. }
  10453. } else {
  10454. c.ServeSuccessJSON(map[string]interface{}{
  10455. "failed_code": -10,
  10456. "msg": res.ErrMsg,
  10457. })
  10458. }
  10459. } else {
  10460. SFZStr := c.GetSFZBaseInfo()
  10461. id_card_str := strings.Split(SFZStr, "^")
  10462. id_card_number := id_card_str[0]
  10463. card_sn := ""
  10464. 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)
  10465. var dat map[string]interface{}
  10466. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10467. fmt.Println(dat)
  10468. } else {
  10469. fmt.Println(err)
  10470. }
  10471. userJSONBytes, _ := json.Marshal(dat)
  10472. var res ResultTwo
  10473. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10474. utils.ErrorLog("解析失败:%v", err)
  10475. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10476. return
  10477. }
  10478. if res.Infcode == 0 {
  10479. patient, err := service.GetPatientByNumber(id_card_number, c.GetAdminUserInfo().CurrentOrgId)
  10480. if err == gorm.ErrRecordNotFound {
  10481. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  10482. return
  10483. } else if err != nil {
  10484. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  10485. return
  10486. } else {
  10487. c.ServeSuccessJSON(map[string]interface{}{
  10488. "patient": patient,
  10489. "number": id_card_number,
  10490. })
  10491. }
  10492. } else {
  10493. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10494. return
  10495. }
  10496. }
  10497. break
  10498. case 3:
  10499. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  10500. var api string
  10501. if miConfig.MdtrtareaAdmvs == "320921" {
  10502. 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 +
  10503. "&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
  10504. fmt.Println(api)
  10505. } else {
  10506. 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 +
  10507. "&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)
  10508. }
  10509. resp, requestErr := http.Get(api)
  10510. if requestErr != nil {
  10511. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10512. return
  10513. }
  10514. body, ioErr := ioutil.ReadAll(resp.Body)
  10515. if ioErr != nil {
  10516. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10517. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10518. return
  10519. }
  10520. var respJSON map[string]interface{}
  10521. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  10522. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10523. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10524. return
  10525. }
  10526. var status string
  10527. status = respJSON["data"].(map[string]interface{})["status"].(string)
  10528. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  10529. var token string
  10530. var res ResultTwo //1101结果
  10531. var res10265 ResultTwo10265 //1101结果
  10532. var card_info string //卡信息
  10533. var busi_card_info string
  10534. //card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  10535. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  10536. if status == "0" { //读卡成功
  10537. if card_type == "1" {
  10538. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  10539. result, _ := json.Marshal(respJSON)
  10540. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  10541. utils.ErrorLog("解析失败:%v", err)
  10542. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10543. return
  10544. }
  10545. res.ErrMsg = res10265.ErrMsg
  10546. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  10547. res.Infcode = infocode
  10548. res.Output = res10265.Output
  10549. res.InfRefmsgid = res10265.InfRefmsgid
  10550. } else {
  10551. //var card_info string //卡信息
  10552. //var busi_card_info string
  10553. token = respJSON["data"].(map[string]interface{})["token"].(string)
  10554. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  10555. //fmt.Println(card_info)
  10556. //fmt.Println(busi_card_info)
  10557. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  10558. result, _ := json.Marshal(respJSON)
  10559. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  10560. utils.ErrorLog("解析失败:%v", err)
  10561. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10562. return
  10563. }
  10564. res.ErrMsg = res10265.ErrMsg
  10565. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  10566. res.Infcode = infocode
  10567. res.Output = res10265.Output
  10568. res.InfRefmsgid = res10265.InfRefmsgid
  10569. }
  10570. if res.Infcode == 0 {
  10571. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  10572. if err == gorm.ErrRecordNotFound {
  10573. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  10574. return
  10575. } else if err != nil {
  10576. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  10577. return
  10578. } else {
  10579. if card_type == "1" {
  10580. bas := strings.Split(card_info, "|")
  10581. basNumber := bas[2]
  10582. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  10583. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  10584. infoStr := string(Iinfos)
  10585. idetinfoStr := string(Idetinfos)
  10586. psn := &models.HisPsn{
  10587. PsnNo: res.Output.Baseinfo.PsnNo,
  10588. PatientId: patient.ID,
  10589. Certno: res.Output.Baseinfo.Certno,
  10590. //Brdy: res.Output.Baseinfo.Brdy,
  10591. Gend: res.Output.Baseinfo.Gend,
  10592. Naty: res.Output.Baseinfo.Naty,
  10593. PsnCertType: res.Output.Baseinfo.PsnCertType,
  10594. PsnName: res.Output.Baseinfo.PsnName,
  10595. Idetinfo: idetinfoStr,
  10596. Insuinfo: infoStr,
  10597. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10598. CardInfo: card_info,
  10599. VerifyNumber: busi_card_info,
  10600. }
  10601. service.CreateHisPsn(psn)
  10602. c.ServeSuccessJSON(map[string]interface{}{
  10603. "patient": patient,
  10604. "number": basNumber,
  10605. })
  10606. } else {
  10607. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  10608. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  10609. infoStr := string(Iinfos)
  10610. idetinfoStr := string(Idetinfos)
  10611. psn := &models.HisPsn{
  10612. PsnNo: res.Output.Baseinfo.PsnNo,
  10613. PatientId: patient.ID,
  10614. Certno: res.Output.Baseinfo.Certno,
  10615. Gend: res.Output.Baseinfo.Gend,
  10616. Naty: res.Output.Baseinfo.Naty,
  10617. PsnCertType: res.Output.Baseinfo.PsnCertType,
  10618. PsnName: res.Output.Baseinfo.PsnName,
  10619. Idetinfo: idetinfoStr,
  10620. Insuinfo: infoStr,
  10621. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10622. CardInfo: card_info,
  10623. VerifyNumber: token,
  10624. }
  10625. service.CreateHisPsn(psn)
  10626. var rf []*ResultFive
  10627. json.Unmarshal([]byte(infoStr), &rf)
  10628. var insutypes []*ResultFive
  10629. var insutype string
  10630. var is390 int = 0
  10631. var is310 int = 0
  10632. for _, item := range rf {
  10633. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  10634. insutypes = append(insutypes, item)
  10635. }
  10636. }
  10637. if len(insutypes) == 1 {
  10638. insutype = insutypes[0].Insutype
  10639. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  10640. } else {
  10641. for _, i := range insutypes {
  10642. if i.Insutype == "390" {
  10643. is390 = 1
  10644. }
  10645. if i.Insutype == "310" {
  10646. is310 = 1
  10647. }
  10648. }
  10649. }
  10650. if is390 == 1 {
  10651. insutype = "390"
  10652. }
  10653. if is310 == 1 {
  10654. insutype = "310"
  10655. }
  10656. if len(insutypes) == 0 {
  10657. insutype = "310"
  10658. }
  10659. c.ServeSuccessJSON(map[string]interface{}{
  10660. "patient": patient,
  10661. "number": token,
  10662. "insutype": insutype,
  10663. })
  10664. }
  10665. }
  10666. } else {
  10667. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10668. return
  10669. }
  10670. } else { //读卡失败
  10671. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10672. return
  10673. }
  10674. }
  10675. break
  10676. case 4:
  10677. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  10678. var api string
  10679. if miConfig.MdtrtareaAdmvs == "320921" {
  10680. 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 +
  10681. "&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
  10682. fmt.Println(api)
  10683. } else {
  10684. 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 +
  10685. "&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)
  10686. }
  10687. resp, requestErr := http.Get(api)
  10688. if requestErr != nil {
  10689. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10690. return
  10691. }
  10692. body, ioErr := ioutil.ReadAll(resp.Body)
  10693. if ioErr != nil {
  10694. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10695. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10696. return
  10697. }
  10698. var respJSON map[string]interface{}
  10699. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  10700. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10701. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10702. return
  10703. }
  10704. var status string
  10705. status = respJSON["data"].(map[string]interface{})["status"].(string)
  10706. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  10707. var token string
  10708. var res ResultTwo //1101结果
  10709. var res10265 ResultTwo10265 //1101结果
  10710. if status == "0" { //读卡成功
  10711. var card_info string //卡信息
  10712. var busi_card_info string
  10713. token = respJSON["data"].(map[string]interface{})["token"].(string)
  10714. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  10715. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  10716. fmt.Println(card_info)
  10717. fmt.Println(busi_card_info)
  10718. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  10719. result, _ := json.Marshal(respJSON)
  10720. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  10721. utils.ErrorLog("解析失败:%v", err)
  10722. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10723. return
  10724. }
  10725. res.ErrMsg = res10265.ErrMsg
  10726. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  10727. res.Infcode = infocode
  10728. res.Output = res10265.Output
  10729. res.InfRefmsgid = res10265.InfRefmsgid
  10730. if res.Infcode == 0 {
  10731. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  10732. if err == gorm.ErrRecordNotFound {
  10733. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  10734. return
  10735. } else if err != nil {
  10736. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  10737. return
  10738. } else {
  10739. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  10740. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  10741. infoStr := string(Iinfos)
  10742. idetinfoStr := string(Idetinfos)
  10743. b, age, _ := getBirthdateAndAge(res.Output.Baseinfo.Certno)
  10744. psn := &models.HisPsn{
  10745. PsnNo: res.Output.Baseinfo.PsnNo,
  10746. PatientId: patient.ID,
  10747. Certno: res.Output.Baseinfo.Certno,
  10748. Brdy: b,
  10749. Age: float64(age),
  10750. //Brdy: res.Output.Baseinfo.Brdy,
  10751. Gend: res.Output.Baseinfo.Gend,
  10752. Naty: res.Output.Baseinfo.Naty,
  10753. PsnCertType: res.Output.Baseinfo.PsnCertType,
  10754. PsnName: res.Output.Baseinfo.PsnName,
  10755. Idetinfo: idetinfoStr,
  10756. Insuinfo: infoStr,
  10757. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10758. CardInfo: card_info,
  10759. VerifyNumber: token,
  10760. }
  10761. var rf []*ResultFive
  10762. json.Unmarshal([]byte(infoStr), &rf)
  10763. var insutypes []*ResultFive
  10764. var insutype string
  10765. var is390 int = 0
  10766. var is310 int = 0
  10767. for _, item := range rf {
  10768. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  10769. insutypes = append(insutypes, item)
  10770. }
  10771. }
  10772. if len(insutypes) == 1 {
  10773. insutype = insutypes[0].Insutype
  10774. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  10775. } else {
  10776. for _, i := range insutypes {
  10777. if i.Insutype == "390" {
  10778. is390 = 1
  10779. }
  10780. if i.Insutype == "310" {
  10781. is310 = 1
  10782. }
  10783. }
  10784. }
  10785. if is390 == 1 {
  10786. insutype = "390"
  10787. }
  10788. if is310 == 1 {
  10789. insutype = "310"
  10790. }
  10791. if len(insutypes) == 0 {
  10792. insutype = "310"
  10793. }
  10794. service.CreateHisPsn(psn)
  10795. c.ServeSuccessJSON(map[string]interface{}{
  10796. "patient": patient,
  10797. "number": token,
  10798. "insutype": insutype,
  10799. })
  10800. }
  10801. } else {
  10802. c.ServeSuccessJSON(map[string]interface{}{
  10803. "failed_code": -10,
  10804. "msg": res.ErrMsg,
  10805. })
  10806. }
  10807. } else { //读卡失败
  10808. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10809. return
  10810. }
  10811. } else if miConfig.MdtrtareaAdmvs == "341203" {
  10812. var api string
  10813. api = miConfig.SecretKey + "ahyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  10814. "&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
  10815. resp, requestErr := http.Get(api)
  10816. if requestErr != nil {
  10817. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10818. return
  10819. }
  10820. body, ioErr := ioutil.ReadAll(resp.Body)
  10821. if ioErr != nil {
  10822. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10823. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10824. return
  10825. }
  10826. var respJSON map[string]interface{}
  10827. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  10828. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10829. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10830. return
  10831. }
  10832. var status string
  10833. status = respJSON["data"].(map[string]interface{})["status"].(string)
  10834. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  10835. var token string
  10836. var res ResultTwo //1101结果
  10837. if status == "1" { //读卡成功
  10838. var card_info string //卡信息
  10839. var busi_card_info string
  10840. token = respJSON["data"].(map[string]interface{})["token"].(string)
  10841. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  10842. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  10843. fmt.Println(card_info)
  10844. fmt.Println(busi_card_info)
  10845. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  10846. result, _ := json.Marshal(respJSON)
  10847. if err := json.Unmarshal([]byte(result), &res); err != nil {
  10848. utils.ErrorLog("解析失败:%v", err)
  10849. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10850. return
  10851. }
  10852. if res.Infcode == 0 {
  10853. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  10854. if err == gorm.ErrRecordNotFound {
  10855. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  10856. return
  10857. } else if err != nil {
  10858. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  10859. return
  10860. } else {
  10861. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  10862. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  10863. infoStr := string(Iinfos)
  10864. idetinfoStr := string(Idetinfos)
  10865. psn := &models.HisPsn{
  10866. PsnNo: res.Output.Baseinfo.PsnNo,
  10867. PatientId: patient.ID,
  10868. Certno: res.Output.Baseinfo.Certno,
  10869. Gend: res.Output.Baseinfo.Gend,
  10870. Naty: res.Output.Baseinfo.Naty,
  10871. PsnCertType: res.Output.Baseinfo.PsnCertType,
  10872. PsnName: res.Output.Baseinfo.PsnName,
  10873. Idetinfo: idetinfoStr,
  10874. Insuinfo: infoStr,
  10875. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10876. CardInfo: card_info,
  10877. VerifyNumber: token,
  10878. }
  10879. var rf []*ResultFive
  10880. json.Unmarshal([]byte(infoStr), &rf)
  10881. var insutypes []*ResultFive
  10882. var insutype string
  10883. var is390 int = 0
  10884. var is310 int = 0
  10885. for _, item := range rf {
  10886. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  10887. insutypes = append(insutypes, item)
  10888. }
  10889. }
  10890. if len(insutypes) == 1 {
  10891. insutype = insutypes[0].Insutype
  10892. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  10893. } else {
  10894. for _, i := range insutypes {
  10895. if i.Insutype == "390" {
  10896. is390 = 1
  10897. }
  10898. if i.Insutype == "310" {
  10899. is310 = 1
  10900. }
  10901. }
  10902. }
  10903. if is390 == 1 {
  10904. insutype = "390"
  10905. }
  10906. if is310 == 1 {
  10907. insutype = "310"
  10908. }
  10909. if len(insutypes) == 0 {
  10910. insutype = "310"
  10911. }
  10912. service.CreateHisPsn(psn)
  10913. c.ServeSuccessJSON(map[string]interface{}{
  10914. "patient": patient,
  10915. "number": token,
  10916. "insutype": insutype,
  10917. })
  10918. }
  10919. } else {
  10920. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10921. return
  10922. }
  10923. } else { //读卡失败
  10924. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10925. return
  10926. }
  10927. } else if miConfig.MdtrtareaAdmvs == "430800" {
  10928. idNo := c.GetString("idNo")
  10929. userName := c.GetString("userName")
  10930. ecToken := c.GetString("ecToken")
  10931. insuOrg := c.GetString("insuOrg")
  10932. result2, requestLog2 := service.Hnyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, insuOrg, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, ecToken, "", idNo, userName)
  10933. saveLog(result2, requestLog2, "1101", "获取人员信息")
  10934. var res ResultTwo
  10935. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  10936. utils.ErrorLog("解析失败:%v", err)
  10937. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10938. return
  10939. }
  10940. if res.Infcode == 0 {
  10941. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  10942. if err == gorm.ErrRecordNotFound {
  10943. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  10944. return
  10945. } else if err != nil {
  10946. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  10947. return
  10948. } else {
  10949. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  10950. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  10951. infoStr := string(Iinfos)
  10952. idetinfoStr := string(Idetinfos)
  10953. psn := &models.HisPsn{
  10954. PsnNo: res.Output.Baseinfo.PsnNo,
  10955. PatientId: patient.ID,
  10956. Certno: res.Output.Baseinfo.Certno,
  10957. Gend: res.Output.Baseinfo.Gend,
  10958. Naty: res.Output.Baseinfo.Naty,
  10959. PsnCertType: res.Output.Baseinfo.PsnCertType,
  10960. PsnName: res.Output.Baseinfo.PsnName,
  10961. Idetinfo: idetinfoStr,
  10962. Insuinfo: infoStr,
  10963. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10964. CardInfo: "",
  10965. Stage: "1",
  10966. VerifyNumber: ecToken,
  10967. InsuplcAdmdvs: insuOrg,
  10968. }
  10969. service.CreateHisPsn(psn)
  10970. var rf []*ResultFive
  10971. json.Unmarshal([]byte(infoStr), &rf)
  10972. var insutypes []*ResultFive
  10973. var insutype string
  10974. var is390 int = 0
  10975. var is310 int = 0
  10976. for _, item := range rf {
  10977. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  10978. insutypes = append(insutypes, item)
  10979. }
  10980. }
  10981. if len(insutypes) == 1 {
  10982. insutype = insutypes[0].Insutype
  10983. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  10984. } else {
  10985. for _, i := range insutypes {
  10986. if i.Insutype == "390" {
  10987. is390 = 1
  10988. }
  10989. if i.Insutype == "310" {
  10990. is310 = 1
  10991. }
  10992. }
  10993. }
  10994. if is390 == 1 {
  10995. insutype = "390"
  10996. }
  10997. if is310 == 1 {
  10998. insutype = "310"
  10999. }
  11000. if len(insutypes) == 0 {
  11001. insutype = "310"
  11002. }
  11003. c.ServeSuccessJSON(map[string]interface{}{
  11004. "patient": patient,
  11005. "number": ecToken,
  11006. "insutype": insutype,
  11007. })
  11008. }
  11009. } else {
  11010. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  11011. return
  11012. }
  11013. } else if miConfig.MdtrtareaAdmvs == "360302" {
  11014. //if initFlag == 0 {
  11015. //c.TestGetJiangXiBasBaseInit()
  11016. //}
  11017. //if initEleFlag == 0 {
  11018. // GetJxEleBaseInitInfo(c.GetAdminUserInfo().CurrentOrgId)
  11019. //}
  11020. //_, result2 := GetjxELekeyInfo(miConfig.Code, "1", roles.UserName)
  11021. _, result := GetjxELeInfoaaa(miConfig.Code, "1", roles.UserName)
  11022. //json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  11023. type ELeData struct {
  11024. Data struct {
  11025. IdNo string `json:"idNo"`
  11026. IdType string `json:"idType"`
  11027. UserName string `json:"userName"`
  11028. EcToken string `json:"ecToken"`
  11029. InsuOrg string `json:"insuOrg"`
  11030. Gender string `json:"gender"`
  11031. Birthday string `json:"birthday"`
  11032. Nationality string `json:"nationality"`
  11033. Email string `json:"email"`
  11034. Extra string `json:"extra"`
  11035. } `json:"data"`
  11036. Code int `json:"code"`
  11037. Message string `json:"message"`
  11038. }
  11039. var ele ELeData
  11040. err := json.Unmarshal([]byte(result), &ele)
  11041. if err != nil {
  11042. utils.ErrorLog("解析失败:%v", err)
  11043. }
  11044. token := ele.Data.EcToken
  11045. token = Remove0000(token)
  11046. 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)
  11047. saveLog(result2, requestLog2, "1101", "获取人员信息")
  11048. var res ResultTwo
  11049. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  11050. utils.ErrorLog("解析失败:%v", err)
  11051. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11052. return
  11053. }
  11054. if res.Infcode == 0 {
  11055. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  11056. if err == gorm.ErrRecordNotFound {
  11057. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  11058. return
  11059. } else if err != nil {
  11060. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  11061. return
  11062. } else {
  11063. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  11064. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  11065. infoStr := string(Iinfos)
  11066. idetinfoStr := string(Idetinfos)
  11067. psn := &models.HisPsn{
  11068. PsnNo: res.Output.Baseinfo.PsnNo,
  11069. PatientId: patient.ID,
  11070. Certno: res.Output.Baseinfo.Certno,
  11071. Gend: res.Output.Baseinfo.Gend,
  11072. Naty: res.Output.Baseinfo.Naty,
  11073. PsnCertType: res.Output.Baseinfo.PsnCertType,
  11074. PsnName: res.Output.Baseinfo.PsnName,
  11075. Idetinfo: idetinfoStr,
  11076. Insuinfo: infoStr,
  11077. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  11078. CardInfo: "",
  11079. VerifyNumber: token,
  11080. }
  11081. service.CreateHisPsn(psn)
  11082. var rf []*ResultFive
  11083. json.Unmarshal([]byte(infoStr), &rf)
  11084. var insutypes []*ResultFive
  11085. var insutype string
  11086. var is390 int = 0
  11087. var is310 int = 0
  11088. for _, item := range rf {
  11089. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  11090. insutypes = append(insutypes, item)
  11091. }
  11092. }
  11093. if len(insutypes) == 1 {
  11094. insutype = insutypes[0].Insutype
  11095. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  11096. } else {
  11097. for _, i := range insutypes {
  11098. if i.Insutype == "390" {
  11099. is390 = 1
  11100. }
  11101. if i.Insutype == "310" {
  11102. is310 = 1
  11103. }
  11104. }
  11105. }
  11106. if is390 == 1 {
  11107. insutype = "390"
  11108. }
  11109. if is310 == 1 {
  11110. insutype = "310"
  11111. }
  11112. if len(insutypes) == 0 {
  11113. insutype = "310"
  11114. }
  11115. c.ServeSuccessJSON(map[string]interface{}{
  11116. "patient": patient,
  11117. "number": token,
  11118. "insutype": insutype,
  11119. })
  11120. }
  11121. } else {
  11122. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  11123. return
  11124. }
  11125. } else if miConfig.MdtrtareaAdmvs == "430800" {
  11126. //if initFlag == 0 {
  11127. c.TestGetJiangXiBasBaseInit()
  11128. //}
  11129. //if initEleFlag == 0 {
  11130. // GetJxEleBaseInitInfo(c.GetAdminUserInfo().CurrentOrgId)
  11131. //}
  11132. json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  11133. type ELeData struct {
  11134. Data struct {
  11135. IdNo string `json:"idNo"`
  11136. IdType string `json:"idType"`
  11137. UserName string `json:"userName"`
  11138. EcToken string `json:"ecToken"`
  11139. InsuOrg string `json:"insuOrg"`
  11140. Gender string `json:"gender"`
  11141. Birthday string `json:"birthday"`
  11142. Nationality string `json:"nationality"`
  11143. Email string `json:"email"`
  11144. Extra string `json:"extra"`
  11145. } `json:"data"`
  11146. Code int `json:"code"`
  11147. Message string `json:"message"`
  11148. }
  11149. var ele ELeData
  11150. err := json.Unmarshal([]byte(json_result), &ele)
  11151. if err != nil {
  11152. utils.ErrorLog("解析失败:%v", err)
  11153. }
  11154. token := ele.Data.EcToken
  11155. token = Remove0000(token)
  11156. 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)
  11157. saveLog(result2, requestLog2, "1101", "获取人员信息")
  11158. var res ResultTwo
  11159. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  11160. utils.ErrorLog("解析失败:%v", err)
  11161. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11162. return
  11163. }
  11164. if res.Infcode == 0 {
  11165. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  11166. if err == gorm.ErrRecordNotFound {
  11167. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  11168. return
  11169. } else if err != nil {
  11170. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  11171. return
  11172. } else {
  11173. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  11174. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  11175. infoStr := string(Iinfos)
  11176. idetinfoStr := string(Idetinfos)
  11177. psn := &models.HisPsn{
  11178. PsnNo: res.Output.Baseinfo.PsnNo,
  11179. PatientId: patient.ID,
  11180. Certno: res.Output.Baseinfo.Certno,
  11181. Gend: res.Output.Baseinfo.Gend,
  11182. Naty: res.Output.Baseinfo.Naty,
  11183. PsnCertType: res.Output.Baseinfo.PsnCertType,
  11184. PsnName: res.Output.Baseinfo.PsnName,
  11185. Idetinfo: idetinfoStr,
  11186. Insuinfo: infoStr,
  11187. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  11188. CardInfo: "",
  11189. VerifyNumber: token,
  11190. }
  11191. service.CreateHisPsn(psn)
  11192. var rf []*ResultFive
  11193. json.Unmarshal([]byte(infoStr), &rf)
  11194. var insutypes []*ResultFive
  11195. var insutype string
  11196. var is390 int = 0
  11197. var is310 int = 0
  11198. for _, item := range rf {
  11199. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  11200. insutypes = append(insutypes, item)
  11201. }
  11202. }
  11203. if len(insutypes) == 1 {
  11204. insutype = insutypes[0].Insutype
  11205. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  11206. } else {
  11207. for _, i := range insutypes {
  11208. if i.Insutype == "390" {
  11209. is390 = 1
  11210. }
  11211. if i.Insutype == "310" {
  11212. is310 = 1
  11213. }
  11214. }
  11215. }
  11216. if is390 == 1 {
  11217. insutype = "390"
  11218. }
  11219. if is310 == 1 {
  11220. insutype = "310"
  11221. }
  11222. if len(insutypes) == 0 {
  11223. insutype = "310"
  11224. }
  11225. c.ServeSuccessJSON(map[string]interface{}{
  11226. "patient": patient,
  11227. "number": token,
  11228. "insutype": insutype,
  11229. })
  11230. }
  11231. } else {
  11232. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  11233. return
  11234. }
  11235. } else if miConfig.MdtrtareaAdmvs == "350500" {
  11236. type ELeData struct {
  11237. Code string `json:"code"`
  11238. Data struct {
  11239. Aac002 string `json:"aac002"`
  11240. Aaz500 string `json:"aaz500"`
  11241. ActCardNo string `json:"actCardNo"`
  11242. Bab520 string `json:"bab520"`
  11243. Bkz543 string `json:"bkz543"`
  11244. BusinessType string `json:"businessType"`
  11245. CertfCodg string `json:"certfCodg"`
  11246. EcIndexNo string `json:"ecIndexNo"`
  11247. EcToken string `json:"ecToken"`
  11248. ID0000 string `json:"id0000"`
  11249. IDNo string `json:"idNo"`
  11250. IDType string `json:"idType"`
  11251. Idcode string `json:"idcode"`
  11252. IdentityToken string `json:"identity_token"`
  11253. InsuOrg string `json:"insuOrg"`
  11254. OfficeID string `json:"officeId"`
  11255. OfficeName string `json:"officeName"`
  11256. OperatorID string `json:"operatorId"`
  11257. OperatorName string `json:"operatorName"`
  11258. OrgID string `json:"orgId"`
  11259. UserName string `json:"userName"`
  11260. } `json:"data"`
  11261. Infno interface{} `json:"infno"`
  11262. Message string `json:"message"`
  11263. OrgID string `json:"orgId"`
  11264. TransType string `json:"transType"`
  11265. }
  11266. inputInfo, outPutInfo, _ := service.ReadEleCard(miConfig.Code)
  11267. outPutInfo = Remove0000(outPutInfo)
  11268. if len(outPutInfo) > 0 {
  11269. var ele ELeData
  11270. err := json.Unmarshal([]byte(outPutInfo), &ele)
  11271. if err != nil {
  11272. utils.ErrorLog("解析失败:%v", err)
  11273. }
  11274. token := ele.Data.EcToken
  11275. fmt.Println(inputInfo)
  11276. fmt.Println(outPutInfo)
  11277. 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)
  11278. saveLog(result, requestLog, "1101", "获取人员信息")
  11279. var dat map[string]interface{}
  11280. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11281. fmt.Println(dat)
  11282. } else {
  11283. fmt.Println(err)
  11284. }
  11285. userJSONBytes, _ := json.Marshal(dat)
  11286. var res ResultTwo
  11287. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11288. utils.ErrorLog("解析失败:%v", err)
  11289. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11290. return
  11291. }
  11292. res.ErrMsg = errMsgLog
  11293. if res.Infcode == 0 {
  11294. patient, err := service.GetPatientByNumber(ele.Data.IDNo, c.GetAdminUserInfo().CurrentOrgId)
  11295. if err == gorm.ErrRecordNotFound {
  11296. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  11297. return
  11298. } else if err != nil {
  11299. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  11300. return
  11301. } else {
  11302. fmt.Println(res)
  11303. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  11304. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  11305. infoStr := string(Iinfos)
  11306. idetinfoStr := string(Idetinfos)
  11307. psn := &models.HisPsn{
  11308. PsnNo: res.Output.Baseinfo.PsnNo,
  11309. PatientId: patient.ID,
  11310. Certno: res.Output.Baseinfo.Certno,
  11311. Gend: res.Output.Baseinfo.Gend,
  11312. Naty: res.Output.Baseinfo.Naty,
  11313. PsnCertType: res.Output.Baseinfo.PsnCertType,
  11314. PsnName: res.Output.Baseinfo.PsnName,
  11315. Idetinfo: idetinfoStr,
  11316. Insuinfo: infoStr,
  11317. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  11318. CardInfo: outPutInfo,
  11319. VerifyNumber: token,
  11320. InsuplcAdmdvs: ele.Data.InsuOrg,
  11321. }
  11322. service.CreateHisPsn(psn)
  11323. var rf []*ResultFive
  11324. json.Unmarshal([]byte(infoStr), &rf)
  11325. var insutypes []*ResultFive
  11326. var insutype string
  11327. var is390 int = 0
  11328. var is310 int = 0
  11329. for _, item := range rf {
  11330. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  11331. insutypes = append(insutypes, item)
  11332. }
  11333. }
  11334. if len(insutypes) == 1 {
  11335. insutype = insutypes[0].Insutype
  11336. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  11337. } else {
  11338. for _, i := range insutypes {
  11339. if i.Insutype == "390" {
  11340. is390 = 1
  11341. }
  11342. if i.Insutype == "310" {
  11343. is310 = 1
  11344. }
  11345. }
  11346. }
  11347. if is390 == 1 {
  11348. insutype = "390"
  11349. }
  11350. if is310 == 1 {
  11351. insutype = "310"
  11352. }
  11353. if len(insutypes) == 0 {
  11354. insutype = "310"
  11355. }
  11356. c.ServeSuccessJSON(map[string]interface{}{
  11357. "patient": patient,
  11358. "number": token,
  11359. "insutype": insutype,
  11360. })
  11361. }
  11362. } else {
  11363. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  11364. return
  11365. }
  11366. }
  11367. } else if miConfig.MdtrtareaAdmvs == "150499" {
  11368. var api string
  11369. 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 +
  11370. "&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
  11371. resp, requestErr := http.Get(api)
  11372. if requestErr != nil {
  11373. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11374. return
  11375. }
  11376. body, ioErr := ioutil.ReadAll(resp.Body)
  11377. if ioErr != nil {
  11378. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11379. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11380. return
  11381. }
  11382. var respJSON map[string]interface{}
  11383. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  11384. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11385. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11386. return
  11387. }
  11388. var status string
  11389. status = respJSON["data"].(map[string]interface{})["status"].(string)
  11390. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  11391. var token string
  11392. var res ResultTwo //1101结果
  11393. var res10265 ResultTwo10265 //1101结果
  11394. if status == "0" { //读卡成功
  11395. var card_info string //卡信息
  11396. var busi_card_info string
  11397. token = respJSON["data"].(map[string]interface{})["token"].(string)
  11398. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  11399. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  11400. fmt.Println(card_info)
  11401. fmt.Println(busi_card_info)
  11402. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  11403. result, _ := json.Marshal(respJSON)
  11404. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  11405. utils.ErrorLog("解析失败:%v", err)
  11406. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11407. return
  11408. }
  11409. res.ErrMsg = res10265.ErrMsg
  11410. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  11411. res.Infcode = infocode
  11412. res.Output = res10265.Output
  11413. res.InfRefmsgid = res10265.InfRefmsgid
  11414. if res.Infcode == 0 {
  11415. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  11416. if err == gorm.ErrRecordNotFound {
  11417. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  11418. return
  11419. } else if err != nil {
  11420. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  11421. return
  11422. } else {
  11423. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  11424. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  11425. infoStr := string(Iinfos)
  11426. idetinfoStr := string(Idetinfos)
  11427. psn := &models.HisPsn{
  11428. PsnNo: res.Output.Baseinfo.PsnNo,
  11429. PatientId: patient.ID,
  11430. Certno: res.Output.Baseinfo.Certno,
  11431. Gend: res.Output.Baseinfo.Gend,
  11432. Naty: res.Output.Baseinfo.Naty,
  11433. PsnCertType: res.Output.Baseinfo.PsnCertType,
  11434. PsnName: res.Output.Baseinfo.PsnName,
  11435. Idetinfo: idetinfoStr,
  11436. Insuinfo: infoStr,
  11437. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  11438. CardInfo: card_info,
  11439. VerifyNumber: token,
  11440. }
  11441. var rf []*ResultFive
  11442. json.Unmarshal([]byte(infoStr), &rf)
  11443. var insutypes []*ResultFive
  11444. var insutype string
  11445. var is390 int = 0
  11446. var is310 int = 0
  11447. for _, item := range rf {
  11448. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  11449. insutypes = append(insutypes, item)
  11450. }
  11451. }
  11452. if len(insutypes) == 1 {
  11453. insutype = insutypes[0].Insutype
  11454. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  11455. } else {
  11456. for _, i := range insutypes {
  11457. if i.Insutype == "390" {
  11458. is390 = 1
  11459. }
  11460. if i.Insutype == "310" {
  11461. is310 = 1
  11462. }
  11463. }
  11464. }
  11465. if is390 == 1 {
  11466. insutype = "390"
  11467. }
  11468. if is310 == 1 {
  11469. insutype = "310"
  11470. }
  11471. if len(insutypes) == 0 {
  11472. insutype = "310"
  11473. }
  11474. service.CreateHisPsn(psn)
  11475. c.ServeSuccessJSON(map[string]interface{}{
  11476. "patient": patient,
  11477. "number": token,
  11478. "insutype": insutype,
  11479. })
  11480. }
  11481. } else {
  11482. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  11483. return
  11484. }
  11485. } else { //读卡失败
  11486. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  11487. return
  11488. }
  11489. } else if miConfig.MdtrtareaAdmvs == "450721" {
  11490. res := c.GetoleInfo()
  11491. if res.Infcode == 0 {
  11492. var result string
  11493. if res.Output.MdtrtCertType == "01" {
  11494. 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)
  11495. } else if res.Output.MdtrtCertType == "02" {
  11496. 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)
  11497. } else if res.Output.MdtrtCertType == "03" {
  11498. 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)
  11499. }
  11500. var dat map[string]interface{}
  11501. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11502. fmt.Println(dat)
  11503. } else {
  11504. fmt.Println(err)
  11505. }
  11506. userJSONBytes, _ := json.Marshal(dat)
  11507. var res2 ResultTwo
  11508. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  11509. utils.ErrorLog("解析失败:%v", err)
  11510. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11511. return
  11512. }
  11513. if res2.Infcode == 0 {
  11514. patient, err := service.GetPatientByNumber(res.Output.CertNo, c.GetAdminUserInfo().CurrentOrgId)
  11515. if err == gorm.ErrRecordNotFound {
  11516. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  11517. return
  11518. } else if err != nil {
  11519. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  11520. return
  11521. } else {
  11522. Iinfos, _ := json.Marshal(res2.Output.Iinfo)
  11523. Idetinfos, _ := json.Marshal(res2.Output.Idetinfo)
  11524. infoStr := string(Iinfos)
  11525. idetinfoStr := string(Idetinfos)
  11526. var rf []*ResultFive
  11527. json.Unmarshal([]byte(infoStr), &rf)
  11528. var insutypes []*ResultFive
  11529. var insutype string
  11530. var is390 int = 0
  11531. var is310 int = 0
  11532. //var insuplc_admdvs string
  11533. for _, item := range rf {
  11534. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  11535. insutypes = append(insutypes, item)
  11536. }
  11537. }
  11538. if len(insutypes) == 1 {
  11539. insutype = insutypes[0].Insutype
  11540. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  11541. } else {
  11542. for _, i := range insutypes {
  11543. if i.Insutype == "390" {
  11544. is390 = 1
  11545. }
  11546. if i.Insutype == "310" {
  11547. is310 = 1
  11548. }
  11549. }
  11550. }
  11551. if is390 == 1 {
  11552. insutype = "390"
  11553. }
  11554. if is310 == 1 {
  11555. insutype = "310"
  11556. }
  11557. if len(insutypes) == 0 {
  11558. insutype = "310"
  11559. }
  11560. psn := &models.HisPsn{
  11561. PsnNo: res2.Output.Baseinfo.PsnNo,
  11562. PatientId: patient.ID,
  11563. Certno: res2.Output.Baseinfo.Certno,
  11564. Gend: res2.Output.Baseinfo.Gend,
  11565. Naty: res2.Output.Baseinfo.Naty,
  11566. PsnCertType: res2.Output.Baseinfo.PsnCertType,
  11567. PsnName: res2.Output.Baseinfo.PsnName,
  11568. Idetinfo: idetinfoStr,
  11569. Insuinfo: infoStr,
  11570. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  11571. CardInfo: res.Output.CertNo + "|" + res.Output.CardSN,
  11572. VerifyNumber: res.Output.EcToken,
  11573. InsuplcAdmdvs: res.Output.InsuplcAdmdvs,
  11574. }
  11575. if res.Output.MdtrtCertType == "01" {
  11576. psn.VerifyNumber = res.Output.EcToken
  11577. //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)
  11578. } else if res.Output.MdtrtCertType == "02" {
  11579. psn.VerifyNumber = res.Output.CardNo
  11580. //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)
  11581. } else if res.Output.MdtrtCertType == "03" {
  11582. psn.VerifyNumber = res.Output.MdtrtCertNo
  11583. //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)
  11584. }
  11585. service.CreateHisPsn(psn)
  11586. var balc float64
  11587. for _, item := range rf {
  11588. if item.Insutype == insutype {
  11589. balc = item.Balc
  11590. }
  11591. }
  11592. c.ServeSuccessJSON(map[string]interface{}{
  11593. "patient": patient,
  11594. "number": res.Output.CardNo,
  11595. "insutype": insutype,
  11596. "blac": balc,
  11597. "desc": idetinfoStr,
  11598. })
  11599. }
  11600. } else {
  11601. c.ServeSuccessJSON(map[string]interface{}{
  11602. "failed_code": -10,
  11603. "msg": res2.ErrMsg,
  11604. })
  11605. }
  11606. } else {
  11607. c.ServeSuccessJSON(map[string]interface{}{
  11608. "failed_code": -10,
  11609. "msg": res.ErrMsg,
  11610. })
  11611. }
  11612. } else if miConfig.MdtrtareaAdmvs == "420902" {
  11613. var res ResultTwo
  11614. api := miConfig.Url + "hbyb/1101?cert_no=" + "" +
  11615. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  11616. "&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)
  11617. resp, requestErr := http.Get(api)
  11618. if requestErr != nil {
  11619. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11620. return
  11621. }
  11622. body, ioErr := ioutil.ReadAll(resp.Body)
  11623. if ioErr != nil {
  11624. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11625. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11626. return
  11627. }
  11628. var respJSON map[string]interface{}
  11629. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  11630. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11631. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11632. return
  11633. }
  11634. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11635. result, _ := json.Marshal(respJSON)
  11636. fmt.Println("log")
  11637. fmt.Println(string(result))
  11638. if err := json.Unmarshal([]byte(result), &res); err != nil {
  11639. utils.ErrorLog("解析失败:%v", err)
  11640. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11641. return
  11642. }
  11643. if res.Infcode == 0 {
  11644. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  11645. if err == gorm.ErrRecordNotFound {
  11646. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  11647. return
  11648. } else if err != nil {
  11649. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  11650. return
  11651. } else {
  11652. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  11653. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  11654. infoStr := string(Iinfos)
  11655. idetinfoStr := string(Idetinfos)
  11656. var rf []*ResultFive
  11657. json.Unmarshal([]byte(infoStr), &rf)
  11658. var insutypes []*ResultFive
  11659. var insutype string
  11660. var is390 int = 0
  11661. var is310 int = 0
  11662. for _, item := range rf {
  11663. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  11664. insutypes = append(insutypes, item)
  11665. }
  11666. }
  11667. if len(insutypes) == 1 {
  11668. insutype = insutypes[0].Insutype
  11669. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  11670. } else {
  11671. for _, i := range insutypes {
  11672. if i.Insutype == "390" {
  11673. is390 = 1
  11674. }
  11675. if i.Insutype == "310" {
  11676. is310 = 1
  11677. }
  11678. }
  11679. }
  11680. if is390 == 1 {
  11681. insutype = "390"
  11682. }
  11683. if is310 == 1 {
  11684. insutype = "310"
  11685. }
  11686. if len(insutypes) == 0 {
  11687. insutype = "390"
  11688. }
  11689. var insuplc_admdvs string
  11690. for _, item := range rf {
  11691. if item.Insutype == insutype {
  11692. insuplc_admdvs = item.InsuplcAdmdvs
  11693. }
  11694. }
  11695. psn := &models.HisPsn{
  11696. PsnNo: res.Output.Baseinfo.PsnNo,
  11697. PatientId: patient.ID,
  11698. Certno: res.Output.Baseinfo.Certno,
  11699. Gend: res.Output.Baseinfo.Gend,
  11700. Naty: res.Output.Baseinfo.Naty,
  11701. PsnCertType: res.Output.Baseinfo.PsnCertType,
  11702. PsnName: res.Output.Baseinfo.PsnName,
  11703. Idetinfo: idetinfoStr,
  11704. Insuinfo: infoStr,
  11705. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  11706. InsuplcAdmdvs: insuplc_admdvs,
  11707. }
  11708. service.CreateHisPsn(psn)
  11709. c.ServeSuccessJSON(map[string]interface{}{
  11710. "patient": patient,
  11711. "number": res.Output.Baseinfo.Certno,
  11712. })
  11713. }
  11714. } else {
  11715. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  11716. return
  11717. }
  11718. } else {
  11719. type ELeData struct {
  11720. Code string `json:"code"`
  11721. Data struct {
  11722. Aac002 string `json:"aac002"`
  11723. Aaz500 string `json:"aaz500"`
  11724. ActCardNo string `json:"actCardNo"`
  11725. Bab520 string `json:"bab520"`
  11726. Bkz543 string `json:"bkz543"`
  11727. BusinessType string `json:"businessType"`
  11728. CertfCodg string `json:"certfCodg"`
  11729. EcIndexNo string `json:"ecIndexNo"`
  11730. EcToken string `json:"ecToken"`
  11731. ID0000 string `json:"id0000"`
  11732. IDNo string `json:"idNo"`
  11733. IDType string `json:"idType"`
  11734. Idcode string `json:"idcode"`
  11735. IdentityToken string `json:"identity_token"`
  11736. InsuOrg string `json:"insuOrg"`
  11737. OfficeID string `json:"officeId"`
  11738. OfficeName string `json:"officeName"`
  11739. OperatorID string `json:"operatorId"`
  11740. OperatorName string `json:"operatorName"`
  11741. OrgID string `json:"orgId"`
  11742. UserName string `json:"userName"`
  11743. } `json:"data"`
  11744. Infno interface{} `json:"infno"`
  11745. Message string `json:"message"`
  11746. OrgID string `json:"orgId"`
  11747. TransType string `json:"transType"`
  11748. }
  11749. _, result := GetELeInfo(miConfig.Code, "1", roles.UserName, miConfig.MdtrtareaAdmvs)
  11750. fmt.Println(result)
  11751. outPutInfo := Remove0000(result)
  11752. fmt.Println(outPutInfo)
  11753. if len(outPutInfo) > 0 {
  11754. var ele ELeData
  11755. err := json.Unmarshal([]byte(outPutInfo), &ele)
  11756. if err != nil {
  11757. utils.ErrorLog("解析失败:%v", err)
  11758. }
  11759. token := ele.Data.EcToken
  11760. fmt.Println(outPutInfo)
  11761. 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)
  11762. saveLog(result, requestLog, "1101", "获取人员信息")
  11763. var dat map[string]interface{}
  11764. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11765. fmt.Println(dat)
  11766. } else {
  11767. fmt.Println(err)
  11768. }
  11769. userJSONBytes, _ := json.Marshal(dat)
  11770. var res ResultTwo
  11771. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11772. utils.ErrorLog("解析失败:%v", err)
  11773. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11774. return
  11775. }
  11776. if res.Infcode == 0 {
  11777. patient, err := service.GetPatientByNumber(ele.Data.IDNo, c.GetAdminUserInfo().CurrentOrgId)
  11778. if err == gorm.ErrRecordNotFound {
  11779. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  11780. return
  11781. } else if err != nil {
  11782. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  11783. return
  11784. } else {
  11785. fmt.Println(res)
  11786. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  11787. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  11788. infoStr := string(Iinfos)
  11789. idetinfoStr := string(Idetinfos)
  11790. psn := &models.HisPsn{
  11791. PsnNo: res.Output.Baseinfo.PsnNo,
  11792. PatientId: patient.ID,
  11793. Certno: res.Output.Baseinfo.Certno,
  11794. Gend: res.Output.Baseinfo.Gend,
  11795. Naty: res.Output.Baseinfo.Naty,
  11796. PsnCertType: res.Output.Baseinfo.PsnCertType,
  11797. PsnName: res.Output.Baseinfo.PsnName,
  11798. Idetinfo: idetinfoStr,
  11799. Insuinfo: infoStr,
  11800. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  11801. CardInfo: outPutInfo,
  11802. VerifyNumber: token,
  11803. InsuplcAdmdvs: ele.Data.InsuOrg,
  11804. }
  11805. service.CreateHisPsn(psn)
  11806. var rf []*ResultFive
  11807. json.Unmarshal([]byte(infoStr), &rf)
  11808. var insutypes []*ResultFive
  11809. var insutype string
  11810. var is390 int = 0
  11811. var is310 int = 0
  11812. for _, item := range rf {
  11813. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  11814. insutypes = append(insutypes, item)
  11815. }
  11816. }
  11817. if len(insutypes) == 1 {
  11818. insutype = insutypes[0].Insutype
  11819. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  11820. } else {
  11821. for _, i := range insutypes {
  11822. if i.Insutype == "390" {
  11823. is390 = 1
  11824. }
  11825. if i.Insutype == "310" {
  11826. is310 = 1
  11827. }
  11828. }
  11829. }
  11830. if is390 == 1 {
  11831. insutype = "390"
  11832. }
  11833. if is310 == 1 {
  11834. insutype = "310"
  11835. }
  11836. if len(insutypes) == 0 {
  11837. insutype = "310"
  11838. }
  11839. c.ServeSuccessJSON(map[string]interface{}{
  11840. "patient": patient,
  11841. "number": token,
  11842. "insutype": insutype,
  11843. })
  11844. }
  11845. } else {
  11846. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  11847. return
  11848. }
  11849. }
  11850. //fmt.Println(result)
  11851. //
  11852. //if initFlag == 0 {
  11853. // c.TestGetBasBaseInit()
  11854. //}
  11855. //token := c.GetEleBaseInfo()
  11856. //
  11857. //token = Remove0000(token)
  11858. //
  11859. //result2, requestLog2 := service.Gdyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, insuplc_admdvs_str, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, token, "", "")
  11860. //saveLog(result2, requestLog2, "1101", "获取人员信息")
  11861. ////
  11862. //var res ResultTwo
  11863. //if err := json.Unmarshal([]byte(result2), &res); err != nil {
  11864. // utils.ErrorLog("解析失败:%v", err)
  11865. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11866. // return
  11867. //}
  11868. //
  11869. //if res.Infcode == 0 {
  11870. // patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  11871. // if err == gorm.ErrRecordNotFound {
  11872. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  11873. // return
  11874. // } else if err != nil {
  11875. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  11876. // return
  11877. //
  11878. // } else {
  11879. // Iinfos, _ := json.Marshal(res.Output.Iinfo)
  11880. // Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  11881. // infoStr := string(Iinfos)
  11882. // idetinfoStr := string(Idetinfos)
  11883. //
  11884. //
  11885. //
  11886. //
  11887. // var rf []*ResultFive
  11888. // json.Unmarshal([]byte(infoStr), &rf)
  11889. //
  11890. // var insutypes []*ResultFive
  11891. // var insutype string
  11892. // var is390 int = 0
  11893. // var is310 int = 0
  11894. // var insuplc_admdvs string
  11895. //
  11896. // for _, item := range rf {
  11897. // if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  11898. // insutypes = append(insutypes, item)
  11899. // }
  11900. // }
  11901. //
  11902. // if len(insutypes) == 1 {
  11903. // insutype = insutypes[0].Insutype
  11904. // //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  11905. // } else {
  11906. // for _, i := range insutypes {
  11907. // if i.Insutype == "390" {
  11908. // is390 = 1
  11909. // }
  11910. //
  11911. // if i.Insutype == "310" {
  11912. // is310 = 1
  11913. // }
  11914. // }
  11915. // }
  11916. // if is390 == 1 {
  11917. // insutype = "390"
  11918. // }
  11919. //
  11920. // if is310 == 1 {
  11921. // insutype = "310"
  11922. // }
  11923. // if len(insutypes) == 0 {
  11924. // insutype = "310"
  11925. // }
  11926. // for _, item := range rf {
  11927. // if item.Insutype == insutype {
  11928. // insuplc_admdvs = item.InsuplcAdmdvs
  11929. // }
  11930. // }
  11931. // psn := &models.HisPsn{
  11932. // PsnNo: res.Output.Baseinfo.PsnNo,
  11933. // Age: res.Output.Baseinfo.Age,
  11934. // PatientId: patient.ID,
  11935. // Certno: res.Output.Baseinfo.Certno,
  11936. // Brdy: res.Output.Baseinfo.Brdy,
  11937. // Gend: res.Output.Baseinfo.Gend,
  11938. // Naty: res.Output.Baseinfo.Naty,
  11939. // PsnCertType: res.Output.Baseinfo.PsnCertType,
  11940. // PsnName: res.Output.Baseinfo.PsnName,
  11941. // Idetinfo: idetinfoStr,
  11942. // Insuinfo: infoStr,
  11943. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  11944. // CardInfo: "",
  11945. // VerifyNumber: token,
  11946. // InsuplcAdmdvs: insuplc_admdvs,
  11947. // }
  11948. // service.CreateHisPsn(psn)
  11949. //
  11950. // c.ServeSuccessJSON(map[string]interface{}{
  11951. // "patient": patient,
  11952. // "number": token,
  11953. // })
  11954. // }
  11955. //} else {
  11956. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  11957. // return
  11958. //}
  11959. }
  11960. break
  11961. case 5:
  11962. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  11963. var api string
  11964. if miConfig.MdtrtareaAdmvs == "320921" {
  11965. 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 +
  11966. "&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
  11967. fmt.Println(api)
  11968. } else {
  11969. 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 +
  11970. "&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)
  11971. }
  11972. resp, requestErr := http.Get(api)
  11973. if requestErr != nil {
  11974. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11975. return
  11976. }
  11977. body, ioErr := ioutil.ReadAll(resp.Body)
  11978. if ioErr != nil {
  11979. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11980. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11981. return
  11982. }
  11983. var respJSON map[string]interface{}
  11984. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  11985. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11986. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11987. return
  11988. }
  11989. var status string
  11990. status = respJSON["data"].(map[string]interface{})["status"].(string)
  11991. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  11992. var token string
  11993. var res ResultTwo //1101结果
  11994. var res10265 ResultTwo10265 //1101结果
  11995. if status == "0" { //读卡成功
  11996. var card_info string //卡信息
  11997. //var busi_card_info string
  11998. var auth_info string
  11999. token = respJSON["data"].(map[string]interface{})["token"].(string)
  12000. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  12001. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  12002. auth_info = respJSON["data"].(map[string]interface{})["eletwo"].(string)
  12003. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  12004. result, _ := json.Marshal(respJSON)
  12005. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  12006. utils.ErrorLog("解析失败:%v", err)
  12007. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12008. return
  12009. }
  12010. res.ErrMsg = res10265.ErrMsg
  12011. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  12012. res.Infcode = infocode
  12013. res.Output = res10265.Output
  12014. res.InfRefmsgid = res10265.InfRefmsgid
  12015. if res.Infcode == 0 {
  12016. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  12017. if err == gorm.ErrRecordNotFound {
  12018. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  12019. return
  12020. } else if err != nil {
  12021. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  12022. return
  12023. } else {
  12024. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  12025. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  12026. infoStr := string(Iinfos)
  12027. idetinfoStr := string(Idetinfos)
  12028. b, age, _ := getBirthdateAndAge(res.Output.Baseinfo.Certno)
  12029. psn := &models.HisPsn{
  12030. PsnNo: res.Output.Baseinfo.PsnNo,
  12031. PatientId: patient.ID,
  12032. Certno: res.Output.Baseinfo.Certno,
  12033. Gend: res.Output.Baseinfo.Gend,
  12034. Brdy: b,
  12035. Age: float64(age),
  12036. Naty: res.Output.Baseinfo.Naty,
  12037. PsnCertType: res.Output.Baseinfo.PsnCertType,
  12038. PsnName: res.Output.Baseinfo.PsnName,
  12039. Idetinfo: idetinfoStr,
  12040. Insuinfo: infoStr,
  12041. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  12042. CardInfo: card_info,
  12043. VerifyNumber: token,
  12044. AuthInfo: auth_info,
  12045. }
  12046. var rf []*ResultFive
  12047. json.Unmarshal([]byte(infoStr), &rf)
  12048. var insutypes []*ResultFive
  12049. var insutype string
  12050. var is390 int = 0
  12051. var is310 int = 0
  12052. for _, item := range rf {
  12053. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  12054. insutypes = append(insutypes, item)
  12055. }
  12056. }
  12057. if len(insutypes) == 1 {
  12058. insutype = insutypes[0].Insutype
  12059. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  12060. } else {
  12061. for _, i := range insutypes {
  12062. if i.Insutype == "390" {
  12063. is390 = 1
  12064. }
  12065. if i.Insutype == "310" {
  12066. is310 = 1
  12067. }
  12068. }
  12069. }
  12070. if is390 == 1 {
  12071. insutype = "390"
  12072. }
  12073. if is310 == 1 {
  12074. insutype = "310"
  12075. }
  12076. if len(insutypes) == 0 {
  12077. insutype = "310"
  12078. }
  12079. service.CreateHisPsn(psn)
  12080. c.ServeSuccessJSON(map[string]interface{}{
  12081. "patient": patient,
  12082. "number": token,
  12083. "insutype": insutype,
  12084. })
  12085. }
  12086. } else {
  12087. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  12088. return
  12089. }
  12090. } else { //读卡失败
  12091. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  12092. return
  12093. }
  12094. }
  12095. break
  12096. }
  12097. }
  12098. var initFlag int64 = 0
  12099. var initEleFlag int64 = 0
  12100. func (c *HisApiController) TestGetBasBaseInit() {
  12101. DllDef := syscall.MustLoadDLL("SSCard.dll")
  12102. Iinit := DllDef.MustFindProc("Init")
  12103. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  12104. fmt.Println("http://hosp-sz.gd.hsip.gov.cn/gdyb_api/prd/api/card/initDll")
  12105. ret, _, err := Iinit.Call(StrPtr("http://hosp-sz.gd.hsip.gov.cn/gdyb_api/prd/api/card/initDll"), StrPtr(miConfig.InsuplcAdmdvs))
  12106. if ret != 0 {
  12107. fmt.Println("SSCard的报错原因:", err)
  12108. fmt.Println("SSCard的运算结果为:", ret)
  12109. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  12110. return
  12111. }
  12112. result := int(ret)
  12113. fmt.Println("SSCard的运算结果为1:", result)
  12114. initFlag = 1
  12115. return
  12116. }
  12117. func (c *HisApiController) HandleJiangXiReadCard() {
  12118. fmt.Println("~~~~~~")
  12119. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  12120. admin_user_id, _ := c.GetInt64("admin_user_id")
  12121. id_card_type, _ := c.GetInt64("id_card_type")
  12122. //certificates, _ := c.GetInt64("certificates")
  12123. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  12124. if initFlag == 0 {
  12125. c.TestGetJiangXiBasBaseInit()
  12126. }
  12127. basStr := c.GetBasBaseInfo()
  12128. if len(basStr) == 0 {
  12129. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  12130. return
  12131. }
  12132. fmt.Println(basStr)
  12133. bas := strings.Split(basStr, "|")
  12134. basNumber := bas[1]
  12135. fmt.Println(basNumber)
  12136. card_sn := bas[3]
  12137. fmt.Println(card_sn)
  12138. 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, "")
  12139. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  12140. var dat map[string]interface{}
  12141. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12142. fmt.Println(dat)
  12143. } else {
  12144. fmt.Println(err)
  12145. }
  12146. userJSONBytes, _ := json.Marshal(dat)
  12147. var res ResultTwo
  12148. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12149. utils.ErrorLog("解析失败:%v", err)
  12150. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12151. return
  12152. }
  12153. if res.Infcode == 0 {
  12154. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  12155. if err == gorm.ErrRecordNotFound {
  12156. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  12157. return
  12158. } else if err != nil {
  12159. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  12160. return
  12161. } else {
  12162. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  12163. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  12164. infoStr := string(Iinfos)
  12165. idetinfoStr := string(Idetinfos)
  12166. psn := &models.HisPsn{
  12167. PsnNo: res.Output.Baseinfo.PsnNo,
  12168. PatientId: patient.ID,
  12169. Certno: res.Output.Baseinfo.Certno,
  12170. Gend: res.Output.Baseinfo.Gend,
  12171. Naty: res.Output.Baseinfo.Naty,
  12172. PsnCertType: res.Output.Baseinfo.PsnCertType,
  12173. PsnName: res.Output.Baseinfo.PsnName,
  12174. Idetinfo: idetinfoStr,
  12175. Insuinfo: infoStr,
  12176. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  12177. CardInfo: basStr,
  12178. VerifyNumber: "",
  12179. }
  12180. service.CreateHisPsn(psn)
  12181. c.ServeSuccessJSON(map[string]interface{}{
  12182. "patient": patient,
  12183. "number": basNumber,
  12184. })
  12185. }
  12186. } else {
  12187. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  12188. return
  12189. }
  12190. }
  12191. func (c *HisApiController) TestGetHnBasBaseInit() {
  12192. DllDef := syscall.MustLoadDLL("SSCard.dll")
  12193. Iinit := DllDef.MustFindProc("Init")
  12194. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  12195. //http://10.77.211.236/CSB/hsa-fsi-1303
  12196. ret, _, err := Iinit.Call(StrPtr("http://10.93.32.89:20001/hsa-hgs-adapt/api/card/initDll"), StrPtr("430100|10.93.32.89:20001"))
  12197. if ret != 0 {
  12198. fmt.Println("SSCard的报错原因:", err)
  12199. fmt.Println("SSCard的运算结果为:", ret)
  12200. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  12201. return
  12202. }
  12203. result := int(ret)
  12204. fmt.Println("SSCard的运算结果为1:", result)
  12205. initFlag = 1
  12206. return
  12207. }
  12208. func (c *HisApiController) TestGetJiangXiBasBaseInit() {
  12209. DllDef := syscall.MustLoadDLL("SSCard.dll")
  12210. Iinit := DllDef.MustFindProc("Init")
  12211. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  12212. //http://10.77.211.236/CSB/hsa-fsi-1303
  12213. ret, _, err := Iinit.Call(StrPtr("http://10.77.224.18:9001/1.0.0/agent-card-init"), StrPtr("360302"))
  12214. if ret != 0 {
  12215. fmt.Println("SSCard的报错原因:", err)
  12216. fmt.Println("SSCard的运算结果为:", ret)
  12217. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  12218. return
  12219. }
  12220. result := int(ret)
  12221. fmt.Println("SSCard的运算结果为1:", result)
  12222. initFlag = 1
  12223. return
  12224. }
  12225. func (c *HisApiController) GetSFZBaseInfo() string {
  12226. DllDef := syscall.MustLoadDLL("SSCard.dll")
  12227. readCard := DllDef.MustFindProc("ReadSFZ")
  12228. if readCard == nil {
  12229. fmt.Println("readcard is nil")
  12230. readCard = DllDef.MustFindProc("ReadSFZ")
  12231. }
  12232. str := make([]byte, 8096)
  12233. str1 := make([]byte, 8096)
  12234. r, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(8096), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(8096))
  12235. fmt.Println(r)
  12236. return Remove0000(string(str))
  12237. }
  12238. func (c *HisApiController) GetEleBaseInfo() string {
  12239. DllDef := syscall.MustLoadDLL("SSCard.dll")
  12240. readCard := DllDef.MustFindProc("GetQRBase")
  12241. fmt.Println(readCard)
  12242. if readCard == nil {
  12243. fmt.Println("readcard is nil")
  12244. readCard = DllDef.MustFindProc("GetQRBase")
  12245. }
  12246. str := make([]byte, 1024)
  12247. str1 := make([]byte, 1024)
  12248. ret2, _, _ := readCard.Call(uintptr(180), (uintptr)(unsafe.Pointer(&str[0])), uintptr(1024), (uintptr)(unsafe.Pointer(&str1[0])), uintptr(1024))
  12249. fmt.Println(ret2)
  12250. fmt.Println(string(str1))
  12251. fmt.Println(string(str))
  12252. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  12253. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  12254. if ret2 != 0 {
  12255. return ""
  12256. }
  12257. return string(str)
  12258. }
  12259. func GetHnEleBaseInfo(code string, operator_id int64, operator_name string) (string, string) {
  12260. DllDef := syscall.MustLoadDLL("NationECCode.dll")
  12261. readCard := DllDef.MustFindProc("NationEcTrans")
  12262. fmt.Println(readCard)
  12263. fmt.Println("!!!!!")
  12264. pBusiCardInfo := make([]byte, 2048)
  12265. input := make(map[string]interface{})
  12266. inputData := make(map[string]interface{})
  12267. inputData["orgId"] = code
  12268. inputData["businessType"] = "01101"
  12269. inputData["operatorId"] = "1"
  12270. inputData["operatorName"] = "admin"
  12271. inputData["officeId"] = "001"
  12272. inputData["officeName"] = "血透室"
  12273. inputData["deviceType"] = ""
  12274. input["data"] = inputData
  12275. input["orgId"] = code
  12276. input["transType"] = "ec.query"
  12277. bytesData, _ := json.Marshal(input)
  12278. ret2, _, _ := readCard.Call(StrPtr("https://10.93.32.89:20001/localcfc/api/hsecfc/localQrCodeQuery"), StrPtr(string(bytesData)), (uintptr)(unsafe.Pointer(&pBusiCardInfo[0])))
  12279. fmt.Println(ret2)
  12280. fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  12281. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  12282. return DeleteExtraSpace(""), DeleteExtraSpace(string(pBusiCardInfo))
  12283. }
  12284. func GetgdEleBaseInfo(code string, operator_id int64, operator_name string) (string, string) {
  12285. DllDef := syscall.MustLoadDLL("NationECCode.dll")
  12286. readCard := DllDef.MustFindProc("NationEcTrans")
  12287. fmt.Println(readCard)
  12288. fmt.Println("!!!!!")
  12289. pBusiCardInfo := make([]byte, 2048)
  12290. input := make(map[string]interface{})
  12291. inputData := make(map[string]interface{})
  12292. inputData["orgId"] = code
  12293. inputData["businessType"] = "01101"
  12294. inputData["operatorId"] = "9"
  12295. inputData["operatorName"] = "admin"
  12296. inputData["officeId"] = "001"
  12297. inputData["officeName"] = "血透室"
  12298. inputData["deviceType"] = ""
  12299. input["data"] = inputData
  12300. input["orgId"] = code
  12301. input["transType"] = "ec.query"
  12302. bytesData, _ := json.Marshal(input)
  12303. 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])))
  12304. fmt.Println(ret2)
  12305. fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  12306. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  12307. return DeleteExtraSpace(""), ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8")
  12308. }
  12309. func GetgdEleBaseInfoTwo(code string, operator_id int64, operator_name string) (string, string) {
  12310. DllDef := syscall.MustLoadDLL("NationECCode.dll")
  12311. readCard := DllDef.MustFindProc("NationEcTrans")
  12312. fmt.Println(readCard)
  12313. fmt.Println("!!!!!")
  12314. pBusiCardInfo := make([]byte, 2048)
  12315. input := make(map[string]interface{})
  12316. inputData := make(map[string]interface{})
  12317. inputData["orgId"] = code
  12318. inputData["businessType"] = "01301"
  12319. inputData["operatorId"] = "9"
  12320. inputData["operatorName"] = "admin"
  12321. inputData["officeId"] = "001"
  12322. inputData["officeName"] = "血透室"
  12323. inputData["deviceType"] = ""
  12324. input["data"] = inputData
  12325. input["orgId"] = code
  12326. input["transType"] = "ec.query"
  12327. bytesData, _ := json.Marshal(input)
  12328. 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])))
  12329. fmt.Println(ret2)
  12330. fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  12331. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  12332. return DeleteExtraSpace(""), ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8")
  12333. }
  12334. func GetJxEleBaseInfo(org_id int64) string {
  12335. DllDef := syscall.MustLoadDLL("SSCard.dll")
  12336. readCard := DllDef.MustFindProc("NationEcTrans")
  12337. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  12338. if readCard == nil {
  12339. fmt.Println("readcard is nil")
  12340. readCard = DllDef.MustFindProc("NationEcTrans")
  12341. }
  12342. str1 := make([]byte, 1024)
  12343. data := make(map[string]interface{})
  12344. inputData := make(map[string]interface{})
  12345. inputData["orgId"] = miConfig.Code
  12346. inputData["businessType"] = "01101"
  12347. inputData["operatorId"] = "test001"
  12348. inputData["operatorName"] = "cn"
  12349. inputData["officeId"] = "32760"
  12350. inputData["officeName"] = "waike"
  12351. inputData["deviceType"] = ""
  12352. data["data"] = inputData
  12353. data["transType"] = "ec.query"
  12354. data["extra "] = ""
  12355. data["orgId"] = miConfig.Code
  12356. bytesData, _ := json.Marshal(data)
  12357. //bytesData, _ := json.Marshal(data)
  12358. //bytesData = []byte(ConvertToString(string(bytesData), "utf-8", "gbk"))
  12359. ret2, _, _ := readCard.Call(StrPtr("http://10.77.224.18:9001/1.0.0/localQrCodeQuery"), (uintptr)(unsafe.Pointer(&bytesData[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  12360. fmt.Println(ret2)
  12361. fmt.Println(string(str1))
  12362. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  12363. if ret2 != 0 {
  12364. return ""
  12365. }
  12366. return Remove0000(ConvertToString(string(str1), "gbk", "utf-8"))
  12367. }
  12368. func GetJxEleBaseInitInfo(org_id int64) string {
  12369. DllDef := syscall.MustLoadDLL("SSCard.dll")
  12370. readCard := DllDef.MustFindProc("NationEcTrans")
  12371. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  12372. if readCard == nil {
  12373. fmt.Println("readcard is nil")
  12374. readCard = DllDef.MustFindProc("NationEcTrans")
  12375. }
  12376. str1 := make([]byte, 2048)
  12377. data := make(map[string]interface{})
  12378. inputData := make(map[string]interface{})
  12379. inputData["orgId"] = miConfig.Code
  12380. inputData["businessType"] = "01101"
  12381. inputData["operatorId"] = "1"
  12382. inputData["operatorName"] = "huangchuang"
  12383. inputData["officeId"] = "101"
  12384. inputData["officeName"] = "xuetou"
  12385. inputData["deviceType"] = ""
  12386. data["data"] = inputData
  12387. data["transType"] = "ec.query"
  12388. data["orgId"] = miConfig.Code
  12389. bytesData, _ := json.Marshal(data)
  12390. bytesData = []byte(ConvertToString(string(bytesData), "utf-8", "gbk"))
  12391. ret2, _, _ := readCard.Call(StrPtr("http://10.77.224.18:9001/1.0.0/getEncDynamicKey"), (uintptr)(unsafe.Pointer(&bytesData[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  12392. fmt.Println("http://10.77.224.18:9001/1.0.0/getEncDynamicKey")
  12393. fmt.Println(ret2)
  12394. fmt.Println(string(str1))
  12395. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  12396. if ret2 != 0 {
  12397. return ""
  12398. }
  12399. if len(Remove0000(ConvertToString(string(str1), "gbk", "utf-8"))) > 0 {
  12400. initEleFlag = 1
  12401. }
  12402. return Remove0000(ConvertToString(string(str1), "gbk", "utf-8"))
  12403. }
  12404. //func (c *HisApiController)GetgxBasBaseInfotwo() {
  12405. // // 构建命令
  12406. // cmd := exec.Command("python", "b.py")
  12407. //
  12408. // // 执行命令并等待完成
  12409. // output, err := cmd.CombinedOutput()
  12410. // if err != nil {
  12411. // fmt.Println("Error executing Python script:", err)
  12412. // return
  12413. // }
  12414. //
  12415. // // 打印Python脚本的输出
  12416. // fmt.Println(string(output))
  12417. //}
  12418. func (c *HisApiController) GetgxBasBaseInfo(code string) string {
  12419. DllDef := syscall.MustLoadDLL("yh_interface_xyb.dll")
  12420. readCard := DllDef.MustFindProc("gxyb_call")
  12421. if readCard == nil {
  12422. fmt.Println("readcard is nil")
  12423. readCard = DllDef.MustFindProc("gxyb_call")
  12424. }
  12425. str := make([]byte, 1024)
  12426. str1 := make([]byte, 1024)
  12427. //data := make(map[string]interface{})
  12428. currentTime := time.Now()
  12429. // 格式化时间为 "YYYYMMDDHH24MISS"
  12430. formattedTime := currentTime.Format("20060102150405")
  12431. inputData := make(map[string]interface{})
  12432. inputData2 := make(map[string]interface{})
  12433. inputData["transNo"] = "1401"
  12434. inputData["transType"] = "passwordCheck"
  12435. inputData["timestamp"] = formattedTime
  12436. inputData2["fixmedinsCode"] = code
  12437. inputData2["psnNo"] = ""
  12438. inputData["data"] = inputData2
  12439. jsonBytes, err := json.Marshal(inputData)
  12440. if err != nil {
  12441. fmt.Println("Error encoding map to JSON:", err)
  12442. }
  12443. ret2, _, _ := readCard.Call(StrPtr("1401"), (uintptr)(unsafe.Pointer(&jsonBytes[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  12444. fmt.Println(string(str1))
  12445. fmt.Println(string(str))
  12446. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  12447. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  12448. if ret2 != 0 {
  12449. return ""
  12450. }
  12451. return string(str)
  12452. }
  12453. func (c *HisApiController) GetoleInfo() Response {
  12454. ole.CoInitializeEx(0, ole.COINIT_MULTITHREADED)
  12455. defer ole.CoUninitialize()
  12456. // Replace with the ProgID or CLSID of your COM object
  12457. progID := "YinHai.XJ.Actual.Interface.New"
  12458. // Create COM object
  12459. unknown, err := oleutil.CreateObject(progID)
  12460. if err != nil {
  12461. fmt.Println("Unable to create COM object:", err)
  12462. }
  12463. defer unknown.Release()
  12464. // Query for the IDispatch interface
  12465. dispatch, err := unknown.QueryInterface(ole.IID_IDispatch)
  12466. if err != nil {
  12467. fmt.Println("Unable to get IDispatch interface:", err)
  12468. }
  12469. defer dispatch.Release()
  12470. // Prepare parameters
  12471. transNo := "1401"
  12472. transType := "passwordCheck"
  12473. timestamp := time.Now().Unix()
  12474. fixmedinsCode := "H45072101171"
  12475. psnNo := ""
  12476. data := fmt.Sprintf(`{"transNo":"%s","transType":"%s","timestamp":"%s","data":{"fixmedinsCode":"%s","psnNo":"%s"}}`, transNo, transType, timestamp, fixmedinsCode, psnNo)
  12477. result2 := ""
  12478. // Call COM object's method using the IDispatch interface
  12479. resulr, err := oleutil.CallMethod(dispatch, "gxyb_call", "1401", data, &result2)
  12480. fmt.Println(resulr)
  12481. fmt.Println(result2)
  12482. if err != nil {
  12483. fmt.Println("调用COM对象方法失败:", err)
  12484. }
  12485. var response Response
  12486. err2 := json.Unmarshal([]byte(result2), &response)
  12487. if err2 != nil {
  12488. fmt.Println("解析JSON失败:", err)
  12489. }
  12490. return response
  12491. }
  12492. func (c *HisApiController) GetBasBaseInfo() string {
  12493. DllDef := syscall.MustLoadDLL("SSCard.dll")
  12494. readCard := DllDef.MustFindProc("ReadCardBas")
  12495. if readCard == nil {
  12496. fmt.Println("readcard is nil")
  12497. readCard = DllDef.MustFindProc("ReadCardBas")
  12498. }
  12499. str := make([]byte, 1024)
  12500. str1 := make([]byte, 1024)
  12501. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), uintptr(1024), (uintptr)(unsafe.Pointer(&str1[0])), uintptr(1024))
  12502. fmt.Println(string(str1))
  12503. fmt.Println(string(str))
  12504. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  12505. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  12506. if ret2 != 0 {
  12507. return ""
  12508. }
  12509. return string(str)
  12510. }
  12511. func (c *HisApiController) GetFjBasBaseInfo() (string, string, string, string, string) {
  12512. DllDef := syscall.MustLoadDLL("chs_fjs_standard.dll")
  12513. readCard := DllDef.MustFindProc("read_cardinfo")
  12514. if readCard == nil {
  12515. fmt.Println("readcard is nil")
  12516. readCard = DllDef.MustFindProc("read_cardinfo")
  12517. }
  12518. str := make([]byte, 1024) //卡号
  12519. str1 := make([]byte, 1024) //卡识别码
  12520. str2 := make([]byte, 1024) //身份证号
  12521. str3 := make([]byte, 1024) //姓名
  12522. str4 := make([]byte, 1024) //错误信息
  12523. 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])))
  12524. fmt.Println(string(str1))
  12525. fmt.Println(string(str))
  12526. fmt.Println(string(str2))
  12527. fmt.Println(string(str3))
  12528. fmt.Println(string(str4))
  12529. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  12530. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  12531. fmt.Println(":", ConvertToString(string(str2), "gbk", "utf-8"))
  12532. fmt.Println(":", ConvertToString(string(str3), "gbk", "utf-8"))
  12533. fmt.Println(":", ConvertToString(string(str4), "gbk", "utf-8"))
  12534. if ret2 != 0 {
  12535. return "", "", "", "", ""
  12536. }
  12537. return string(str), string(str1), string(str2), string(str3), string(str4)
  12538. }
  12539. type CustomFundPay struct {
  12540. FundPayType string `json:"fund_pay_type"`
  12541. FundPayamt float64 `json:"fund_payamt"`
  12542. InscpScpAmt float64 `json:"inscp_scp_amt"`
  12543. }
  12544. //func (c *HisApiController) GetBatchSettleList() {
  12545. // start_time_str := c.GetString("start_time")
  12546. // //end_time_str := c.GetString("end_time")
  12547. // admin_user_id, _ := c.GetInt64("admin_user_id")
  12548. //
  12549. // orders,_ := service.GetHisOrderByIDThree(start_time_str)
  12550. //
  12551. // for _, item := range orders {
  12552. // order, _ := service.GetHisOrderByIDTwo(item.ID)
  12553. // roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  12554. // his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  12555. // admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  12556. // curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  12557. // //depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  12558. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  12559. // pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  12560. // doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  12561. //
  12562. // if order.ID == 0 {
  12563. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  12564. // return
  12565. // }
  12566. //
  12567. // //last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  12568. // //max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  12569. // //count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  12570. // //fmt.Println(count)
  12571. // //var zero string
  12572. // //number := count + 1
  12573. // //if number >= 1000 {
  12574. // // zero = "0000" + strconv.FormatInt(number, 10)
  12575. // //} else if number >= 10000 {
  12576. // // zero = "000" + strconv.FormatInt(number, 10)
  12577. // //} else if number >= 100000 {
  12578. // // zero = "00" + strconv.FormatInt(number, 10)
  12579. // //} else if number >= 1000000 {
  12580. // // zero = "0" + strconv.FormatInt(number, 10)
  12581. // //} else {
  12582. // // zero = strconv.FormatInt(number, 10)
  12583. // //}
  12584. // //fmt.Println(zero)
  12585. //
  12586. // struct4101 := service.Struct4101{
  12587. // PsnNo: order.PsnNo,
  12588. // MdtrtId: order.MdtrtId,
  12589. // SetlId: order.SetlId,
  12590. // PsnName: order.PsnName,
  12591. // Gend: order.Gend,
  12592. // Brdy: his.Brdy,
  12593. // Age: his.Age,
  12594. // Naty: order.Naty,
  12595. // PatnCertType: "01",
  12596. // Certno: order.Certno,
  12597. // Prfs: "90",
  12598. // ConerName: roles[0].UserName,
  12599. // PatnRlts: "99",
  12600. // ConerAddr: miConfig.OrgName,
  12601. // ConerTel: admin.Mobile,
  12602. // HiType: order.Insutype,
  12603. // Insuplc: miConfig.InsuplcAdmdvs,
  12604. // MaindiagFlag: "1",
  12605. // BillCode: order.SetlId,
  12606. // BillNo: order.SetlId,
  12607. // BizSn: order.Number,
  12608. // PsnSelfPay: order.PsnPartAmt,
  12609. // PsnOwnPay: order.PsnPartAmt,
  12610. // AcctPay: order.AcctPay,
  12611. // PsnCashpay: order.PsnCashPay,
  12612. // HiPaymtd: "1",
  12613. // Hsorg: miConfig.InsuplcAdmdvs,
  12614. // HsorgOpter: miConfig.InsuplcAdmdvs,
  12615. // MedinsFillPsn: curRoles.UserName,
  12616. // MedinsFillDept: miConfig.OrgName,
  12617. // IptMedType: "2",
  12618. // }
  12619. // struct4101.SetlBegnDate = order.SetlTime
  12620. // struct4101.SetlEndDate = order.SetlTime
  12621. // time_arr := strings.Split(order.SetlTime, " ")
  12622. // struct4101.AdmTime = time_arr[0]
  12623. // struct4101.AdmEndTime = time_arr[0]
  12624. //
  12625. // var rf []CustomFundPay
  12626. // json.Unmarshal([]byte(order.SetlDetail), &rf)
  12627. //
  12628. // var tempFunPays []service.CustomStruct
  12629. // for _, item := range rf {
  12630. // var tempFunPay service.CustomStruct
  12631. // tempFunPay.FundPayamt = item.FundPayamt
  12632. // tempFunPay.FundPayType = item.FundPayType
  12633. // tempFunPays = append(tempFunPays, tempFunPay)
  12634. // }
  12635. // struct4101.CustomStruct = tempFunPays
  12636. //
  12637. // var tempDiaginfos []service.DiaginfoStructTwo
  12638. // var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  12639. // var tempOpspdiseinfos []service.OpspdiseinfoStruct
  12640. //
  12641. // diagnosis_ids := strings.Split(his.Diagnosis, ",")
  12642. // var config []*models.HisXtDiagnoseConfig
  12643. // for _, item := range diagnosis_ids {
  12644. // id, _ := strconv.ParseInt(item, 10, 64)
  12645. // diagnosisConfig, _ := service.FindDiagnoseById(id)
  12646. // config = append(config, &diagnosisConfig)
  12647. // }
  12648. //
  12649. // for index, item := range config {
  12650. // if index == 0 {
  12651. // var tempDiaginfo service.DiaginfoStructTwo
  12652. // tempDiaginfo.DiagCode = item.CountryCode
  12653. // tempDiaginfo.DiagName = item.CountryContentName
  12654. // tempDiaginfo.DiagType = "1"
  12655. // tempDiaginfo.MaindiagFlag = "1"
  12656. // tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  12657. // } else {
  12658. // var tempDiaginfo service.DiaginfoStructTwo
  12659. // tempDiaginfo.DiagCode = item.CountryCode
  12660. // tempDiaginfo.DiagName = item.CountryContentName
  12661. // tempDiaginfo.DiagType = "1"
  12662. // tempDiaginfo.MaindiagFlag = "0"
  12663. // tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  12664. // }
  12665. // }
  12666. // struct4101.Diseinfo = tempDiaginfos
  12667. //
  12668. // sickConfigTwo, _ := service.FindSickById(his.SickType)
  12669. // tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  12670. // tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  12671. // tempOpspdiseinfo2.OprnOprtCode = sickConfigTwo.ContentCode
  12672. // tempOpspdiseinfo2.OprnOprtName = sickConfigTwo.CountryContentName
  12673. // tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  12674. // struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  12675. //
  12676. // var iteminfo service.IteminfoStruct
  12677. //
  12678. // var bedCostTotal float64 = 0 //床位总费
  12679. // var bedCostSelfTotal float64 = 0 //床位自费
  12680. // var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  12681. //
  12682. // var operationCostTotal float64 = 0 //手术费
  12683. // var operationCostSelfTotal float64 = 0 //手术费
  12684. // var operationCostPartSelfTotal float64 = 0 //手术费
  12685. //
  12686. // var otherCostTotal float64 = 0 //其他费用
  12687. // var otherCostSelfTotal float64 = 0 //其他费用
  12688. // var otherCostPartSelfTotal float64 = 0 //其他费用
  12689. //
  12690. // var materialCostTotal float64 = 0 //材料费
  12691. // var materialCostSelfTotal float64 = 0 //材料费
  12692. // var materialCostPartSelfTotal float64 = 0 //材料费
  12693. //
  12694. // var westernMedicineCostTotal float64 = 0 //西药费
  12695. // var westernMedicineCostSelfTotal float64 = 0 //西药费
  12696. // var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  12697. //
  12698. // var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  12699. // var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  12700. // var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  12701. //
  12702. // var checkCostTotal float64 = 0 //检查费
  12703. // var checkCostSelfTotal float64 = 0 //检查费
  12704. // var checkCostPartSelfTotal float64 = 0 //检查费
  12705. //
  12706. // var laboratoryCostTotal float64 = 0 //化验费
  12707. // var laboratoryCostSelfTotal float64 = 0 //化验费
  12708. // var laboratoryCostPartSelfTotal float64 = 0 //化验费
  12709. //
  12710. // var treatCostTotal float64 = 0 //治疗费用
  12711. // var treatCostSelfTotal float64 = 0 //治疗费用
  12712. // var treatCostPartSelfTotal float64 = 0 //治疗费用
  12713. //
  12714. // decimal.DivisionPrecision = 2
  12715. //
  12716. // var bed_fulamt_ownpay_amt float64 = 0
  12717. // var operation_fulamt_ownpay_amt float64 = 0
  12718. // var other_fulamt_ownpay_amt float64 = 0
  12719. // var westernMedicine_fulamt_ownpay_amt float64 = 0
  12720. // var chineseTraditional_fulamt_ownpay_amt float64 = 0
  12721. // var check_fulamt_ownpay_amt float64 = 0
  12722. // var material_fulamt_ownpay_amt float64 = 0
  12723. // var laboratory_fulamt_ownpay_amt float64 = 0
  12724. // var treat_fulamt_ownpay_amt float64 = 0
  12725. //
  12726. // var bed_claa_sunmfee float64 = 0
  12727. // var bed_clab_amt float64 = 0
  12728. // var bed_other_amt float64 = 0
  12729. //
  12730. // var operation_claa_sunmfee float64 = 0
  12731. // var operation_clab_amt float64 = 0
  12732. // var operation_other_amt float64 = 0
  12733. //
  12734. // var other_claa_sunmfee float64 = 0
  12735. // var other_clab_amt float64 = 0
  12736. // var other_other_amt float64 = 0
  12737. //
  12738. // var westernMedicine_claa_sunmfee float64 = 0
  12739. // var westernMedicine_clab_amt float64 = 0
  12740. // var westernMedicine_other_amt float64 = 0
  12741. //
  12742. // var chineseTraditional_claa_sunmfee float64 = 0
  12743. // var chineseTraditional_clab_amt float64 = 0
  12744. // var chineseTraditional_other_amt float64 = 0
  12745. //
  12746. // var check_claa_sunmfee float64 = 0
  12747. // var check_clab_amt float64 = 0
  12748. // var check_other_amt float64 = 0
  12749. //
  12750. // var material_claa_sunmfee float64 = 0
  12751. // var material_clab_amt float64 = 0
  12752. // var material_other_amt float64 = 0
  12753. //
  12754. // var laboratory_claa_sunmfee float64 = 0
  12755. // var laboratory_clab_amt float64 = 0
  12756. // var laboratory_other_amt float64 = 0
  12757. //
  12758. // var treat_claa_sunmfee float64 = 0
  12759. // var treat_clab_amt float64 = 0
  12760. // var treat_other_amt float64 = 0
  12761. //
  12762. // for _, item := range order.HisOrderInfo {
  12763. // if item.MedChrgitmType == "01" { //床位费
  12764. // bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12765. // bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12766. // bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12767. // bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  12768. // if item.ChrgitmLv == "1" {
  12769. // bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12770. // }
  12771. // if item.ChrgitmLv == "2" {
  12772. // bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12773. //
  12774. // }
  12775. // if item.ChrgitmLv == "3" {
  12776. // bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12777. // }
  12778. //
  12779. // }
  12780. //
  12781. // if item.MedChrgitmType == "03" { //检查费
  12782. // checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12783. // checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12784. // checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12785. // check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  12786. // if item.ChrgitmLv == "1" {
  12787. //
  12788. // check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12789. //
  12790. // }
  12791. // if item.ChrgitmLv == "2" {
  12792. // check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12793. //
  12794. // }
  12795. // if item.ChrgitmLv == "3" {
  12796. // check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12797. // }
  12798. // }
  12799. //
  12800. // if item.MedChrgitmType == "04" { //化验费
  12801. // laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12802. // laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12803. // laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12804. // laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  12805. // if item.ChrgitmLv == "1" {
  12806. //
  12807. // laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12808. //
  12809. // }
  12810. // if item.ChrgitmLv == "2" {
  12811. // laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12812. //
  12813. // }
  12814. // if item.ChrgitmLv == "3" {
  12815. // laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12816. // }
  12817. // }
  12818. //
  12819. // if item.MedChrgitmType == "05" { //治疗费
  12820. // treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12821. // treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12822. // treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12823. // treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  12824. // if item.ChrgitmLv == "1" {
  12825. //
  12826. // treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12827. //
  12828. // }
  12829. // if item.ChrgitmLv == "2" {
  12830. // treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12831. //
  12832. // }
  12833. // if item.ChrgitmLv == "3" {
  12834. // treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12835. // }
  12836. // }
  12837. //
  12838. // if item.MedChrgitmType == "06" { //手术费
  12839. // operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12840. // operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12841. // operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12842. // operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  12843. //
  12844. // if item.ChrgitmLv == "1" {
  12845. //
  12846. // operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12847. //
  12848. // }
  12849. // if item.ChrgitmLv == "2" {
  12850. // operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12851. //
  12852. // }
  12853. // if item.ChrgitmLv == "3" {
  12854. // operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12855. // }
  12856. // }
  12857. //
  12858. // if item.MedChrgitmType == "08" { //材料费
  12859. // materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12860. // materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12861. // materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12862. // material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  12863. // if item.ChrgitmLv == "1" {
  12864. //
  12865. // material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12866. //
  12867. // }
  12868. // if item.ChrgitmLv == "2" {
  12869. // material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12870. //
  12871. // }
  12872. // if item.ChrgitmLv == "3" {
  12873. // material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12874. // }
  12875. // }
  12876. //
  12877. // if item.MedChrgitmType == "09" { //西药费
  12878. // westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12879. // westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12880. // westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12881. // westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  12882. // if item.ChrgitmLv == "1" {
  12883. //
  12884. // westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12885. //
  12886. // }
  12887. // if item.ChrgitmLv == "2" {
  12888. // westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12889. //
  12890. // }
  12891. // if item.ChrgitmLv == "3" {
  12892. // westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12893. // }
  12894. // }
  12895. //
  12896. // if item.MedChrgitmType == "11" { //中成费
  12897. // chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12898. // chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12899. // chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12900. // chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  12901. // if item.ChrgitmLv == "1" {
  12902. //
  12903. // chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12904. //
  12905. // }
  12906. // if item.ChrgitmLv == "2" {
  12907. // chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12908. //
  12909. // }
  12910. // if item.ChrgitmLv == "3" {
  12911. // chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12912. // }
  12913. // }
  12914. //
  12915. // if item.MedChrgitmType == "14" { //其他费
  12916. // otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12917. // otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12918. // otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12919. // other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  12920. // if item.ChrgitmLv == "1" {
  12921. // other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12922. //
  12923. // }
  12924. // if item.ChrgitmLv == "2" {
  12925. // other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12926. //
  12927. // }
  12928. // if item.ChrgitmLv == "3" {
  12929. // other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12930. // }
  12931. // }
  12932. //
  12933. // }
  12934. //
  12935. // var iteminfoStructs []service.IteminfoStruct
  12936. //
  12937. // if bedCostTotal != 0 {
  12938. // iteminfo.MedChrgitm = "01"
  12939. // iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  12940. // iteminfo.Amt = bedCostTotal
  12941. // iteminfo.ClaaSumfee = bed_claa_sunmfee
  12942. // iteminfo.ClabAmt = bed_clab_amt
  12943. // iteminfo.OthAmt = bed_other_amt
  12944. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  12945. // }
  12946. //
  12947. // if checkCostTotal != 0 {
  12948. // iteminfo.MedChrgitm = "03"
  12949. // iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  12950. // iteminfo.Amt = checkCostTotal
  12951. // iteminfo.ClaaSumfee = check_claa_sunmfee
  12952. // iteminfo.ClabAmt = check_clab_amt
  12953. // iteminfo.OthAmt = check_other_amt
  12954. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  12955. //
  12956. // }
  12957. //
  12958. // if laboratoryCostTotal != 0 {
  12959. // iteminfo.MedChrgitm = "04"
  12960. // iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  12961. // iteminfo.Amt = laboratoryCostTotal
  12962. // iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  12963. // iteminfo.ClabAmt = laboratory_clab_amt
  12964. // iteminfo.OthAmt = laboratory_other_amt
  12965. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  12966. //
  12967. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  12968. //
  12969. // }
  12970. //
  12971. // if treatCostTotal != 0 {
  12972. // iteminfo.MedChrgitm = "05"
  12973. // iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  12974. // iteminfo.Amt = treatCostTotal
  12975. // iteminfo.ClaaSumfee = treat_claa_sunmfee
  12976. // iteminfo.ClabAmt = treat_clab_amt
  12977. // iteminfo.OthAmt = treat_other_amt
  12978. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  12979. // //(struct4101.IteminfoStruct, iteminfo)
  12980. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  12981. // }
  12982. //
  12983. // if operationCostTotal != 0 {
  12984. // iteminfo.MedChrgitm = "06"
  12985. // iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  12986. // iteminfo.Amt = operationCostTotal
  12987. // iteminfo.ClaaSumfee = operation_claa_sunmfee
  12988. // iteminfo.ClabAmt = operation_clab_amt
  12989. // iteminfo.OthAmt = operation_other_amt
  12990. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  12991. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  12992. // }
  12993. //
  12994. // if materialCostTotal != 0 {
  12995. // iteminfo.MedChrgitm = "08"
  12996. // iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  12997. // iteminfo.Amt = materialCostTotal
  12998. // iteminfo.ClaaSumfee = material_claa_sunmfee
  12999. // iteminfo.ClabAmt = material_clab_amt
  13000. // iteminfo.OthAmt = material_other_amt
  13001. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  13002. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  13003. // }
  13004. //
  13005. // if westernMedicineCostTotal != 0 {
  13006. // iteminfo.MedChrgitm = "09"
  13007. // iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  13008. // iteminfo.Amt = westernMedicineCostTotal
  13009. // iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  13010. // iteminfo.ClabAmt = westernMedicine_clab_amt
  13011. // iteminfo.OthAmt = westernMedicine_other_amt
  13012. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  13013. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  13014. //
  13015. // }
  13016. // if chineseTraditionalMedicineCostTotal != 0 {
  13017. // iteminfo.MedChrgitm = "11"
  13018. // iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  13019. // iteminfo.Amt = westernMedicineCostTotal
  13020. // iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  13021. // iteminfo.ClabAmt = westernMedicine_clab_amt
  13022. // iteminfo.OthAmt = westernMedicine_other_amt
  13023. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  13024. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  13025. //
  13026. // }
  13027. // if otherCostTotal != 0 {
  13028. // iteminfo.MedChrgitm = "14"
  13029. // iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  13030. // iteminfo.Amt = otherCostTotal
  13031. // iteminfo.ClaaSumfee = other_claa_sunmfee
  13032. // iteminfo.ClabAmt = other_clab_amt
  13033. // iteminfo.OthAmt = other_other_amt
  13034. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  13035. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  13036. //
  13037. // }
  13038. // struct4101.IteminfoStruct = iteminfoStructs
  13039. // struct4101.Ntly = "中国"
  13040. // struct4101.AdmCaty = "A03.06"
  13041. //
  13042. // struct4101.DoctorName = doctor.UserName
  13043. // struct4101.DoctorCode = doctor.DoctorNumber
  13044. //
  13045. // var res ResultSeventeen
  13046. //
  13047. // if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  13048. // struct4101.BillCode = order.Number
  13049. // struct4101.BillNo = order.SetlId
  13050. // var resOther ResultSeventeenOther
  13051. // var pp models.PublicParams
  13052. // pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  13053. // pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  13054. // pp.FixmedinsName = miConfig.OrgName
  13055. // pp.FixmedinsCode = miConfig.Code
  13056. // pp.RequestUrl = miConfig.Url
  13057. // pp.Cainfo = miConfig.Cainfo
  13058. // pp.SecretKey = miConfig.SecretKey
  13059. // pp.AccessKey = miConfig.AccessKey
  13060. // pp.OpterName = curRoles.UserName
  13061. //
  13062. // client := &http.Client{}
  13063. // var req *http.Request
  13064. // data := make(map[string]interface{})
  13065. // data["struct4101"] = struct4101
  13066. // data["pp"] = pp
  13067. // bytesData, _ := json.Marshal(data)
  13068. // if miConfig.MdtrtareaAdmvs == "320921" {
  13069. // req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  13070. // } else {
  13071. // req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  13072. // }
  13073. // resp, _ := client.Do(req)
  13074. // defer resp.Body.Close()
  13075. // body, ioErr := ioutil.ReadAll(resp.Body)
  13076. // if ioErr != nil {
  13077. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13078. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13079. // return
  13080. // }
  13081. // var respJSON map[string]interface{}
  13082. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  13083. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13084. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13085. // return
  13086. // }
  13087. //
  13088. // respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  13089. // userJSONBytes, _ := json.Marshal(respJSON)
  13090. // fmt.Println("log")
  13091. // fmt.Println(string(userJSONBytes))
  13092. // if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  13093. // utils.ErrorLog("解析失败:%v", err)
  13094. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13095. // return
  13096. // }
  13097. // res.InfRefmsgid = resOther.InfRefmsgid
  13098. // res.Output = resOther.Output
  13099. // res.ErrMsg = resOther.ErrMsg
  13100. // infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  13101. // res.Infcode = infocode
  13102. // } else if miConfig.MdtrtareaAdmvs == "360302" {
  13103. //
  13104. // var pp models.PublicParams
  13105. // pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  13106. // pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  13107. // pp.FixmedinsName = miConfig.OrgName
  13108. // pp.FixmedinsCode = miConfig.Code
  13109. // pp.RequestUrl = miConfig.Url
  13110. // pp.Cainfo = miConfig.Cainfo
  13111. // pp.SecretKey = miConfig.SecretKey
  13112. // pp.AccessKey = miConfig.AccessKey
  13113. // pp.OpterName = curRoles.UserName
  13114. // result, _ := service.Jxyb4101(struct4101, pp)
  13115. // var dat map[string]interface{}
  13116. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13117. // fmt.Println(dat)
  13118. // } else {
  13119. // fmt.Println(err)
  13120. // }
  13121. // userJSONBytes, _ := json.Marshal(dat)
  13122. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13123. // utils.ErrorLog("解析失败:%v", err)
  13124. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13125. // return
  13126. // }
  13127. //
  13128. // } else if miConfig.MdtrtareaAdmvs == "430800" {
  13129. // var pp models.PublicParams
  13130. // pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  13131. // pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  13132. // pp.FixmedinsName = miConfig.OrgName
  13133. // pp.FixmedinsCode = miConfig.Code
  13134. // pp.RequestUrl = miConfig.Url
  13135. // pp.Cainfo = miConfig.Cainfo
  13136. // pp.SecretKey = miConfig.SecretKey
  13137. // pp.AccessKey = miConfig.AccessKey
  13138. // pp.OpterName = curRoles.UserName
  13139. // result, _ := service.Hnyb4101(struct4101, pp)
  13140. // var dat map[string]interface{}
  13141. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13142. // fmt.Println(dat)
  13143. // } else {
  13144. // fmt.Println(err)
  13145. // }
  13146. // userJSONBytes, _ := json.Marshal(dat)
  13147. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13148. // utils.ErrorLog("解析失败:%v", err)
  13149. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13150. // return
  13151. // }
  13152. //
  13153. // } else if miConfig.MdtrtareaAdmvs == "150499" {
  13154. // var resOther ResultSeventeenOther
  13155. //
  13156. // var pp models.PublicParams
  13157. // pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  13158. // pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  13159. // pp.FixmedinsName = miConfig.OrgName
  13160. // pp.FixmedinsCode = miConfig.Code
  13161. // pp.RequestUrl = miConfig.Url
  13162. // pp.Cainfo = miConfig.Cainfo
  13163. // pp.SecretKey = miConfig.SecretKey
  13164. // pp.AccessKey = miConfig.AccessKey
  13165. // pp.OpterName = curRoles.UserName
  13166. // client := &http.Client{}
  13167. // var req *http.Request
  13168. // data := make(map[string]interface{})
  13169. // data["struct4101"] = struct4101
  13170. // data["pp"] = pp
  13171. // bytesData, _ := json.Marshal(data)
  13172. // req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/4101", bytes.NewReader(bytesData))
  13173. // resp, _ := client.Do(req)
  13174. // defer resp.Body.Close()
  13175. // body, ioErr := ioutil.ReadAll(resp.Body)
  13176. // if ioErr != nil {
  13177. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13178. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13179. // return
  13180. // }
  13181. // var respJSON map[string]interface{}
  13182. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  13183. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13184. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13185. // return
  13186. // }
  13187. //
  13188. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13189. // userJSONBytes, _ := json.Marshal(respJSON)
  13190. // if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  13191. // utils.ErrorLog("解析失败:%v", err)
  13192. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13193. // return
  13194. // }
  13195. // res.InfRefmsgid = resOther.InfRefmsgid
  13196. // res.Output = resOther.Output
  13197. // res.ErrMsg = resOther.ErrMsg
  13198. // infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  13199. // res.Infcode = infocode
  13200. //
  13201. // } else if miConfig.MdtrtareaAdmvs == "350500" {
  13202. // var pp models.PublicParams
  13203. // pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  13204. // pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  13205. // pp.FixmedinsName = miConfig.OrgName
  13206. // pp.FixmedinsCode = miConfig.Code
  13207. // pp.RequestUrl = miConfig.Url
  13208. // pp.Cainfo = miConfig.Cainfo
  13209. // pp.SecretKey = miConfig.SecretKey
  13210. // pp.AccessKey = miConfig.AccessKey
  13211. // pp.OpterName = curRoles.UserName
  13212. // result, requestLog, errMsgLog := service.Fjyb4101(struct4101, pp)
  13213. // fmt.Println(requestLog)
  13214. // fmt.Println(errMsgLog)
  13215. //
  13216. // saveLog(result, requestLog, "4101a", "上传清单")
  13217. //
  13218. // var dat map[string]interface{}
  13219. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13220. // fmt.Println(dat)
  13221. // } else {
  13222. // fmt.Println(err)
  13223. // }
  13224. // userJSONBytes, _ := json.Marshal(dat)
  13225. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13226. // utils.ErrorLog("解析失败:%v", err)
  13227. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13228. // return
  13229. // }
  13230. //
  13231. // } else {
  13232. //
  13233. // result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId)
  13234. // var dat map[string]interface{}
  13235. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13236. // fmt.Println(dat)
  13237. // } else {
  13238. // fmt.Println(err)
  13239. // }
  13240. // userJSONBytes, _ := json.Marshal(dat)
  13241. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13242. // utils.ErrorLog("解析失败:%v", err)
  13243. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13244. // return
  13245. // }
  13246. // }
  13247. //
  13248. // if res.Infcode != 0 {
  13249. // adminUser := c.GetAdminUserInfo()
  13250. // errlog := &models.HisOrderError{
  13251. // UserOrgId: adminUser.CurrentOrgId,
  13252. // Ctime: time.Now().Unix(),
  13253. // Mtime: time.Now().Unix(),
  13254. // ErrMsg: res.ErrMsg,
  13255. // Status: 1,
  13256. // PatientId: order.ID,
  13257. // Stage: 10265,
  13258. // }
  13259. // service.CreateErrMsgLog(errlog)
  13260. // continue
  13261. // } else {
  13262. // //order.FaPiaoNumber = zero
  13263. // //order.FaPiaoCode = last_order.FaPiaoCode
  13264. // //service.UpdateOrder(order)
  13265. // hisFundSettleListResult := &models.HisFundSettleListResult{
  13266. // Number: res.Output.SetlListId,
  13267. // Status: 1,
  13268. // Ctime: time.Now().Unix(),
  13269. // Mtime: time.Now().Unix(),
  13270. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13271. // IsUpload: 1,
  13272. // OrderId: order.ID,
  13273. // }
  13274. // service.CreateUploadRecord(hisFundSettleListResult)
  13275. // c.ServeSuccessJSON(map[string]interface{}{
  13276. // "msg": "上传成功",
  13277. // "result": hisFundSettleListResult,
  13278. // })
  13279. // continue
  13280. // }
  13281. // }
  13282. //}
  13283. func (c *HisApiController) GetbatchSettleList() {
  13284. //order_id, _ := c.GetInt64("order_id")
  13285. admin_user_id, _ := c.GetInt64("admin_user_id")
  13286. orders, _ := service.GetAllHisOrderTwo10485()
  13287. for _, item := range orders {
  13288. order, _ := service.GetHisOrderByIDTwo(item.ID)
  13289. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  13290. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  13291. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  13292. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  13293. //depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  13294. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  13295. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  13296. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  13297. //last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  13298. //max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  13299. //count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  13300. //fmt.Println(count)
  13301. //var zero string
  13302. //number := count + 1
  13303. //if number >= 1000 {
  13304. // zero = "0000" + strconv.FormatInt(number, 10)
  13305. //} else if number >= 10000 {
  13306. // zero = "000" + strconv.FormatInt(number, 10)
  13307. //} else if number >= 100000 {
  13308. // zero = "00" + strconv.FormatInt(number, 10)
  13309. //} else if number >= 1000000 {
  13310. // zero = "0" + strconv.FormatInt(number, 10)
  13311. //} else {
  13312. // zero = strconv.FormatInt(number, 10)
  13313. //}
  13314. //fmt.Println(zero)
  13315. struct4101 := service.Struct4101{
  13316. PsnNo: order.PsnNo,
  13317. MdtrtId: order.MdtrtId,
  13318. SetlId: order.SetlId,
  13319. PsnName: order.PsnName,
  13320. Gend: order.Gend,
  13321. Brdy: his.Brdy,
  13322. Age: his.Age,
  13323. Naty: order.Naty,
  13324. PatnCertType: "01",
  13325. Certno: order.Certno,
  13326. Prfs: "90",
  13327. ConerName: roles[0].UserName,
  13328. PatnRlts: "99",
  13329. ConerAddr: miConfig.OrgName,
  13330. ConerTel: admin.Mobile,
  13331. HiType: order.Insutype,
  13332. Insuplc: miConfig.InsuplcAdmdvs,
  13333. MaindiagFlag: "1",
  13334. BillCode: order.SetlId,
  13335. BillNo: order.SetlId,
  13336. BizSn: order.Number,
  13337. PsnSelfPay: order.PsnPartAmt,
  13338. PsnOwnPay: order.PsnPartAmt,
  13339. AcctPay: order.AcctPay,
  13340. PsnCashpay: order.PsnCashPay,
  13341. HiPaymtd: "1",
  13342. Hsorg: miConfig.InsuplcAdmdvs,
  13343. HsorgOpter: miConfig.InsuplcAdmdvs,
  13344. MedinsFillPsn: curRoles.UserName,
  13345. MedinsFillDept: miConfig.OrgName,
  13346. IptMedType: "2",
  13347. }
  13348. struct4101.SetlBegnDate = order.SetlTime
  13349. struct4101.SetlEndDate = order.SetlTime
  13350. time_arr := strings.Split(order.SetlTime, " ")
  13351. struct4101.AdmTime = time_arr[0]
  13352. struct4101.AdmEndTime = time_arr[0]
  13353. //var rf []CustomFundPay
  13354. //json.Unmarshal([]byte(order.SetlDetail), &rf)
  13355. //
  13356. //var tempFunPays []service.CustomStruct
  13357. //for _, item := range rf {
  13358. // var tempFunPay service.CustomStruct
  13359. // tempFunPay.FundPayamt = item.FundPayamt
  13360. // tempFunPay.FundPayType = item.FundPayType
  13361. // tempFunPays = append(tempFunPays, tempFunPay)
  13362. //}
  13363. //struct4101.CustomStruct = tempFunPays
  13364. var tempDiaginfos []service.DiaginfoStructTwo
  13365. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  13366. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  13367. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  13368. var config []*models.HisXtDiagnoseConfig
  13369. for _, item := range diagnosis_ids {
  13370. id, _ := strconv.ParseInt(item, 10, 64)
  13371. diagnosisConfig, _ := service.FindDiagnoseById(id)
  13372. config = append(config, &diagnosisConfig)
  13373. }
  13374. for index, item := range config {
  13375. if index == 0 {
  13376. var tempDiaginfo service.DiaginfoStructTwo
  13377. tempDiaginfo.DiagCode = item.CountryCode
  13378. tempDiaginfo.DiagName = item.CountryContentName
  13379. tempDiaginfo.DiagType = "1"
  13380. tempDiaginfo.MaindiagFlag = "1"
  13381. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  13382. } else {
  13383. var tempDiaginfo service.DiaginfoStructTwo
  13384. tempDiaginfo.DiagCode = item.CountryCode
  13385. tempDiaginfo.DiagName = item.CountryContentName
  13386. tempDiaginfo.DiagType = "1"
  13387. tempDiaginfo.MaindiagFlag = "0"
  13388. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  13389. }
  13390. }
  13391. struct4101.Diseinfo = tempDiaginfos
  13392. sickConfigTwo, _ := service.FindSickById(his.SickType)
  13393. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  13394. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  13395. tempOpspdiseinfo2.OprnOprtCode = sickConfigTwo.ContentCode
  13396. tempOpspdiseinfo2.OprnOprtName = sickConfigTwo.CountryContentName
  13397. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  13398. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  13399. var iteminfo service.IteminfoStruct
  13400. var bedCostTotal float64 = 0 //床位总费
  13401. var bedCostSelfTotal float64 = 0 //床位自费
  13402. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  13403. var operationCostTotal float64 = 0 //手术费
  13404. var operationCostSelfTotal float64 = 0 //手术费
  13405. var operationCostPartSelfTotal float64 = 0 //手术费
  13406. var otherCostTotal float64 = 0 //其他费用
  13407. var otherCostSelfTotal float64 = 0 //其他费用
  13408. var otherCostPartSelfTotal float64 = 0 //其他费用
  13409. var materialCostTotal float64 = 0 //材料费
  13410. var materialCostSelfTotal float64 = 0 //材料费
  13411. var materialCostPartSelfTotal float64 = 0 //材料费
  13412. var westernMedicineCostTotal float64 = 0 //西药费
  13413. var westernMedicineCostSelfTotal float64 = 0 //西药费
  13414. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  13415. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  13416. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  13417. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  13418. var checkCostTotal float64 = 0 //检查费
  13419. var checkCostSelfTotal float64 = 0 //检查费
  13420. var checkCostPartSelfTotal float64 = 0 //检查费
  13421. var laboratoryCostTotal float64 = 0 //化验费
  13422. var laboratoryCostSelfTotal float64 = 0 //化验费
  13423. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  13424. var treatCostTotal float64 = 0 //治疗费用
  13425. var treatCostSelfTotal float64 = 0 //治疗费用
  13426. var treatCostPartSelfTotal float64 = 0 //治疗费用
  13427. decimal.DivisionPrecision = 2
  13428. var bed_fulamt_ownpay_amt float64 = 0
  13429. var operation_fulamt_ownpay_amt float64 = 0
  13430. var other_fulamt_ownpay_amt float64 = 0
  13431. var westernMedicine_fulamt_ownpay_amt float64 = 0
  13432. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  13433. var check_fulamt_ownpay_amt float64 = 0
  13434. var material_fulamt_ownpay_amt float64 = 0
  13435. var laboratory_fulamt_ownpay_amt float64 = 0
  13436. var treat_fulamt_ownpay_amt float64 = 0
  13437. var bed_claa_sunmfee float64 = 0
  13438. var bed_clab_amt float64 = 0
  13439. var bed_other_amt float64 = 0
  13440. var operation_claa_sunmfee float64 = 0
  13441. var operation_clab_amt float64 = 0
  13442. var operation_other_amt float64 = 0
  13443. var other_claa_sunmfee float64 = 0
  13444. var other_clab_amt float64 = 0
  13445. var other_other_amt float64 = 0
  13446. var westernMedicine_claa_sunmfee float64 = 0
  13447. var westernMedicine_clab_amt float64 = 0
  13448. var westernMedicine_other_amt float64 = 0
  13449. var chineseTraditional_claa_sunmfee float64 = 0
  13450. var chineseTraditional_clab_amt float64 = 0
  13451. var chineseTraditional_other_amt float64 = 0
  13452. var check_claa_sunmfee float64 = 0
  13453. var check_clab_amt float64 = 0
  13454. var check_other_amt float64 = 0
  13455. var material_claa_sunmfee float64 = 0
  13456. var material_clab_amt float64 = 0
  13457. var material_other_amt float64 = 0
  13458. var laboratory_claa_sunmfee float64 = 0
  13459. var laboratory_clab_amt float64 = 0
  13460. var laboratory_other_amt float64 = 0
  13461. var treat_claa_sunmfee float64 = 0
  13462. var treat_clab_amt float64 = 0
  13463. var treat_other_amt float64 = 0
  13464. for _, item := range order.HisOrderInfo {
  13465. if item.MedChrgitmType == "01" { //床位费
  13466. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13467. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13468. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13469. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  13470. if item.ChrgitmLv == "1" {
  13471. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13472. }
  13473. if item.ChrgitmLv == "2" {
  13474. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13475. }
  13476. if item.ChrgitmLv == "3" {
  13477. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13478. }
  13479. }
  13480. if item.MedChrgitmType == "03" { //检查费
  13481. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13482. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13483. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13484. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  13485. if item.ChrgitmLv == "1" {
  13486. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13487. }
  13488. if item.ChrgitmLv == "2" {
  13489. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13490. }
  13491. if item.ChrgitmLv == "3" {
  13492. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13493. }
  13494. }
  13495. if item.MedChrgitmType == "04" { //化验费
  13496. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13497. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13498. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13499. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  13500. if item.ChrgitmLv == "1" {
  13501. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13502. }
  13503. if item.ChrgitmLv == "2" {
  13504. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13505. }
  13506. if item.ChrgitmLv == "3" {
  13507. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13508. }
  13509. }
  13510. if item.MedChrgitmType == "05" { //治疗费
  13511. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13512. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13513. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13514. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  13515. if item.ChrgitmLv == "1" {
  13516. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13517. }
  13518. if item.ChrgitmLv == "2" {
  13519. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13520. }
  13521. if item.ChrgitmLv == "3" {
  13522. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13523. }
  13524. }
  13525. if item.MedChrgitmType == "06" { //手术费
  13526. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13527. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13528. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13529. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  13530. if item.ChrgitmLv == "1" {
  13531. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13532. }
  13533. if item.ChrgitmLv == "2" {
  13534. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13535. }
  13536. if item.ChrgitmLv == "3" {
  13537. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13538. }
  13539. }
  13540. if item.MedChrgitmType == "08" { //材料费
  13541. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13542. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13543. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13544. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  13545. if item.ChrgitmLv == "1" {
  13546. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13547. }
  13548. if item.ChrgitmLv == "2" {
  13549. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13550. }
  13551. if item.ChrgitmLv == "3" {
  13552. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13553. }
  13554. }
  13555. if item.MedChrgitmType == "09" { //西药费
  13556. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13557. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13558. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13559. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  13560. if item.ChrgitmLv == "1" {
  13561. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13562. }
  13563. if item.ChrgitmLv == "2" {
  13564. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13565. }
  13566. if item.ChrgitmLv == "3" {
  13567. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13568. }
  13569. }
  13570. if item.MedChrgitmType == "11" { //中成费
  13571. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13572. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13573. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13574. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  13575. if item.ChrgitmLv == "1" {
  13576. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13577. }
  13578. if item.ChrgitmLv == "2" {
  13579. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13580. }
  13581. if item.ChrgitmLv == "3" {
  13582. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13583. }
  13584. }
  13585. if item.MedChrgitmType == "14" { //其他费
  13586. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13587. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13588. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13589. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  13590. if item.ChrgitmLv == "1" {
  13591. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13592. }
  13593. if item.ChrgitmLv == "2" {
  13594. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13595. }
  13596. if item.ChrgitmLv == "3" {
  13597. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13598. }
  13599. }
  13600. }
  13601. var iteminfoStructs []service.IteminfoStruct
  13602. if bedCostTotal != 0 {
  13603. iteminfo.MedChrgitm = "01"
  13604. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  13605. iteminfo.Amt = bedCostTotal
  13606. iteminfo.ClaaSumfee = bed_claa_sunmfee
  13607. iteminfo.ClabAmt = bed_clab_amt
  13608. iteminfo.OthAmt = bed_other_amt
  13609. iteminfoStructs = append(iteminfoStructs, iteminfo)
  13610. }
  13611. if checkCostTotal != 0 {
  13612. iteminfo.MedChrgitm = "03"
  13613. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  13614. iteminfo.Amt = checkCostTotal
  13615. iteminfo.ClaaSumfee = check_claa_sunmfee
  13616. iteminfo.ClabAmt = check_clab_amt
  13617. iteminfo.OthAmt = check_other_amt
  13618. iteminfoStructs = append(iteminfoStructs, iteminfo)
  13619. }
  13620. if laboratoryCostTotal != 0 {
  13621. iteminfo.MedChrgitm = "04"
  13622. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  13623. iteminfo.Amt = laboratoryCostTotal
  13624. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  13625. iteminfo.ClabAmt = laboratory_clab_amt
  13626. iteminfo.OthAmt = laboratory_other_amt
  13627. iteminfoStructs = append(iteminfoStructs, iteminfo)
  13628. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  13629. }
  13630. if treatCostTotal != 0 {
  13631. iteminfo.MedChrgitm = "05"
  13632. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  13633. iteminfo.Amt = treatCostTotal
  13634. iteminfo.ClaaSumfee = treat_claa_sunmfee
  13635. iteminfo.ClabAmt = treat_clab_amt
  13636. iteminfo.OthAmt = treat_other_amt
  13637. iteminfoStructs = append(iteminfoStructs, iteminfo)
  13638. //(struct4101.IteminfoStruct, iteminfo)
  13639. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  13640. }
  13641. if operationCostTotal != 0 {
  13642. iteminfo.MedChrgitm = "06"
  13643. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  13644. iteminfo.Amt = operationCostTotal
  13645. iteminfo.ClaaSumfee = operation_claa_sunmfee
  13646. iteminfo.ClabAmt = operation_clab_amt
  13647. iteminfo.OthAmt = operation_other_amt
  13648. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  13649. iteminfoStructs = append(iteminfoStructs, iteminfo)
  13650. }
  13651. if materialCostTotal != 0 {
  13652. iteminfo.MedChrgitm = "08"
  13653. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  13654. iteminfo.Amt = materialCostTotal
  13655. iteminfo.ClaaSumfee = material_claa_sunmfee
  13656. iteminfo.ClabAmt = material_clab_amt
  13657. iteminfo.OthAmt = material_other_amt
  13658. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  13659. iteminfoStructs = append(iteminfoStructs, iteminfo)
  13660. }
  13661. if westernMedicineCostTotal != 0 {
  13662. iteminfo.MedChrgitm = "09"
  13663. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  13664. iteminfo.Amt = westernMedicineCostTotal
  13665. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  13666. iteminfo.ClabAmt = westernMedicine_clab_amt
  13667. iteminfo.OthAmt = westernMedicine_other_amt
  13668. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  13669. iteminfoStructs = append(iteminfoStructs, iteminfo)
  13670. }
  13671. if chineseTraditionalMedicineCostTotal != 0 {
  13672. iteminfo.MedChrgitm = "11"
  13673. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  13674. iteminfo.Amt = westernMedicineCostTotal
  13675. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  13676. iteminfo.ClabAmt = westernMedicine_clab_amt
  13677. iteminfo.OthAmt = westernMedicine_other_amt
  13678. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  13679. iteminfoStructs = append(iteminfoStructs, iteminfo)
  13680. }
  13681. if otherCostTotal != 0 {
  13682. iteminfo.MedChrgitm = "14"
  13683. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  13684. iteminfo.Amt = otherCostTotal
  13685. iteminfo.ClaaSumfee = other_claa_sunmfee
  13686. iteminfo.ClabAmt = other_clab_amt
  13687. iteminfo.OthAmt = other_other_amt
  13688. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  13689. iteminfoStructs = append(iteminfoStructs, iteminfo)
  13690. }
  13691. struct4101.IteminfoStruct = iteminfoStructs
  13692. struct4101.Ntly = "中国"
  13693. struct4101.AdmCaty = "A03.06"
  13694. struct4101.DoctorName = doctor.UserName
  13695. struct4101.DoctorCode = doctor.DoctorNumber
  13696. var res ResultSeventeen
  13697. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  13698. struct4101.BillCode = order.Number
  13699. struct4101.BillNo = order.SetlId
  13700. var resOther ResultSeventeenOther
  13701. var pp models.PublicParams
  13702. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  13703. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  13704. pp.FixmedinsName = miConfig.OrgName
  13705. pp.FixmedinsCode = miConfig.Code
  13706. pp.RequestUrl = miConfig.Url
  13707. pp.Cainfo = miConfig.Cainfo
  13708. pp.SecretKey = miConfig.SecretKey
  13709. pp.AccessKey = miConfig.AccessKey
  13710. pp.OpterName = curRoles.UserName
  13711. client := &http.Client{}
  13712. var req *http.Request
  13713. data := make(map[string]interface{})
  13714. data["struct4101"] = struct4101
  13715. data["pp"] = pp
  13716. bytesData, _ := json.Marshal(data)
  13717. if miConfig.MdtrtareaAdmvs == "320921" {
  13718. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  13719. } else {
  13720. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  13721. }
  13722. resp, _ := client.Do(req)
  13723. defer resp.Body.Close()
  13724. body, ioErr := ioutil.ReadAll(resp.Body)
  13725. if ioErr != nil {
  13726. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13727. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13728. return
  13729. }
  13730. var respJSON map[string]interface{}
  13731. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  13732. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13733. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13734. return
  13735. }
  13736. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  13737. userJSONBytes, _ := json.Marshal(respJSON)
  13738. fmt.Println("log")
  13739. fmt.Println(string(userJSONBytes))
  13740. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  13741. utils.ErrorLog("解析失败:%v", err)
  13742. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13743. return
  13744. }
  13745. res.InfRefmsgid = resOther.InfRefmsgid
  13746. res.Output = resOther.Output
  13747. res.ErrMsg = resOther.ErrMsg
  13748. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  13749. res.Infcode = infocode
  13750. } else if miConfig.MdtrtareaAdmvs == "360302" {
  13751. var pp models.PublicParams
  13752. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  13753. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  13754. pp.FixmedinsName = miConfig.OrgName
  13755. pp.FixmedinsCode = miConfig.Code
  13756. pp.RequestUrl = miConfig.Url
  13757. pp.Cainfo = miConfig.Cainfo
  13758. pp.SecretKey = miConfig.SecretKey
  13759. pp.AccessKey = miConfig.AccessKey
  13760. pp.OpterName = curRoles.UserName
  13761. result, _ := service.Jxyb4101(struct4101, pp)
  13762. var dat map[string]interface{}
  13763. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13764. fmt.Println(dat)
  13765. } else {
  13766. fmt.Println(err)
  13767. }
  13768. userJSONBytes, _ := json.Marshal(dat)
  13769. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13770. utils.ErrorLog("解析失败:%v", err)
  13771. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13772. return
  13773. }
  13774. } else if miConfig.MdtrtareaAdmvs == "430800" {
  13775. var pp models.PublicParams
  13776. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  13777. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  13778. pp.FixmedinsName = miConfig.OrgName
  13779. pp.FixmedinsCode = miConfig.Code
  13780. pp.RequestUrl = miConfig.Url
  13781. pp.Cainfo = miConfig.Cainfo
  13782. pp.SecretKey = miConfig.SecretKey
  13783. pp.AccessKey = miConfig.AccessKey
  13784. pp.OpterName = curRoles.UserName
  13785. result, _ := service.Hnyb4101(struct4101, pp)
  13786. var dat map[string]interface{}
  13787. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13788. fmt.Println(dat)
  13789. } else {
  13790. fmt.Println(err)
  13791. }
  13792. userJSONBytes, _ := json.Marshal(dat)
  13793. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13794. utils.ErrorLog("解析失败:%v", err)
  13795. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13796. return
  13797. }
  13798. } else if miConfig.MdtrtareaAdmvs == "150499" {
  13799. var resOther ResultSeventeenOther
  13800. var pp models.PublicParams
  13801. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  13802. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  13803. pp.FixmedinsName = miConfig.OrgName
  13804. pp.FixmedinsCode = miConfig.Code
  13805. pp.RequestUrl = miConfig.Url
  13806. pp.Cainfo = miConfig.Cainfo
  13807. pp.SecretKey = miConfig.SecretKey
  13808. pp.AccessKey = miConfig.AccessKey
  13809. pp.OpterName = curRoles.UserName
  13810. client := &http.Client{}
  13811. var req *http.Request
  13812. data := make(map[string]interface{})
  13813. data["struct4101"] = struct4101
  13814. data["pp"] = pp
  13815. bytesData, _ := json.Marshal(data)
  13816. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/4101", bytes.NewReader(bytesData))
  13817. resp, _ := client.Do(req)
  13818. defer resp.Body.Close()
  13819. body, ioErr := ioutil.ReadAll(resp.Body)
  13820. if ioErr != nil {
  13821. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13822. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13823. return
  13824. }
  13825. var respJSON map[string]interface{}
  13826. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  13827. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13828. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13829. return
  13830. }
  13831. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13832. userJSONBytes, _ := json.Marshal(respJSON)
  13833. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  13834. utils.ErrorLog("解析失败:%v", err)
  13835. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13836. return
  13837. }
  13838. res.InfRefmsgid = resOther.InfRefmsgid
  13839. res.Output = resOther.Output
  13840. res.ErrMsg = resOther.ErrMsg
  13841. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  13842. res.Infcode = infocode
  13843. } else if miConfig.MdtrtareaAdmvs == "350500" {
  13844. var pp models.PublicParams
  13845. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  13846. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  13847. pp.FixmedinsName = miConfig.OrgName
  13848. pp.FixmedinsCode = miConfig.Code
  13849. pp.RequestUrl = miConfig.Url
  13850. pp.Cainfo = miConfig.Cainfo
  13851. pp.SecretKey = miConfig.SecretKey
  13852. pp.AccessKey = miConfig.AccessKey
  13853. pp.OpterName = curRoles.UserName
  13854. result, requestLog, errMsgLog := service.Fjyb4101(struct4101, pp)
  13855. fmt.Println(requestLog)
  13856. fmt.Println(errMsgLog)
  13857. saveLog(result, requestLog, "4101a", "上传清单")
  13858. var dat map[string]interface{}
  13859. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13860. fmt.Println(dat)
  13861. } else {
  13862. fmt.Println(err)
  13863. }
  13864. userJSONBytes, _ := json.Marshal(dat)
  13865. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13866. utils.ErrorLog("解析失败:%v", err)
  13867. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13868. return
  13869. }
  13870. } else if miConfig.MdtrtareaAdmvs == "441799" {
  13871. var pp models.PublicParams
  13872. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  13873. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  13874. pp.FixmedinsName = miConfig.OrgName
  13875. pp.FixmedinsCode = miConfig.Code
  13876. pp.RequestUrl = miConfig.Url
  13877. pp.Cainfo = miConfig.Cainfo
  13878. pp.SecretKey = miConfig.SecretKey
  13879. pp.AccessKey = miConfig.AccessKey
  13880. pp.OpterName = curRoles.UserName
  13881. client := &http.Client{}
  13882. var req *http.Request
  13883. data := make(map[string]interface{})
  13884. data["struct4101"] = struct4101
  13885. data["pp"] = pp
  13886. bytesData, _ := json.Marshal(data)
  13887. req, _ = http.NewRequest("POST", miConfig.Url+"gdyb/4101", bytes.NewReader(bytesData))
  13888. resp, _ := client.Do(req)
  13889. defer resp.Body.Close()
  13890. body, ioErr := ioutil.ReadAll(resp.Body)
  13891. if ioErr != nil {
  13892. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13893. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13894. return
  13895. }
  13896. var respJSON map[string]interface{}
  13897. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  13898. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13899. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13900. return
  13901. }
  13902. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13903. userJSONBytes, _ := json.Marshal(respJSON)
  13904. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13905. utils.ErrorLog("解析失败:%v", err)
  13906. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13907. return
  13908. }
  13909. } else {
  13910. result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId, admin_user_id)
  13911. var dat map[string]interface{}
  13912. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13913. fmt.Println(dat)
  13914. } else {
  13915. fmt.Println(err)
  13916. }
  13917. userJSONBytes, _ := json.Marshal(dat)
  13918. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13919. utils.ErrorLog("解析失败:%v", err)
  13920. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13921. return
  13922. }
  13923. }
  13924. if res.Infcode != 0 {
  13925. errlog := &models.HisOrderError{
  13926. UserOrgId: order.UserOrgId,
  13927. Ctime: time.Now().Unix(),
  13928. Mtime: time.Now().Unix(),
  13929. ErrMsg: res.ErrMsg + "解析失败",
  13930. Status: 1,
  13931. PatientId: order.ID,
  13932. Stage: 10485,
  13933. }
  13934. service.CreateErrMsgLog(errlog)
  13935. continue
  13936. //c.ServeSuccessJSON(map[string]interface{}{
  13937. // "failed_code": -10,
  13938. // "msg": res.ErrMsg,
  13939. //})
  13940. } else {
  13941. //order.FaPiaoNumber = zero
  13942. //order.FaPiaoCode = last_order.FaPiaoCode
  13943. //service.UpdateOrder(order)
  13944. hisFundSettleListResult := &models.HisFundSettleListResult{
  13945. Number: res.Output.SetlListId,
  13946. Status: 1,
  13947. Ctime: time.Now().Unix(),
  13948. Mtime: time.Now().Unix(),
  13949. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13950. IsUpload: 1,
  13951. OrderId: order.ID,
  13952. }
  13953. service.CreateUploadRecord(hisFundSettleListResult)
  13954. continue
  13955. }
  13956. }
  13957. }
  13958. func (c *HisApiController) GetSettleList() {
  13959. order_id, _ := c.GetInt64("order_id")
  13960. admin_user_id, _ := c.GetInt64("admin_user_id")
  13961. order, _ := service.GetHisOrderByIDTwo(order_id)
  13962. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  13963. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  13964. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  13965. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  13966. //depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  13967. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  13968. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  13969. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  13970. if order.ID == 0 {
  13971. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  13972. return
  13973. }
  13974. //last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  13975. //max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  13976. //count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  13977. //fmt.Println(count)
  13978. //var zero string
  13979. //number := count + 1
  13980. //if number >= 1000 {
  13981. // zero = "0000" + strconv.FormatInt(number, 10)
  13982. //} else if number >= 10000 {
  13983. // zero = "000" + strconv.FormatInt(number, 10)
  13984. //} else if number >= 100000 {
  13985. // zero = "00" + strconv.FormatInt(number, 10)
  13986. //} else if number >= 1000000 {
  13987. // zero = "0" + strconv.FormatInt(number, 10)
  13988. //} else {
  13989. // zero = strconv.FormatInt(number, 10)
  13990. //}
  13991. //fmt.Println(zero)
  13992. struct4101 := service.Struct4101{
  13993. PsnNo: order.PsnNo,
  13994. MdtrtId: order.MdtrtId,
  13995. SetlId: order.SetlId,
  13996. PsnName: order.PsnName,
  13997. Gend: order.Gend,
  13998. Brdy: his.Brdy,
  13999. Age: his.Age,
  14000. Naty: order.Naty,
  14001. PatnCertType: "01",
  14002. Certno: order.Certno,
  14003. Prfs: "90",
  14004. ConerName: roles[0].UserName,
  14005. PatnRlts: "99",
  14006. ConerAddr: miConfig.OrgName,
  14007. ConerTel: admin.Mobile,
  14008. HiType: order.Insutype,
  14009. Insuplc: miConfig.InsuplcAdmdvs,
  14010. MaindiagFlag: "1",
  14011. BillCode: order.SetlId,
  14012. BillNo: order.SetlId,
  14013. BizSn: order.Number,
  14014. PsnSelfPay: order.PsnPartAmt,
  14015. PsnOwnPay: order.PsnPartAmt,
  14016. AcctPay: order.AcctPay,
  14017. PsnCashpay: order.PsnCashPay,
  14018. HiPaymtd: "1",
  14019. Hsorg: miConfig.InsuplcAdmdvs,
  14020. HsorgOpter: miConfig.InsuplcAdmdvs,
  14021. MedinsFillPsn: curRoles.UserName,
  14022. MedinsFillDept: miConfig.OrgName,
  14023. IptMedType: "2",
  14024. }
  14025. struct4101.SetlBegnDate = order.SetlTime
  14026. struct4101.SetlEndDate = order.SetlTime
  14027. time_arr := strings.Split(order.SetlTime, " ")
  14028. struct4101.AdmTime = time_arr[0]
  14029. struct4101.AdmEndTime = time_arr[0]
  14030. //
  14031. //var rf []CustomFundPay
  14032. //json.Unmarshal([]byte(order.SetlDetail), &rf)
  14033. //
  14034. //var tempFunPays []service.CustomStruct
  14035. //for _, item := range rf {
  14036. // var tempFunPay service.CustomStruct
  14037. // tempFunPay.FundPayamt = item.FundPayamt
  14038. // tempFunPay.FundPayType = item.FundPayType
  14039. // tempFunPays = append(tempFunPays, tempFunPay)
  14040. //}
  14041. //struct4101.CustomStruct = tempFunPays
  14042. var tempDiaginfos []service.DiaginfoStructTwo
  14043. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  14044. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  14045. diagnosis_ids := strings.Split(order.Diagnosis, ",")
  14046. var config []*models.HisXtDiagnoseConfig
  14047. for _, item := range diagnosis_ids {
  14048. id, _ := strconv.ParseInt(item, 10, 64)
  14049. diagnosisConfig, _ := service.FindDiagnoseById(id)
  14050. config = append(config, &diagnosisConfig)
  14051. }
  14052. if miConfig.Code == "H15049901371" {
  14053. //for _, item := range config {
  14054. // if item.ID == 138 {
  14055. diagnosisConfig, _ := service.FindDiagnoseById(138)
  14056. var tempDiaginfo service.DiaginfoStructTwo
  14057. tempDiaginfo.DiagCode = diagnosisConfig.CountryCode
  14058. tempDiaginfo.DiagName = diagnosisConfig.CountryContentName
  14059. tempDiaginfo.DiagType = "1"
  14060. tempDiaginfo.MaindiagFlag = "1"
  14061. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  14062. //}
  14063. //}
  14064. for _, item := range config {
  14065. if item.ID != 138 {
  14066. var tempDiaginfo service.DiaginfoStructTwo
  14067. tempDiaginfo.DiagCode = item.CountryCode
  14068. tempDiaginfo.DiagName = item.CountryContentName
  14069. tempDiaginfo.DiagType = "1"
  14070. tempDiaginfo.MaindiagFlag = "0"
  14071. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  14072. }
  14073. }
  14074. } else {
  14075. for index, item := range config {
  14076. if index == 0 {
  14077. var tempDiaginfo service.DiaginfoStructTwo
  14078. tempDiaginfo.DiagCode = item.CountryCode
  14079. tempDiaginfo.DiagName = item.CountryContentName
  14080. tempDiaginfo.DiagType = "1"
  14081. tempDiaginfo.MaindiagFlag = "1"
  14082. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  14083. } else {
  14084. var tempDiaginfo service.DiaginfoStructTwo
  14085. tempDiaginfo.DiagCode = item.CountryCode
  14086. tempDiaginfo.DiagName = item.CountryContentName
  14087. tempDiaginfo.DiagType = "1"
  14088. tempDiaginfo.MaindiagFlag = "0"
  14089. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  14090. }
  14091. }
  14092. }
  14093. struct4101.Diseinfo = tempDiaginfos
  14094. sickConfigTwo, _ := service.FindSickById(his.SickType)
  14095. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  14096. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  14097. tempOpspdiseinfo2.OprnOprtCode = sickConfigTwo.ContentCode
  14098. tempOpspdiseinfo2.OprnOprtName = sickConfigTwo.CountryContentName
  14099. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  14100. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  14101. var iteminfo service.IteminfoStruct
  14102. var bedCostTotal float64 = 0 //床位总费
  14103. var bedCostSelfTotal float64 = 0 //床位自费
  14104. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  14105. var operationCostTotal float64 = 0 //手术费
  14106. var operationCostSelfTotal float64 = 0 //手术费
  14107. var operationCostPartSelfTotal float64 = 0 //手术费
  14108. var otherCostTotal float64 = 0 //其他费用
  14109. var otherCostSelfTotal float64 = 0 //其他费用
  14110. var otherCostPartSelfTotal float64 = 0 //其他费用
  14111. var materialCostTotal float64 = 0 //材料费
  14112. var materialCostSelfTotal float64 = 0 //材料费
  14113. var materialCostPartSelfTotal float64 = 0 //材料费
  14114. var westernMedicineCostTotal float64 = 0 //西药费
  14115. var westernMedicineCostSelfTotal float64 = 0 //西药费
  14116. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  14117. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  14118. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  14119. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  14120. var checkCostTotal float64 = 0 //检查费
  14121. var checkCostSelfTotal float64 = 0 //检查费
  14122. var checkCostPartSelfTotal float64 = 0 //检查费
  14123. var laboratoryCostTotal float64 = 0 //化验费
  14124. var laboratoryCostSelfTotal float64 = 0 //化验费
  14125. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  14126. var treatCostTotal float64 = 0 //治疗费用
  14127. var treatCostSelfTotal float64 = 0 //治疗费用
  14128. var treatCostPartSelfTotal float64 = 0 //治疗费用
  14129. decimal.DivisionPrecision = 2
  14130. var bed_fulamt_ownpay_amt float64 = 0
  14131. var operation_fulamt_ownpay_amt float64 = 0
  14132. var other_fulamt_ownpay_amt float64 = 0
  14133. var westernMedicine_fulamt_ownpay_amt float64 = 0
  14134. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  14135. var check_fulamt_ownpay_amt float64 = 0
  14136. var material_fulamt_ownpay_amt float64 = 0
  14137. var laboratory_fulamt_ownpay_amt float64 = 0
  14138. var treat_fulamt_ownpay_amt float64 = 0
  14139. var bed_claa_sunmfee float64 = 0
  14140. var bed_clab_amt float64 = 0
  14141. var bed_other_amt float64 = 0
  14142. var operation_claa_sunmfee float64 = 0
  14143. var operation_clab_amt float64 = 0
  14144. var operation_other_amt float64 = 0
  14145. var other_claa_sunmfee float64 = 0
  14146. var other_clab_amt float64 = 0
  14147. var other_other_amt float64 = 0
  14148. var westernMedicine_claa_sunmfee float64 = 0
  14149. var westernMedicine_clab_amt float64 = 0
  14150. var westernMedicine_other_amt float64 = 0
  14151. var chineseTraditional_claa_sunmfee float64 = 0
  14152. var chineseTraditional_clab_amt float64 = 0
  14153. var chineseTraditional_other_amt float64 = 0
  14154. var check_claa_sunmfee float64 = 0
  14155. var check_clab_amt float64 = 0
  14156. var check_other_amt float64 = 0
  14157. var material_claa_sunmfee float64 = 0
  14158. var material_clab_amt float64 = 0
  14159. var material_other_amt float64 = 0
  14160. var laboratory_claa_sunmfee float64 = 0
  14161. var laboratory_clab_amt float64 = 0
  14162. var laboratory_other_amt float64 = 0
  14163. var treat_claa_sunmfee float64 = 0
  14164. var treat_clab_amt float64 = 0
  14165. var treat_other_amt float64 = 0
  14166. for _, item := range order.HisOrderInfo {
  14167. if item.MedChrgitmType == "01" { //床位费
  14168. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14169. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14170. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14171. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14172. if item.ChrgitmLv == "1" {
  14173. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14174. }
  14175. if item.ChrgitmLv == "2" {
  14176. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14177. }
  14178. if item.ChrgitmLv == "3" {
  14179. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14180. }
  14181. }
  14182. if item.MedChrgitmType == "03" { //检查费
  14183. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14184. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14185. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14186. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14187. if item.ChrgitmLv == "1" {
  14188. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14189. }
  14190. if item.ChrgitmLv == "2" {
  14191. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14192. }
  14193. if item.ChrgitmLv == "3" {
  14194. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14195. }
  14196. }
  14197. if item.MedChrgitmType == "04" { //化验费
  14198. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14199. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14200. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14201. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14202. if item.ChrgitmLv == "1" {
  14203. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14204. }
  14205. if item.ChrgitmLv == "2" {
  14206. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14207. }
  14208. if item.ChrgitmLv == "3" {
  14209. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14210. }
  14211. }
  14212. if item.MedChrgitmType == "05" { //治疗费
  14213. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14214. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14215. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14216. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14217. if item.ChrgitmLv == "1" {
  14218. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14219. }
  14220. if item.ChrgitmLv == "2" {
  14221. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14222. }
  14223. if item.ChrgitmLv == "3" {
  14224. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14225. }
  14226. }
  14227. if item.MedChrgitmType == "06" { //手术费
  14228. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14229. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14230. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14231. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14232. if item.ChrgitmLv == "1" {
  14233. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14234. }
  14235. if item.ChrgitmLv == "2" {
  14236. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14237. }
  14238. if item.ChrgitmLv == "3" {
  14239. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14240. }
  14241. }
  14242. if item.MedChrgitmType == "08" { //材料费
  14243. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14244. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14245. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14246. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14247. if item.ChrgitmLv == "1" {
  14248. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14249. }
  14250. if item.ChrgitmLv == "2" {
  14251. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14252. }
  14253. if item.ChrgitmLv == "3" {
  14254. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14255. }
  14256. }
  14257. if item.MedChrgitmType == "09" { //西药费
  14258. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14259. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14260. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14261. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14262. if item.ChrgitmLv == "1" {
  14263. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14264. }
  14265. if item.ChrgitmLv == "2" {
  14266. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14267. }
  14268. if item.ChrgitmLv == "3" {
  14269. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14270. }
  14271. }
  14272. if item.MedChrgitmType == "11" { //中成费
  14273. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14274. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14275. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14276. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14277. if item.ChrgitmLv == "1" {
  14278. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14279. }
  14280. if item.ChrgitmLv == "2" {
  14281. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14282. }
  14283. if item.ChrgitmLv == "3" {
  14284. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14285. }
  14286. }
  14287. if item.MedChrgitmType == "14" { //其他费
  14288. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14289. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14290. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14291. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14292. if item.ChrgitmLv == "1" {
  14293. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14294. }
  14295. if item.ChrgitmLv == "2" {
  14296. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14297. }
  14298. if item.ChrgitmLv == "3" {
  14299. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14300. }
  14301. }
  14302. }
  14303. var iteminfoStructs []service.IteminfoStruct
  14304. if bedCostTotal != 0 {
  14305. iteminfo.MedChrgitm = "01"
  14306. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  14307. iteminfo.Amt = bedCostTotal
  14308. iteminfo.ClaaSumfee = bed_claa_sunmfee
  14309. iteminfo.ClabAmt = bed_clab_amt
  14310. iteminfo.OthAmt = bed_other_amt
  14311. iteminfoStructs = append(iteminfoStructs, iteminfo)
  14312. }
  14313. if checkCostTotal != 0 {
  14314. iteminfo.MedChrgitm = "03"
  14315. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  14316. iteminfo.Amt = checkCostTotal
  14317. iteminfo.ClaaSumfee = check_claa_sunmfee
  14318. iteminfo.ClabAmt = check_clab_amt
  14319. iteminfo.OthAmt = check_other_amt
  14320. iteminfoStructs = append(iteminfoStructs, iteminfo)
  14321. }
  14322. if laboratoryCostTotal != 0 {
  14323. iteminfo.MedChrgitm = "04"
  14324. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  14325. iteminfo.Amt = laboratoryCostTotal
  14326. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  14327. iteminfo.ClabAmt = laboratory_clab_amt
  14328. iteminfo.OthAmt = laboratory_other_amt
  14329. iteminfoStructs = append(iteminfoStructs, iteminfo)
  14330. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  14331. }
  14332. if treatCostTotal != 0 {
  14333. iteminfo.MedChrgitm = "05"
  14334. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  14335. iteminfo.Amt = treatCostTotal
  14336. iteminfo.ClaaSumfee = treat_claa_sunmfee
  14337. iteminfo.ClabAmt = treat_clab_amt
  14338. iteminfo.OthAmt = treat_other_amt
  14339. iteminfoStructs = append(iteminfoStructs, iteminfo)
  14340. //(struct4101.IteminfoStruct, iteminfo)
  14341. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  14342. }
  14343. if operationCostTotal != 0 {
  14344. iteminfo.MedChrgitm = "06"
  14345. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  14346. iteminfo.Amt = operationCostTotal
  14347. iteminfo.ClaaSumfee = operation_claa_sunmfee
  14348. iteminfo.ClabAmt = operation_clab_amt
  14349. iteminfo.OthAmt = operation_other_amt
  14350. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  14351. iteminfoStructs = append(iteminfoStructs, iteminfo)
  14352. }
  14353. if materialCostTotal != 0 {
  14354. iteminfo.MedChrgitm = "08"
  14355. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  14356. iteminfo.Amt = materialCostTotal
  14357. iteminfo.ClaaSumfee = material_claa_sunmfee
  14358. iteminfo.ClabAmt = material_clab_amt
  14359. iteminfo.OthAmt = material_other_amt
  14360. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  14361. iteminfoStructs = append(iteminfoStructs, iteminfo)
  14362. }
  14363. if westernMedicineCostTotal != 0 {
  14364. iteminfo.MedChrgitm = "09"
  14365. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  14366. iteminfo.Amt = westernMedicineCostTotal
  14367. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  14368. iteminfo.ClabAmt = westernMedicine_clab_amt
  14369. iteminfo.OthAmt = westernMedicine_other_amt
  14370. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  14371. iteminfoStructs = append(iteminfoStructs, iteminfo)
  14372. }
  14373. if chineseTraditionalMedicineCostTotal != 0 {
  14374. iteminfo.MedChrgitm = "11"
  14375. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  14376. iteminfo.Amt = westernMedicineCostTotal
  14377. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  14378. iteminfo.ClabAmt = westernMedicine_clab_amt
  14379. iteminfo.OthAmt = westernMedicine_other_amt
  14380. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  14381. iteminfoStructs = append(iteminfoStructs, iteminfo)
  14382. }
  14383. if otherCostTotal != 0 {
  14384. iteminfo.MedChrgitm = "14"
  14385. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  14386. iteminfo.Amt = otherCostTotal
  14387. iteminfo.ClaaSumfee = other_claa_sunmfee
  14388. iteminfo.ClabAmt = other_clab_amt
  14389. iteminfo.OthAmt = other_other_amt
  14390. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  14391. iteminfoStructs = append(iteminfoStructs, iteminfo)
  14392. }
  14393. struct4101.IteminfoStruct = iteminfoStructs
  14394. struct4101.Ntly = "中国"
  14395. struct4101.AdmCaty = "A03.06"
  14396. struct4101.DoctorName = doctor.UserName
  14397. struct4101.DoctorCode = doctor.DoctorNumber
  14398. var res ResultSeventeen
  14399. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  14400. struct4101.BillCode = order.Number
  14401. struct4101.BillNo = order.SetlId
  14402. var resOther ResultSeventeenOther
  14403. var pp models.PublicParams
  14404. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  14405. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  14406. pp.FixmedinsName = miConfig.OrgName
  14407. pp.FixmedinsCode = miConfig.Code
  14408. pp.RequestUrl = miConfig.Url
  14409. pp.Cainfo = miConfig.Cainfo
  14410. pp.SecretKey = miConfig.SecretKey
  14411. pp.AccessKey = miConfig.AccessKey
  14412. pp.OpterName = curRoles.UserName
  14413. client := &http.Client{}
  14414. var req *http.Request
  14415. data := make(map[string]interface{})
  14416. data["struct4101"] = struct4101
  14417. data["pp"] = pp
  14418. bytesData, _ := json.Marshal(data)
  14419. if miConfig.MdtrtareaAdmvs == "320921" {
  14420. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  14421. } else {
  14422. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  14423. }
  14424. resp, _ := client.Do(req)
  14425. defer resp.Body.Close()
  14426. body, ioErr := ioutil.ReadAll(resp.Body)
  14427. if ioErr != nil {
  14428. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14429. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14430. return
  14431. }
  14432. var respJSON map[string]interface{}
  14433. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  14434. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14435. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14436. return
  14437. }
  14438. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  14439. userJSONBytes, _ := json.Marshal(respJSON)
  14440. fmt.Println("log")
  14441. fmt.Println(string(userJSONBytes))
  14442. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  14443. utils.ErrorLog("解析失败:%v", err)
  14444. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14445. return
  14446. }
  14447. res.InfRefmsgid = resOther.InfRefmsgid
  14448. res.Output = resOther.Output
  14449. res.ErrMsg = resOther.ErrMsg
  14450. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  14451. res.Infcode = infocode
  14452. } else if miConfig.MdtrtareaAdmvs == "360302" {
  14453. var pp models.PublicParams
  14454. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  14455. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  14456. pp.FixmedinsName = miConfig.OrgName
  14457. pp.FixmedinsCode = miConfig.Code
  14458. pp.RequestUrl = miConfig.Url
  14459. pp.Cainfo = miConfig.Cainfo
  14460. pp.SecretKey = miConfig.SecretKey
  14461. pp.AccessKey = miConfig.AccessKey
  14462. pp.OpterName = curRoles.UserName
  14463. result, _ := service.Jxyb4101(struct4101, pp)
  14464. var dat map[string]interface{}
  14465. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  14466. fmt.Println(dat)
  14467. } else {
  14468. fmt.Println(err)
  14469. }
  14470. userJSONBytes, _ := json.Marshal(dat)
  14471. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14472. utils.ErrorLog("解析失败:%v", err)
  14473. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14474. return
  14475. }
  14476. } else if miConfig.MdtrtareaAdmvs == "430800" {
  14477. var pp models.PublicParams
  14478. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  14479. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  14480. pp.FixmedinsName = miConfig.OrgName
  14481. pp.FixmedinsCode = miConfig.Code
  14482. pp.RequestUrl = miConfig.Url
  14483. pp.Cainfo = miConfig.Cainfo
  14484. pp.SecretKey = miConfig.SecretKey
  14485. pp.AccessKey = miConfig.AccessKey
  14486. pp.OpterName = curRoles.UserName
  14487. result, _ := service.Hnyb4101(struct4101, pp)
  14488. var dat map[string]interface{}
  14489. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  14490. fmt.Println(dat)
  14491. } else {
  14492. fmt.Println(err)
  14493. }
  14494. userJSONBytes, _ := json.Marshal(dat)
  14495. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14496. utils.ErrorLog("解析失败:%v", err)
  14497. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14498. return
  14499. }
  14500. } else if miConfig.MdtrtareaAdmvs == "150499" {
  14501. var resOther ResultSeventeenOther
  14502. var pp models.PublicParams
  14503. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  14504. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  14505. pp.FixmedinsName = miConfig.OrgName
  14506. pp.FixmedinsCode = miConfig.Code
  14507. pp.RequestUrl = miConfig.Url
  14508. pp.Cainfo = miConfig.Cainfo
  14509. pp.SecretKey = miConfig.SecretKey
  14510. pp.AccessKey = miConfig.AccessKey
  14511. pp.OpterName = curRoles.UserName
  14512. client := &http.Client{}
  14513. var req *http.Request
  14514. data := make(map[string]interface{})
  14515. data["struct4101"] = struct4101
  14516. data["pp"] = pp
  14517. bytesData, _ := json.Marshal(data)
  14518. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/4101", bytes.NewReader(bytesData))
  14519. resp, _ := client.Do(req)
  14520. defer resp.Body.Close()
  14521. body, ioErr := ioutil.ReadAll(resp.Body)
  14522. if ioErr != nil {
  14523. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14524. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14525. return
  14526. }
  14527. var respJSON map[string]interface{}
  14528. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  14529. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14530. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14531. return
  14532. }
  14533. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  14534. userJSONBytes, _ := json.Marshal(respJSON)
  14535. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  14536. utils.ErrorLog("解析失败:%v", err)
  14537. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14538. return
  14539. }
  14540. res.InfRefmsgid = resOther.InfRefmsgid
  14541. res.Output = resOther.Output
  14542. res.ErrMsg = resOther.ErrMsg
  14543. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  14544. res.Infcode = infocode
  14545. } else if miConfig.MdtrtareaAdmvs == "350500" {
  14546. var pp models.PublicParams
  14547. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  14548. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  14549. pp.FixmedinsName = miConfig.OrgName
  14550. pp.FixmedinsCode = miConfig.Code
  14551. pp.RequestUrl = miConfig.Url
  14552. pp.Cainfo = miConfig.Cainfo
  14553. pp.SecretKey = miConfig.SecretKey
  14554. pp.AccessKey = miConfig.AccessKey
  14555. pp.OpterName = curRoles.UserName
  14556. result, requestLog, errMsgLog := service.Fjyb4101(struct4101, pp)
  14557. fmt.Println(requestLog)
  14558. fmt.Println(errMsgLog)
  14559. saveLog(result, requestLog, "4101a", "上传清单")
  14560. var dat map[string]interface{}
  14561. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  14562. fmt.Println(dat)
  14563. } else {
  14564. fmt.Println(err)
  14565. }
  14566. userJSONBytes, _ := json.Marshal(dat)
  14567. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14568. utils.ErrorLog("解析失败:%v", err)
  14569. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14570. return
  14571. }
  14572. } else if miConfig.MdtrtareaAdmvs == "441799" {
  14573. var pp models.PublicParams
  14574. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  14575. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  14576. pp.FixmedinsName = miConfig.OrgName
  14577. pp.FixmedinsCode = miConfig.Code
  14578. pp.RequestUrl = miConfig.Url
  14579. pp.Cainfo = miConfig.Cainfo
  14580. pp.SecretKey = miConfig.SecretKey
  14581. pp.AccessKey = miConfig.AccessKey
  14582. pp.OpterName = curRoles.UserName
  14583. client := &http.Client{}
  14584. var req *http.Request
  14585. data := make(map[string]interface{})
  14586. data["struct4101"] = struct4101
  14587. data["pp"] = pp
  14588. bytesData, _ := json.Marshal(data)
  14589. req, _ = http.NewRequest("POST", miConfig.Url+"gdyb/4101", bytes.NewReader(bytesData))
  14590. resp, _ := client.Do(req)
  14591. defer resp.Body.Close()
  14592. body, ioErr := ioutil.ReadAll(resp.Body)
  14593. if ioErr != nil {
  14594. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14595. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14596. return
  14597. }
  14598. var respJSON map[string]interface{}
  14599. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  14600. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14601. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14602. return
  14603. }
  14604. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  14605. userJSONBytes, _ := json.Marshal(respJSON)
  14606. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14607. utils.ErrorLog("解析失败:%v", err)
  14608. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14609. return
  14610. }
  14611. } else {
  14612. result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId, admin_user_id)
  14613. var dat map[string]interface{}
  14614. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  14615. fmt.Println(dat)
  14616. } else {
  14617. fmt.Println(err)
  14618. }
  14619. userJSONBytes, _ := json.Marshal(dat)
  14620. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14621. utils.ErrorLog("解析失败:%v", err)
  14622. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14623. return
  14624. }
  14625. }
  14626. if res.Infcode != 0 {
  14627. c.ServeSuccessJSON(map[string]interface{}{
  14628. "failed_code": -10,
  14629. "msg": res.ErrMsg,
  14630. })
  14631. return
  14632. } else {
  14633. //order.FaPiaoNumber = zero
  14634. //order.FaPiaoCode = last_order.FaPiaoCode
  14635. //service.UpdateOrder(order)
  14636. hisFundSettleListResult := &models.HisFundSettleListResult{
  14637. Number: res.Output.SetlListId,
  14638. Status: 1,
  14639. Ctime: time.Now().Unix(),
  14640. Mtime: time.Now().Unix(),
  14641. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14642. IsUpload: 1,
  14643. OrderId: order_id,
  14644. }
  14645. service.CreateUploadRecord(hisFundSettleListResult)
  14646. c.ServeSuccessJSON(map[string]interface{}{
  14647. "msg": "上传成功",
  14648. "result": hisFundSettleListResult,
  14649. })
  14650. return
  14651. }
  14652. }
  14653. func (c *HisApiController) GetSettleListHospital() {
  14654. order_id, _ := c.GetInt64("order_id")
  14655. admin_user_id, _ := c.GetInt64("admin_user_id")
  14656. order, _ := service.GetHisOrderByIDTwo(order_id)
  14657. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  14658. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  14659. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  14660. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  14661. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  14662. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  14663. if order.ID == 0 {
  14664. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  14665. return
  14666. }
  14667. last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  14668. max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  14669. count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  14670. fmt.Println(count)
  14671. var zero string
  14672. number := count + 1
  14673. if number >= 1000 {
  14674. zero = "0000" + strconv.FormatInt(number, 10)
  14675. } else if number >= 10000 {
  14676. zero = "000" + strconv.FormatInt(number, 10)
  14677. } else if number >= 100000 {
  14678. zero = "00" + strconv.FormatInt(number, 10)
  14679. } else if number >= 1000000 {
  14680. zero = "0" + strconv.FormatInt(number, 10)
  14681. } else {
  14682. zero = strconv.FormatInt(number, 10)
  14683. }
  14684. fmt.Println(zero)
  14685. struct4101 := service.Struct4101{
  14686. PsnNo: order.PsnNo,
  14687. MdtrtId: order.MdtrtId,
  14688. SetlId: order.SetlId,
  14689. PsnName: order.PsnName,
  14690. Gend: order.Gend,
  14691. Brdy: his.Brdy,
  14692. Age: int64(order.Age),
  14693. Naty: order.Naty,
  14694. PatnCertType: "01",
  14695. Certno: order.Certno,
  14696. Prfs: "90",
  14697. ConerName: roles[0].UserName,
  14698. PatnRlts: "99",
  14699. ConerAddr: miConfig.OrgName,
  14700. ConerTel: admin.Mobile,
  14701. HiType: order.Insutype,
  14702. Insuplc: miConfig.InsuplcAdmdvs,
  14703. MaindiagFlag: "1",
  14704. BillCode: order.SetlId,
  14705. BillNo: order.SetlId,
  14706. BizSn: order.Number,
  14707. PsnSelfPay: order.PsnPartAmt,
  14708. PsnOwnPay: order.PsnPartAmt,
  14709. AcctPay: order.AcctPay,
  14710. PsnCashpay: order.PsnCashPay,
  14711. HiPaymtd: "1",
  14712. Hsorg: miConfig.InsuplcAdmdvs,
  14713. HsorgOpter: miConfig.InsuplcAdmdvs,
  14714. MedinsFillPsn: curRoles.UserName,
  14715. MedinsFillDept: depart.Name,
  14716. IptMedType: "2",
  14717. AdmTime: his.InHosptialTime,
  14718. AdmEndTime: his.OutHosptialTime,
  14719. }
  14720. struct4101.SetlBegnDate = order.SetlTime
  14721. struct4101.SetlEndDate = order.SetlTime
  14722. //var rf []CustomFundPay
  14723. //json.Unmarshal([]byte(order.SetlDetail), &rf)
  14724. //
  14725. //var tempFunPays []service.CustomStruct
  14726. //for _, item := range rf {
  14727. // var tempFunPay service.CustomStruct
  14728. // tempFunPay.FundPayamt = item.FundPayamt
  14729. // tempFunPay.FundPayType = item.FundPayType
  14730. // tempFunPays = append(tempFunPays, tempFunPay)
  14731. //}
  14732. //struct4101.CustomStruct = tempFunPays
  14733. var tempDiaginfos []service.DiaginfoStructTwo
  14734. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  14735. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  14736. //infos, _ := service.FindLastPatientPrescriptionInfoTwo2(c.GetAdminUserInfo().CurrentOrgId, his.PatientId, strings.Split(his.InHosptialTime, " ")[0], strings.Split(his.OutHosptialTime, " ")[0])
  14737. //for _, item := range infos {
  14738. // his.Diagnosis = his.Diagnosis + "," + item.Diagnosis
  14739. //}
  14740. diagnosis_ids_arr := strings.Split(his.Diagnosis, ",")
  14741. diagnosis_ids_arr = RemoveRepeatedPurviewElement2(diagnosis_ids_arr)
  14742. //diagnosis_ids := strings.Split(his.Diagnosis, ",")
  14743. fmt.Println(diagnosis_ids_arr)
  14744. if order.UserOrgId == 10210 {
  14745. var diagnosis_ids_arr_two []int64
  14746. diagnosis_ids_arr_two = append(diagnosis_ids_arr_two, 704)
  14747. var config []*models.HisXtDiagnoseConfig
  14748. for _, id := range diagnosis_ids_arr_two {
  14749. //id, _ := strconv.ParseInt(item, 10, 64)
  14750. diagnosisConfig, _ := service.FindDiagnoseById(id)
  14751. if diagnosisConfig.ID > 0 {
  14752. config = append(config, &diagnosisConfig)
  14753. }
  14754. }
  14755. for index, item := range config {
  14756. if item.ID > 0 {
  14757. if index == 0 {
  14758. var tempDiaginfo service.DiaginfoStructTwo
  14759. tempDiaginfo.DiagCode = item.CountryCode
  14760. tempDiaginfo.DiagName = item.CountryContentName
  14761. tempDiaginfo.DiagType = "1"
  14762. tempDiaginfo.MaindiagFlag = "1"
  14763. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  14764. } else {
  14765. var tempDiaginfo service.DiaginfoStructTwo
  14766. tempDiaginfo.DiagCode = item.CountryCode
  14767. tempDiaginfo.DiagName = item.CountryContentName
  14768. tempDiaginfo.DiagType = "1"
  14769. tempDiaginfo.MaindiagFlag = "0"
  14770. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  14771. }
  14772. }
  14773. }
  14774. struct4101.Diseinfo = tempDiaginfos
  14775. } else {
  14776. var config []*models.HisXtDiagnoseConfig
  14777. for _, item := range diagnosis_ids_arr {
  14778. id, _ := strconv.ParseInt(item, 10, 64)
  14779. diagnosisConfig, _ := service.FindDiagnoseById(id)
  14780. if diagnosisConfig.ID > 0 {
  14781. config = append(config, &diagnosisConfig)
  14782. }
  14783. }
  14784. for index, item := range config {
  14785. if item.ID > 0 {
  14786. if index == 0 {
  14787. var tempDiaginfo service.DiaginfoStructTwo
  14788. tempDiaginfo.DiagCode = item.CountryCode
  14789. tempDiaginfo.DiagName = item.CountryContentName
  14790. tempDiaginfo.DiagType = "1"
  14791. tempDiaginfo.MaindiagFlag = "1"
  14792. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  14793. } else {
  14794. var tempDiaginfo service.DiaginfoStructTwo
  14795. tempDiaginfo.DiagCode = item.CountryCode
  14796. tempDiaginfo.DiagName = item.CountryContentName
  14797. tempDiaginfo.DiagType = "1"
  14798. tempDiaginfo.MaindiagFlag = "0"
  14799. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  14800. }
  14801. }
  14802. }
  14803. struct4101.Diseinfo = tempDiaginfos
  14804. }
  14805. sickConfigTwo, _ := service.FindSickById(his.SickType)
  14806. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  14807. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  14808. tempOpspdiseinfo2.OprnOprtCode = ""
  14809. tempOpspdiseinfo2.OprnOprtName = ""
  14810. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  14811. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  14812. var iteminfo service.IteminfoStruct
  14813. var bedCostTotal float64 = 0 //床位总费
  14814. var bedCostSelfTotal float64 = 0 //床位自费
  14815. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  14816. var operationCostTotal float64 = 0 //手术费
  14817. var operationCostSelfTotal float64 = 0 //手术费
  14818. var operationCostPartSelfTotal float64 = 0 //手术费
  14819. var otherCostTotal float64 = 0 //其他费用
  14820. var otherCostSelfTotal float64 = 0 //其他费用
  14821. var otherCostPartSelfTotal float64 = 0 //其他费用
  14822. var materialCostTotal float64 = 0 //材料费
  14823. var materialCostSelfTotal float64 = 0 //材料费
  14824. var materialCostPartSelfTotal float64 = 0 //材料费
  14825. var westernMedicineCostTotal float64 = 0 //西药费
  14826. var westernMedicineCostSelfTotal float64 = 0 //西药费
  14827. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  14828. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  14829. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  14830. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  14831. var checkCostTotal float64 = 0 //检查费
  14832. var checkCostSelfTotal float64 = 0 //检查费
  14833. var checkCostPartSelfTotal float64 = 0 //检查费
  14834. var laboratoryCostTotal float64 = 0 //化验费
  14835. var laboratoryCostSelfTotal float64 = 0 //化验费
  14836. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  14837. var treatCostTotal float64 = 0 //治疗费用
  14838. var treatCostSelfTotal float64 = 0 //治疗费用
  14839. var treatCostPartSelfTotal float64 = 0 //治疗费用
  14840. decimal.DivisionPrecision = 2
  14841. var bed_fulamt_ownpay_amt float64 = 0
  14842. var operation_fulamt_ownpay_amt float64 = 0
  14843. var other_fulamt_ownpay_amt float64 = 0
  14844. var westernMedicine_fulamt_ownpay_amt float64 = 0
  14845. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  14846. var check_fulamt_ownpay_amt float64 = 0
  14847. var material_fulamt_ownpay_amt float64 = 0
  14848. var laboratory_fulamt_ownpay_amt float64 = 0
  14849. var treat_fulamt_ownpay_amt float64 = 0
  14850. var bed_claa_sunmfee float64 = 0
  14851. var bed_clab_amt float64 = 0
  14852. var bed_other_amt float64 = 0
  14853. var operation_claa_sunmfee float64 = 0
  14854. var operation_clab_amt float64 = 0
  14855. var operation_other_amt float64 = 0
  14856. var other_claa_sunmfee float64 = 0
  14857. var other_clab_amt float64 = 0
  14858. var other_other_amt float64 = 0
  14859. var westernMedicine_claa_sunmfee float64 = 0
  14860. var westernMedicine_clab_amt float64 = 0
  14861. var westernMedicine_other_amt float64 = 0
  14862. var chineseTraditional_claa_sunmfee float64 = 0
  14863. var chineseTraditional_clab_amt float64 = 0
  14864. var chineseTraditional_other_amt float64 = 0
  14865. var check_claa_sunmfee float64 = 0
  14866. var check_clab_amt float64 = 0
  14867. var check_other_amt float64 = 0
  14868. var material_claa_sunmfee float64 = 0
  14869. var material_clab_amt float64 = 0
  14870. var material_other_amt float64 = 0
  14871. var laboratory_claa_sunmfee float64 = 0
  14872. var laboratory_clab_amt float64 = 0
  14873. var laboratory_other_amt float64 = 0
  14874. var treat_claa_sunmfee float64 = 0
  14875. var treat_clab_amt float64 = 0
  14876. var treat_other_amt float64 = 0
  14877. for _, item := range order.HisOrderInfo {
  14878. if item.MedChrgitmType == "01" { //床位费
  14879. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14880. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14881. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14882. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14883. if item.ChrgitmLv == "1" {
  14884. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14885. }
  14886. if item.ChrgitmLv == "2" {
  14887. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14888. }
  14889. if item.ChrgitmLv == "3" {
  14890. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14891. }
  14892. }
  14893. if item.MedChrgitmType == "03" { //检查费
  14894. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14895. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14896. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14897. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14898. if item.ChrgitmLv == "1" {
  14899. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14900. }
  14901. if item.ChrgitmLv == "2" {
  14902. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14903. }
  14904. if item.ChrgitmLv == "3" {
  14905. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14906. }
  14907. }
  14908. if item.MedChrgitmType == "04" { //化验费
  14909. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14910. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14911. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14912. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14913. if item.ChrgitmLv == "1" {
  14914. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14915. }
  14916. if item.ChrgitmLv == "2" {
  14917. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14918. }
  14919. if item.ChrgitmLv == "3" {
  14920. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14921. }
  14922. }
  14923. if item.MedChrgitmType == "05" { //治疗费
  14924. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14925. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14926. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14927. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14928. if item.ChrgitmLv == "1" {
  14929. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14930. }
  14931. if item.ChrgitmLv == "2" {
  14932. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14933. }
  14934. if item.ChrgitmLv == "3" {
  14935. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14936. }
  14937. }
  14938. if item.MedChrgitmType == "06" { //手术费
  14939. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14940. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14941. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14942. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14943. if item.ChrgitmLv == "1" {
  14944. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14945. }
  14946. if item.ChrgitmLv == "2" {
  14947. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14948. }
  14949. if item.ChrgitmLv == "3" {
  14950. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14951. }
  14952. }
  14953. if item.MedChrgitmType == "08" { //材料费
  14954. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14955. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14956. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14957. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14958. if item.ChrgitmLv == "1" {
  14959. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14960. }
  14961. if item.ChrgitmLv == "2" {
  14962. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14963. }
  14964. if item.ChrgitmLv == "3" {
  14965. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14966. }
  14967. }
  14968. if item.MedChrgitmType == "09" { //西药费
  14969. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14970. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14971. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14972. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14973. if item.ChrgitmLv == "1" {
  14974. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14975. }
  14976. if item.ChrgitmLv == "2" {
  14977. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14978. }
  14979. if item.ChrgitmLv == "3" {
  14980. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14981. }
  14982. }
  14983. if item.MedChrgitmType == "11" { //中成费
  14984. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14985. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14986. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14987. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14988. if item.ChrgitmLv == "1" {
  14989. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14990. }
  14991. if item.ChrgitmLv == "2" {
  14992. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14993. }
  14994. if item.ChrgitmLv == "3" {
  14995. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14996. }
  14997. }
  14998. if item.MedChrgitmType == "14" { //其他费
  14999. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  15000. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  15001. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  15002. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  15003. if item.ChrgitmLv == "1" {
  15004. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  15005. }
  15006. if item.ChrgitmLv == "2" {
  15007. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  15008. }
  15009. if item.ChrgitmLv == "3" {
  15010. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  15011. }
  15012. }
  15013. }
  15014. var iteminfoStructs []service.IteminfoStruct
  15015. if bedCostTotal != 0 {
  15016. iteminfo.MedChrgitm = "01"
  15017. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  15018. iteminfo.Amt = bedCostTotal
  15019. iteminfo.ClaaSumfee = bed_claa_sunmfee
  15020. iteminfo.ClabAmt = bed_clab_amt
  15021. iteminfo.OthAmt = bed_other_amt
  15022. iteminfoStructs = append(iteminfoStructs, iteminfo)
  15023. }
  15024. if checkCostTotal != 0 {
  15025. iteminfo.MedChrgitm = "03"
  15026. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  15027. iteminfo.Amt = checkCostTotal
  15028. iteminfo.ClaaSumfee = check_claa_sunmfee
  15029. iteminfo.ClabAmt = check_clab_amt
  15030. iteminfo.OthAmt = check_other_amt
  15031. iteminfoStructs = append(iteminfoStructs, iteminfo)
  15032. }
  15033. if laboratoryCostTotal != 0 {
  15034. iteminfo.MedChrgitm = "04"
  15035. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  15036. iteminfo.Amt = laboratoryCostTotal
  15037. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  15038. iteminfo.ClabAmt = laboratory_clab_amt
  15039. iteminfo.OthAmt = laboratory_other_amt
  15040. iteminfoStructs = append(iteminfoStructs, iteminfo)
  15041. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  15042. }
  15043. if treatCostTotal != 0 {
  15044. iteminfo.MedChrgitm = "05"
  15045. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  15046. iteminfo.Amt = treatCostTotal
  15047. iteminfo.ClaaSumfee = treat_claa_sunmfee
  15048. iteminfo.ClabAmt = treat_clab_amt
  15049. iteminfo.OthAmt = treat_other_amt
  15050. iteminfoStructs = append(iteminfoStructs, iteminfo)
  15051. //(struct4101.IteminfoStruct, iteminfo)
  15052. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  15053. }
  15054. if operationCostTotal != 0 {
  15055. iteminfo.MedChrgitm = "06"
  15056. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  15057. iteminfo.Amt = operationCostTotal
  15058. iteminfo.ClaaSumfee = operation_claa_sunmfee
  15059. iteminfo.ClabAmt = operation_clab_amt
  15060. iteminfo.OthAmt = operation_other_amt
  15061. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  15062. iteminfoStructs = append(iteminfoStructs, iteminfo)
  15063. }
  15064. if materialCostTotal != 0 {
  15065. iteminfo.MedChrgitm = "08"
  15066. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  15067. iteminfo.Amt = materialCostTotal
  15068. iteminfo.ClaaSumfee = material_claa_sunmfee
  15069. iteminfo.ClabAmt = material_clab_amt
  15070. iteminfo.OthAmt = material_other_amt
  15071. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  15072. iteminfoStructs = append(iteminfoStructs, iteminfo)
  15073. }
  15074. if westernMedicineCostTotal != 0 {
  15075. iteminfo.MedChrgitm = "09"
  15076. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  15077. iteminfo.Amt = westernMedicineCostTotal
  15078. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  15079. iteminfo.ClabAmt = westernMedicine_clab_amt
  15080. iteminfo.OthAmt = westernMedicine_other_amt
  15081. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  15082. iteminfoStructs = append(iteminfoStructs, iteminfo)
  15083. }
  15084. if chineseTraditionalMedicineCostTotal != 0 {
  15085. iteminfo.MedChrgitm = "11"
  15086. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  15087. iteminfo.Amt = westernMedicineCostTotal
  15088. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  15089. iteminfo.ClabAmt = westernMedicine_clab_amt
  15090. iteminfo.OthAmt = westernMedicine_other_amt
  15091. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  15092. iteminfoStructs = append(iteminfoStructs, iteminfo)
  15093. }
  15094. if otherCostTotal != 0 {
  15095. iteminfo.MedChrgitm = "14"
  15096. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  15097. iteminfo.Amt = otherCostTotal
  15098. iteminfo.ClaaSumfee = other_claa_sunmfee
  15099. iteminfo.ClabAmt = other_clab_amt
  15100. iteminfo.OthAmt = other_other_amt
  15101. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  15102. iteminfoStructs = append(iteminfoStructs, iteminfo)
  15103. }
  15104. struct4101.IteminfoStruct = iteminfoStructs
  15105. struct4101.Ntly = "中国"
  15106. struct4101.AdmCaty = "A03.06"
  15107. var resOther ResultSeventeenOther
  15108. var res ResultSeventeen
  15109. if miConfig.MdtrtareaAdmvs == "150499" {
  15110. var pp models.PublicParams
  15111. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  15112. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  15113. pp.FixmedinsName = miConfig.OrgName
  15114. pp.FixmedinsCode = miConfig.Code
  15115. pp.RequestUrl = miConfig.Url
  15116. pp.Cainfo = miConfig.Cainfo
  15117. pp.SecretKey = miConfig.SecretKey
  15118. pp.AccessKey = miConfig.AccessKey
  15119. pp.OpterName = curRoles.UserName
  15120. client := &http.Client{}
  15121. var req *http.Request
  15122. data := make(map[string]interface{})
  15123. data["struct4101"] = struct4101
  15124. data["pp"] = pp
  15125. bytesData, _ := json.Marshal(data)
  15126. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/4101", bytes.NewReader(bytesData))
  15127. resp, _ := client.Do(req)
  15128. defer resp.Body.Close()
  15129. body, ioErr := ioutil.ReadAll(resp.Body)
  15130. if ioErr != nil {
  15131. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  15132. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15133. return
  15134. }
  15135. var respJSON map[string]interface{}
  15136. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  15137. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15138. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15139. return
  15140. }
  15141. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  15142. userJSONBytes, _ := json.Marshal(respJSON)
  15143. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  15144. utils.ErrorLog("解析失败:%v", err)
  15145. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15146. return
  15147. }
  15148. res.InfRefmsgid = resOther.InfRefmsgid
  15149. res.Output = resOther.Output
  15150. res.ErrMsg = resOther.ErrMsg
  15151. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  15152. res.Infcode = infocode
  15153. } else if miConfig.MdtrtareaAdmvs == "360302" {
  15154. var pp models.PublicParams
  15155. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  15156. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  15157. pp.FixmedinsName = miConfig.OrgName
  15158. pp.FixmedinsCode = miConfig.Code
  15159. pp.RequestUrl = miConfig.Url
  15160. pp.Cainfo = miConfig.Cainfo
  15161. pp.SecretKey = miConfig.SecretKey
  15162. pp.AccessKey = miConfig.AccessKey
  15163. pp.OpterName = curRoles.UserName
  15164. result, _ := service.Jxyb4101(struct4101, pp)
  15165. var dat map[string]interface{}
  15166. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  15167. fmt.Println(dat)
  15168. } else {
  15169. fmt.Println(err)
  15170. }
  15171. userJSONBytes, _ := json.Marshal(dat)
  15172. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  15173. utils.ErrorLog("解析失败:%v", err)
  15174. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15175. return
  15176. }
  15177. } else {
  15178. result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId, admin_user_id)
  15179. var dat map[string]interface{}
  15180. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  15181. fmt.Println(dat)
  15182. } else {
  15183. fmt.Println(err)
  15184. }
  15185. userJSONBytes, _ := json.Marshal(dat)
  15186. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  15187. utils.ErrorLog("解析失败:%v", err)
  15188. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15189. return
  15190. }
  15191. }
  15192. if res.Infcode != 0 {
  15193. c.ServeSuccessJSON(map[string]interface{}{
  15194. "failed_code": -10,
  15195. "msg": res.ErrMsg,
  15196. })
  15197. return
  15198. } else {
  15199. if miConfig.MdtrtareaAdmvs != "150499" {
  15200. order.FaPiaoNumber = zero
  15201. order.FaPiaoCode = last_order.FaPiaoCode
  15202. service.UpdateOrder(order)
  15203. }
  15204. hisFundSettleListResult := &models.HisFundSettleListResult{
  15205. Number: res.Output.SetlListId,
  15206. Status: 1,
  15207. Ctime: time.Now().Unix(),
  15208. Mtime: time.Now().Unix(),
  15209. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15210. IsUpload: 1,
  15211. OrderId: order_id,
  15212. }
  15213. service.CreateUploadRecord(hisFundSettleListResult)
  15214. c.ServeSuccessJSON(map[string]interface{}{
  15215. "msg": "上传成功",
  15216. "result": hisFundSettleListResult,
  15217. })
  15218. return
  15219. }
  15220. }
  15221. //func (c *HisApiController) GetBatchSettleList() {
  15222. // orders, _ := service.GetAllHisOrder(10106)
  15223. // for _, item := range orders {
  15224. // order_id := item.ID
  15225. // order, _ := service.GetHisOrderByIDTwo(order_id)
  15226. // roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  15227. // his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  15228. // admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  15229. // curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, 2495)
  15230. // depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  15231. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  15232. //
  15233. // pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  15234. //
  15235. // doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  15236. //
  15237. // if order.ID == 0 {
  15238. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  15239. // return
  15240. // }
  15241. // if his.BalanceAccountsType == 2 {
  15242. // continue
  15243. // }
  15244. // struct4101 := service.Struct4101{
  15245. // PsnNo: order.PsnNo,
  15246. // MdtrtId: order.MdtrtId,
  15247. // SetlId: order.SetlId,
  15248. // PsnName: order.PsnName,
  15249. // Gend: order.Gend,
  15250. // Brdy: his.Brdy,
  15251. // Age: his.Age,
  15252. // Naty: order.Naty,
  15253. // PatnCertType: "01",
  15254. // Certno: order.Certno,
  15255. // Prfs: "90",
  15256. // ConerName: roles[0].UserName,
  15257. // PatnRlts: "99",
  15258. // ConerAddr: miConfig.OrgName,
  15259. // ConerTel: admin.Mobile,
  15260. // HiType: order.Insutype,
  15261. // Insuplc: his.InsuplcAdmdvs,
  15262. // MaindiagFlag: "1",
  15263. // BillCode: order.SetlId,
  15264. // BillNo: order.SetlId,
  15265. // BizSn: order.Number,
  15266. // PsnSelfPay: order.PsnPartAmt,
  15267. // PsnOwnPay: order.PsnPartAmt,
  15268. // AcctPay: order.AcctPay,
  15269. // PsnCashpay: order.PsnCashPay,
  15270. // HiPaymtd: "1",
  15271. // Hsorg: his.InsuplcAdmdvs,
  15272. // HsorgOpter: his.InsuplcAdmdvs,
  15273. // MedinsFillPsn: curRoles.UserName,
  15274. // MedinsFillDept: depart.Name,
  15275. // IptMedType: "2",
  15276. // }
  15277. // struct4101.SetlBegnDate = order.SetlTime
  15278. // struct4101.SetlEndDate = order.SetlTime
  15279. // //if order.SettleType == 1 {
  15280. // // t := time.Unix(int64(order.SettleAccountsDate), 0)
  15281. // // dateStr := t.Format("2006-01-02")
  15282. // // struct4101.SetlBegnDate = dateStr
  15283. // // struct4101.SetlEndDate = dateStr
  15284. // //} else {
  15285. // // t := time.Unix(int64(order.SettleStartTime), 0)
  15286. // // t2 := time.Unix(int64(order.SettleEndTime), 0)
  15287. // // dateStartStr := t.Format("2006-01-02")
  15288. // // dateEndStr := t2.Format("2006-01-02")
  15289. // // struct4101.SetlBegnDate = dateStartStr
  15290. // // struct4101.SetlEndDate = dateEndStr
  15291. // //}
  15292. //
  15293. // var rf []CustomFundPay
  15294. // json.Unmarshal([]byte(order.SetlDetail), &rf)
  15295. //
  15296. // var tempFunPays []service.CustomStruct
  15297. // var tempFunPay610100 service.CustomStruct
  15298. //
  15299. // for _, item := range rf {
  15300. // if item.FundPayType == "610100" {
  15301. // tempFunPay610100.FundPayamt, _ = decimal.NewFromFloat(tempFunPay610100.FundPayamt).Add(decimal.NewFromFloat(item.FundPayamt)).Float64()
  15302. // tempFunPay610100.FundPayType = item.FundPayType
  15303. // } else {
  15304. // var tempFunPay service.CustomStruct
  15305. // tempFunPay.FundPayamt = item.FundPayamt
  15306. // tempFunPay.FundPayType = item.FundPayType
  15307. // tempFunPays = append(tempFunPays, tempFunPay)
  15308. // }
  15309. // }
  15310. // tempFunPays = append(tempFunPays, tempFunPay610100)
  15311. // struct4101.CustomStruct = tempFunPays
  15312. //
  15313. // var tempDiaginfos []service.DiaginfoStructTwo
  15314. // var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  15315. // var tempOpspdiseinfos []service.OpspdiseinfoStruct
  15316. //
  15317. // diagnosis_ids := strings.Split(his.Diagnosis, ",")
  15318. // var config []*models.HisXtDiagnoseConfig
  15319. // for _, item := range diagnosis_ids {
  15320. // id, _ := strconv.ParseInt(item, 10, 64)
  15321. // diagnosisConfig, _ := service.FindDiagnoseById(id)
  15322. // config = append(config, &diagnosisConfig)
  15323. // }
  15324. //
  15325. // for index, item := range config {
  15326. // if index == 0 {
  15327. // var tempDiaginfo service.DiaginfoStructTwo
  15328. // tempDiaginfo.DiagCode = item.CountryCode
  15329. // tempDiaginfo.DiagName = item.CountryContentName
  15330. // tempDiaginfo.DiagType = "1"
  15331. // tempDiaginfo.MaindiagFlag = "1"
  15332. // tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  15333. // } else {
  15334. //
  15335. // var tempDiaginfo service.DiaginfoStructTwo
  15336. // tempDiaginfo.DiagCode = item.CountryCode
  15337. // tempDiaginfo.DiagName = item.CountryContentName
  15338. // tempDiaginfo.DiagType = "2"
  15339. // tempDiaginfo.MaindiagFlag = "0"
  15340. // tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  15341. // }
  15342. // }
  15343. // struct4101.Diseinfo = tempDiaginfos
  15344. //
  15345. // sickConfigTwo, _ := service.FindSickById(his.SickType)
  15346. // tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  15347. // tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  15348. // tempOpspdiseinfo2.OprnOprtCode = ""
  15349. // tempOpspdiseinfo2.OprnOprtName = ""
  15350. // tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  15351. // struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  15352. //
  15353. // var iteminfo service.IteminfoStruct
  15354. //
  15355. // var bedCostTotal float64 = 0 //床位总费
  15356. // var bedCostSelfTotal float64 = 0 //床位自费
  15357. // var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  15358. //
  15359. // var examineCostTotal float64 = 0 //诊查总费
  15360. // var examineCostSelfTotal float64 = 0 //诊查自费
  15361. // var examineCostPartSelfTotal float64 = 0 //诊查部分项目自费
  15362. //
  15363. // var nursingCostTotal float64 = 0 //护理总费
  15364. // var nursingCostSelfTotal float64 = 0 //护理自费
  15365. // var nursingCostPartSelfTotal float64 = 0 //护理部分项目自费
  15366. //
  15367. // var chineseMedicineCostTotal float64 = 0 //中成药
  15368. // var chineseMedicineCostSelfTotal float64 = 0 //中成药
  15369. // var chineseMedicineCostPartSelfTotal float64 = 0 //中成药
  15370. //
  15371. // var commonlyTreatmentCostTotal float64 = 0 //一般诊疗费
  15372. // var commonlyTreatmentCostSelfTotal float64 = 0 //一般诊疗费
  15373. // var commonlyTreatmentCostPartSelfTotal float64 = 0 //一般诊疗费
  15374. //
  15375. // var registerCostTotal float64 = 0 //一般诊疗费
  15376. // var registerCostSelfTotal float64 = 0 //一般诊疗费
  15377. // var registerPartSelfTotal float64 = 0 //一般诊疗费
  15378. //
  15379. // var operationCostTotal float64 = 0 //手术费
  15380. // var operationCostSelfTotal float64 = 0 //手术费
  15381. // var operationCostPartSelfTotal float64 = 0 //手术费
  15382. //
  15383. // var otherCostTotal float64 = 0 //其他费用
  15384. // var otherCostSelfTotal float64 = 0 //其他费用
  15385. // var otherCostPartSelfTotal float64 = 0 //其他费用
  15386. //
  15387. // var materialCostTotal float64 = 0 //材料费
  15388. // var materialCostSelfTotal float64 = 0 //材料费
  15389. // var materialCostPartSelfTotal float64 = 0 //材料费
  15390. //
  15391. // var westernMedicineCostTotal float64 = 0 //西药费
  15392. // var westernMedicineCostSelfTotal float64 = 0 //西药费
  15393. // var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  15394. //
  15395. // var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  15396. // var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  15397. // var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  15398. //
  15399. // var checkCostTotal float64 = 0 //检查费
  15400. // var checkCostSelfTotal float64 = 0 //检查费
  15401. // var checkCostPartSelfTotal float64 = 0 //检查费
  15402. //
  15403. // var laboratoryCostTotal float64 = 0 //化验费
  15404. // var laboratoryCostSelfTotal float64 = 0 //化验费
  15405. // var laboratoryCostPartSelfTotal float64 = 0 //化验费
  15406. //
  15407. // var treatCostTotal float64 = 0 //治疗费用
  15408. // var treatCostSelfTotal float64 = 0 //治疗费用
  15409. // var treatCostPartSelfTotal float64 = 0 //治疗费用
  15410. //
  15411. // decimal.DivisionPrecision = 2
  15412. //
  15413. // var bed_fulamt_ownpay_amt float64 = 0
  15414. //
  15415. // var examine_fulamt_ownpay_amt float64 = 0
  15416. //
  15417. // var nursing_fulamt_ownpay_amt float64 = 0
  15418. //
  15419. // var chinese_medicine_fulamt_ownpay_amt float64 = 0
  15420. //
  15421. // var commonly_treatment_fulamt_ownpay_amt float64 = 0
  15422. //
  15423. // var register_fulamt_ownpay_amt float64 = 0
  15424. //
  15425. // var operation_fulamt_ownpay_amt float64 = 0
  15426. // var other_fulamt_ownpay_amt float64 = 0
  15427. // var westernMedicine_fulamt_ownpay_amt float64 = 0
  15428. // var chineseTraditional_fulamt_ownpay_amt float64 = 0
  15429. // var check_fulamt_ownpay_amt float64 = 0
  15430. // var material_fulamt_ownpay_amt float64 = 0
  15431. // var laboratory_fulamt_ownpay_amt float64 = 0
  15432. // var treat_fulamt_ownpay_amt float64 = 0
  15433. //
  15434. // var bed_claa_sunmfee float64 = 0
  15435. // var bed_clab_amt float64 = 0
  15436. // var bed_other_amt float64 = 0
  15437. //
  15438. // var examine_claa_sunmfee float64 = 0
  15439. // var examine_clab_amt float64 = 0
  15440. // var examine_other_amt float64 = 0
  15441. //
  15442. // var nursing_claa_sunmfee float64 = 0
  15443. // var nursing_clab_amt float64 = 0
  15444. // var nursing_other_amt float64 = 0
  15445. //
  15446. // var chinese_medicine_claa_sunmfee float64 = 0
  15447. // var chinese_medicine_clab_amt float64 = 0
  15448. // var chinese_medicine_other_amt float64 = 0
  15449. //
  15450. // var commonly_treatment_claa_sunmfee float64 = 0
  15451. // var commonly_treatment_clab_amt float64 = 0
  15452. // var commonly_treatment_other_amt float64 = 0
  15453. //
  15454. // var operation_claa_sunmfee float64 = 0
  15455. // var operation_clab_amt float64 = 0
  15456. // var operation_other_amt float64 = 0
  15457. //
  15458. // var other_claa_sunmfee float64 = 0
  15459. // var other_clab_amt float64 = 0
  15460. // var other_other_amt float64 = 0
  15461. //
  15462. // var westernMedicine_claa_sunmfee float64 = 0
  15463. // var westernMedicine_clab_amt float64 = 0
  15464. // var westernMedicine_other_amt float64 = 0
  15465. //
  15466. // var chineseTraditional_claa_sunmfee float64 = 0
  15467. // var chineseTraditional_clab_amt float64 = 0
  15468. // var chineseTraditional_other_amt float64 = 0
  15469. //
  15470. // var check_claa_sunmfee float64 = 0
  15471. // var check_clab_amt float64 = 0
  15472. // var check_other_amt float64 = 0
  15473. //
  15474. // var material_claa_sunmfee float64 = 0
  15475. // var material_clab_amt float64 = 0
  15476. // var material_other_amt float64 = 0
  15477. //
  15478. // var laboratory_claa_sunmfee float64 = 0
  15479. // var laboratory_clab_amt float64 = 0
  15480. // var laboratory_other_amt float64 = 0
  15481. //
  15482. // var treat_claa_sunmfee float64 = 0
  15483. // var treat_clab_amt float64 = 0
  15484. // var treat_other_amt float64 = 0
  15485. //
  15486. // var register_claa_sunmfee float64 = 0
  15487. // var register_clab_amt float64 = 0
  15488. // var register_other_amt float64 = 0
  15489. //
  15490. // for _, item := range order.HisOrderInfo {
  15491. // if item.MedChrgitmType == "01" { //床位费
  15492. // bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  15493. // bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  15494. // bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  15495. // bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  15496. // if item.ChrgitmLv == "1" {
  15497. // bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  15498. // }
  15499. // if item.ChrgitmLv == "2" {
  15500. // bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  15501. //
  15502. // }
  15503. // if item.ChrgitmLv == "3" {
  15504. // bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  15505. // }
  15506. //
  15507. // }
  15508. //
  15509. // if item.MedChrgitmType == "02" { //诊查
  15510. // examineCostTotal, _ = decimal.NewFromFloat(examineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  15511. // examineCostSelfTotal, _ = decimal.NewFromFloat(examineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  15512. // examineCostPartSelfTotal, _ = decimal.NewFromFloat(examineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  15513. // examine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(examine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  15514. // if item.ChrgitmLv == "1" {
  15515. // examine_claa_sunmfee, _ = decimal.NewFromFloat(examine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  15516. // }
  15517. // if item.ChrgitmLv == "2" {
  15518. // examine_clab_amt, _ = decimal.NewFromFloat(examine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  15519. //
  15520. // }
  15521. // if item.ChrgitmLv == "3" {
  15522. // examine_other_amt, _ = decimal.NewFromFloat(examine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  15523. // }
  15524. //
  15525. // }
  15526. //
  15527. // if item.MedChrgitmType == "03" { //检查费
  15528. // checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  15529. // checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  15530. // checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  15531. // check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  15532. // if item.ChrgitmLv == "1" {
  15533. //
  15534. // check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  15535. //
  15536. // }
  15537. // if item.ChrgitmLv == "2" {
  15538. // check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  15539. //
  15540. // }
  15541. // if item.ChrgitmLv == "3" {
  15542. // check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  15543. // }
  15544. // }
  15545. //
  15546. // if item.MedChrgitmType == "04" { //化验费
  15547. // laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  15548. // laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  15549. // laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  15550. // laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  15551. // if item.ChrgitmLv == "1" {
  15552. //
  15553. // laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  15554. //
  15555. // }
  15556. // if item.ChrgitmLv == "2" {
  15557. // laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  15558. //
  15559. // }
  15560. // if item.ChrgitmLv == "3" {
  15561. // laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  15562. // }
  15563. // }
  15564. //
  15565. // if item.MedChrgitmType == "05" { //治疗费
  15566. // treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  15567. // treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  15568. // treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  15569. // treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  15570. // if item.ChrgitmLv == "1" {
  15571. //
  15572. // treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  15573. //
  15574. // }
  15575. // if item.ChrgitmLv == "2" {
  15576. // treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  15577. //
  15578. // }
  15579. // if item.ChrgitmLv == "3" {
  15580. // treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  15581. // }
  15582. // }
  15583. //
  15584. // if item.MedChrgitmType == "06" { //手术费
  15585. // operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  15586. // operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  15587. // operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  15588. // operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  15589. //
  15590. // if item.ChrgitmLv == "1" {
  15591. //
  15592. // operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  15593. //
  15594. // }
  15595. // if item.ChrgitmLv == "2" {
  15596. // operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  15597. //
  15598. // }
  15599. // if item.ChrgitmLv == "3" {
  15600. // operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  15601. // }
  15602. // }
  15603. //
  15604. // if item.MedChrgitmType == "07" { //手术费
  15605. // nursingCostTotal, _ = decimal.NewFromFloat(nursingCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  15606. // nursingCostSelfTotal, _ = decimal.NewFromFloat(nursingCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  15607. // nursingCostPartSelfTotal, _ = decimal.NewFromFloat(nursingCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  15608. // nursing_fulamt_ownpay_amt, _ = decimal.NewFromFloat(nursing_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  15609. //
  15610. // if item.ChrgitmLv == "1" {
  15611. //
  15612. // nursing_claa_sunmfee, _ = decimal.NewFromFloat(nursing_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  15613. //
  15614. // }
  15615. // if item.ChrgitmLv == "2" {
  15616. // nursing_clab_amt, _ = decimal.NewFromFloat(nursing_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  15617. //
  15618. // }
  15619. // if item.ChrgitmLv == "3" {
  15620. // nursing_other_amt, _ = decimal.NewFromFloat(nursing_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  15621. // }
  15622. // }
  15623. //
  15624. // if item.MedChrgitmType == "08" { //材料费
  15625. // materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  15626. // materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  15627. // materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  15628. // material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  15629. // if item.ChrgitmLv == "1" {
  15630. //
  15631. // material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  15632. //
  15633. // }
  15634. // if item.ChrgitmLv == "2" {
  15635. // material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  15636. //
  15637. // }
  15638. // if item.ChrgitmLv == "3" {
  15639. // material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  15640. // }
  15641. // }
  15642. // if item.MedChrgitmType == "09" { //西药费
  15643. // westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  15644. // westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  15645. // westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  15646. // westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  15647. // if item.ChrgitmLv == "1" {
  15648. // westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  15649. // }
  15650. // if item.ChrgitmLv == "2" {
  15651. // westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  15652. // }
  15653. // if item.ChrgitmLv == "3" {
  15654. // westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  15655. // }
  15656. // }
  15657. // if item.MedChrgitmType == "10" { //中药饮片
  15658. // chineseMedicineCostTotal, _ = decimal.NewFromFloat(chineseMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  15659. // chineseMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  15660. // chineseMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  15661. // chinese_medicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chinese_medicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  15662. // if item.ChrgitmLv == "1" {
  15663. // chinese_medicine_claa_sunmfee, _ = decimal.NewFromFloat(chinese_medicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  15664. // }
  15665. // if item.ChrgitmLv == "2" {
  15666. // chinese_medicine_clab_amt, _ = decimal.NewFromFloat(chinese_medicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  15667. // }
  15668. // if item.ChrgitmLv == "3" {
  15669. // chinese_medicine_other_amt, _ = decimal.NewFromFloat(chinese_medicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  15670. // }
  15671. // }
  15672. //
  15673. // if item.MedChrgitmType == "11" { //中成费
  15674. // chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  15675. // chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  15676. // chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  15677. // chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  15678. // if item.ChrgitmLv == "1" {
  15679. //
  15680. // chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  15681. //
  15682. // }
  15683. // if item.ChrgitmLv == "2" {
  15684. // chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  15685. //
  15686. // }
  15687. // if item.ChrgitmLv == "3" {
  15688. // chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  15689. // }
  15690. // }
  15691. //
  15692. // if item.MedChrgitmType == "12" { //中成费
  15693. // commonlyTreatmentCostTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  15694. // commonlyTreatmentCostSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  15695. // commonlyTreatmentCostPartSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  15696. // commonly_treatment_fulamt_ownpay_amt, _ = decimal.NewFromFloat(commonly_treatment_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  15697. // if item.ChrgitmLv == "1" {
  15698. //
  15699. // commonly_treatment_claa_sunmfee, _ = decimal.NewFromFloat(commonly_treatment_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  15700. //
  15701. // }
  15702. // if item.ChrgitmLv == "2" {
  15703. // commonly_treatment_clab_amt, _ = decimal.NewFromFloat(commonly_treatment_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  15704. //
  15705. // }
  15706. // if item.ChrgitmLv == "3" {
  15707. // commonly_treatment_other_amt, _ = decimal.NewFromFloat(commonly_treatment_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  15708. // }
  15709. // }
  15710. //
  15711. // if item.MedChrgitmType == "13" { //中成费
  15712. // registerCostTotal, _ = decimal.NewFromFloat(registerCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  15713. // registerCostSelfTotal, _ = decimal.NewFromFloat(registerCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  15714. // registerPartSelfTotal, _ = decimal.NewFromFloat(registerPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  15715. // register_fulamt_ownpay_amt, _ = decimal.NewFromFloat(register_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  15716. // if item.ChrgitmLv == "1" {
  15717. //
  15718. // register_claa_sunmfee, _ = decimal.NewFromFloat(register_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  15719. //
  15720. // }
  15721. // if item.ChrgitmLv == "2" {
  15722. // register_clab_amt, _ = decimal.NewFromFloat(register_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  15723. //
  15724. // }
  15725. // if item.ChrgitmLv == "3" {
  15726. // register_other_amt, _ = decimal.NewFromFloat(register_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  15727. // }
  15728. // }
  15729. //
  15730. // if item.MedChrgitmType == "14" { //其他费
  15731. // otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  15732. // otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  15733. // otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  15734. // other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  15735. // if item.ChrgitmLv == "1" {
  15736. // other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  15737. //
  15738. // }
  15739. // if item.ChrgitmLv == "2" {
  15740. // other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  15741. //
  15742. // }
  15743. // if item.ChrgitmLv == "3" {
  15744. // other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  15745. // }
  15746. // }
  15747. //
  15748. // }
  15749. //
  15750. // var iteminfoStructs []service.IteminfoStruct
  15751. //
  15752. // if bedCostTotal != 0 {
  15753. // iteminfo.MedChrgitm = "01"
  15754. // iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  15755. // iteminfo.Amt = bedCostTotal
  15756. // iteminfo.ClaaSumfee = bed_claa_sunmfee
  15757. // iteminfo.ClabAmt = bed_clab_amt
  15758. // iteminfo.OthAmt = bed_other_amt
  15759. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  15760. // }
  15761. //
  15762. // if examineCostTotal != 0 {
  15763. // iteminfo.MedChrgitm = "02"
  15764. // iteminfo.FulamtOwnpayAmt = examine_fulamt_ownpay_amt
  15765. // iteminfo.Amt = examineCostTotal
  15766. // iteminfo.ClaaSumfee = examine_claa_sunmfee
  15767. // iteminfo.ClabAmt = examine_clab_amt
  15768. // iteminfo.OthAmt = examine_other_amt
  15769. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  15770. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  15771. // }
  15772. //
  15773. // if checkCostTotal != 0 {
  15774. // iteminfo.MedChrgitm = "03"
  15775. // iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  15776. // iteminfo.Amt = checkCostTotal
  15777. // iteminfo.ClaaSumfee = check_claa_sunmfee
  15778. // iteminfo.ClabAmt = check_clab_amt
  15779. // iteminfo.OthAmt = check_other_amt
  15780. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  15781. //
  15782. // }
  15783. //
  15784. // if laboratoryCostTotal != 0 {
  15785. // iteminfo.MedChrgitm = "04"
  15786. // iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  15787. // iteminfo.Amt = laboratoryCostTotal
  15788. // iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  15789. // iteminfo.ClabAmt = laboratory_clab_amt
  15790. // iteminfo.OthAmt = laboratory_other_amt
  15791. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  15792. //
  15793. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  15794. //
  15795. // }
  15796. //
  15797. // if treatCostTotal != 0 {
  15798. // iteminfo.MedChrgitm = "05"
  15799. // iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  15800. // iteminfo.Amt = treatCostTotal
  15801. // iteminfo.ClaaSumfee = treat_claa_sunmfee
  15802. // iteminfo.ClabAmt = treat_clab_amt
  15803. // iteminfo.OthAmt = treat_other_amt
  15804. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  15805. // //(struct4101.IteminfoStruct, iteminfo)
  15806. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  15807. // }
  15808. //
  15809. // if operationCostTotal != 0 {
  15810. // iteminfo.MedChrgitm = "06"
  15811. // iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  15812. // iteminfo.Amt = operationCostTotal
  15813. // iteminfo.ClaaSumfee = operation_claa_sunmfee
  15814. // iteminfo.ClabAmt = operation_clab_amt
  15815. // iteminfo.OthAmt = operation_other_amt
  15816. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  15817. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  15818. // }
  15819. //
  15820. // if nursingCostTotal != 0 {
  15821. // iteminfo.MedChrgitm = "07"
  15822. // iteminfo.FulamtOwnpayAmt = nursing_fulamt_ownpay_amt
  15823. // iteminfo.Amt = nursingCostTotal
  15824. // iteminfo.ClaaSumfee = nursing_claa_sunmfee
  15825. // iteminfo.ClabAmt = nursing_clab_amt
  15826. // iteminfo.OthAmt = nursing_other_amt
  15827. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  15828. // }
  15829. //
  15830. // if materialCostTotal != 0 {
  15831. // iteminfo.MedChrgitm = "08"
  15832. // iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  15833. // iteminfo.Amt = materialCostTotal
  15834. // iteminfo.ClaaSumfee = material_claa_sunmfee
  15835. // iteminfo.ClabAmt = material_clab_amt
  15836. // iteminfo.OthAmt = material_other_amt
  15837. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  15838. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  15839. // }
  15840. //
  15841. // if westernMedicineCostTotal != 0 {
  15842. // iteminfo.MedChrgitm = "09"
  15843. // iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  15844. // iteminfo.Amt = westernMedicineCostTotal
  15845. // iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  15846. // iteminfo.ClabAmt = westernMedicine_clab_amt
  15847. // iteminfo.OthAmt = westernMedicine_other_amt
  15848. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  15849. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  15850. //
  15851. // }
  15852. //
  15853. // if chineseMedicineCostTotal != 0 {
  15854. // iteminfo.MedChrgitm = "10"
  15855. // iteminfo.FulamtOwnpayAmt = chinese_medicine_fulamt_ownpay_amt
  15856. // iteminfo.Amt = chineseMedicineCostTotal
  15857. // iteminfo.ClaaSumfee = chinese_medicine_claa_sunmfee
  15858. // iteminfo.ClabAmt = chinese_medicine_clab_amt
  15859. // iteminfo.OthAmt = chinese_medicine_other_amt
  15860. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  15861. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  15862. //
  15863. // }
  15864. //
  15865. // if chineseTraditionalMedicineCostTotal != 0 {
  15866. // iteminfo.MedChrgitm = "11"
  15867. // iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  15868. // iteminfo.Amt = westernMedicineCostTotal
  15869. // iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  15870. // iteminfo.ClabAmt = westernMedicine_clab_amt
  15871. // iteminfo.OthAmt = westernMedicine_other_amt
  15872. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  15873. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  15874. //
  15875. // }
  15876. //
  15877. // if commonlyTreatmentCostTotal != 0 {
  15878. // iteminfo.MedChrgitm = "12"
  15879. // iteminfo.FulamtOwnpayAmt = commonly_treatment_fulamt_ownpay_amt
  15880. // iteminfo.Amt = commonlyTreatmentCostTotal
  15881. // iteminfo.ClaaSumfee = commonly_treatment_claa_sunmfee
  15882. // iteminfo.ClabAmt = commonly_treatment_clab_amt
  15883. // iteminfo.OthAmt = commonly_treatment_other_amt
  15884. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  15885. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  15886. //
  15887. // }
  15888. //
  15889. // if registerCostTotal != 0 {
  15890. // iteminfo.MedChrgitm = "13"
  15891. // iteminfo.FulamtOwnpayAmt = register_fulamt_ownpay_amt
  15892. // iteminfo.Amt = registerCostTotal
  15893. // iteminfo.ClaaSumfee = register_claa_sunmfee
  15894. // iteminfo.ClabAmt = register_clab_amt
  15895. // iteminfo.OthAmt = register_other_amt
  15896. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  15897. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  15898. //
  15899. // }
  15900. //
  15901. // if otherCostTotal != 0 {
  15902. // iteminfo.MedChrgitm = "14"
  15903. // iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  15904. // iteminfo.Amt = otherCostTotal
  15905. // iteminfo.ClaaSumfee = other_claa_sunmfee
  15906. // iteminfo.ClabAmt = other_clab_amt
  15907. // iteminfo.OthAmt = other_other_amt
  15908. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  15909. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  15910. //
  15911. // }
  15912. // struct4101.IteminfoStruct = iteminfoStructs
  15913. // time_arr := strings.Split(order.SetlTime, " ")
  15914. // struct4101.AdmTime = time_arr[0]
  15915. // struct4101.AdmEndTime = time_arr[0]
  15916. //
  15917. // struct4101.DoctorName = doctor.UserName
  15918. // struct4101.DoctorCode = doctor.DoctorNumber
  15919. //
  15920. // struct4101.Ntly = "中国"
  15921. // struct4101.AdmCaty = "A03.06"
  15922. // var res ResultSeventeen
  15923. // if miConfig.MdtrtareaAdmvs == "421300" {
  15924. // data := make(map[string]interface{})
  15925. // data["struct4101"] = struct4101
  15926. // data["secret_key"] = miConfig.SecretKey
  15927. // data["org_name"] = miConfig.OrgName
  15928. // data["opera"] = curRoles.UserName
  15929. // data["code"] = miConfig.Code
  15930. // data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  15931. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  15932. //
  15933. // client := &http.Client{}
  15934. // bytesData, _ := json.Marshal(data)
  15935. // req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/4101", bytes.NewReader(bytesData))
  15936. // resp, _ := client.Do(req)
  15937. // defer resp.Body.Close()
  15938. // body, ioErr := ioutil.ReadAll(resp.Body)
  15939. // if ioErr != nil {
  15940. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  15941. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15942. // return
  15943. // }
  15944. // var respJSON map[string]interface{}
  15945. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  15946. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15947. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15948. // return
  15949. // }
  15950. //
  15951. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  15952. // userJSONBytes, _ := json.Marshal(respJSON)
  15953. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  15954. // utils.ErrorLog("解析失败:%v", err)
  15955. // //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15956. // adminUser := c.GetAdminUserInfo()
  15957. // errlog := &models.HisOrderError{
  15958. // UserOrgId: adminUser.CurrentOrgId,
  15959. // Ctime: time.Now().Unix(),
  15960. // Mtime: time.Now().Unix(),
  15961. // ErrMsg: res.ErrMsg + "解析失败",
  15962. // Status: 1,
  15963. // PatientId: order_id,
  15964. // Stage: 10088,
  15965. // }
  15966. // service.CreateErrMsgLog(errlog)
  15967. // continue
  15968. // }
  15969. //
  15970. // } else if miConfig.MdtrtareaAdmvs == "420200" {
  15971. // data := make(map[string]interface{})
  15972. // data["struct4101"] = struct4101
  15973. // data["secret_key"] = miConfig.SecretKey
  15974. // data["org_name"] = miConfig.OrgName
  15975. // data["opera"] = curRoles.UserName
  15976. // data["code"] = miConfig.Code
  15977. // data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  15978. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  15979. //
  15980. // client := &http.Client{}
  15981. // bytesData, _ := json.Marshal(data)
  15982. // req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/4101", bytes.NewReader(bytesData))
  15983. // resp, _ := client.Do(req)
  15984. // defer resp.Body.Close()
  15985. // body, ioErr := ioutil.ReadAll(resp.Body)
  15986. // if ioErr != nil {
  15987. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  15988. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15989. // return
  15990. // }
  15991. // var respJSON map[string]interface{}
  15992. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  15993. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15994. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15995. // return
  15996. // }
  15997. //
  15998. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  15999. // userJSONBytes, _ := json.Marshal(respJSON)
  16000. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  16001. // utils.ErrorLog("解析失败:%v", err)
  16002. // //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16003. // adminUser := c.GetAdminUserInfo()
  16004. // errlog := &models.HisOrderError{
  16005. // UserOrgId: adminUser.CurrentOrgId,
  16006. // Ctime: time.Now().Unix(),
  16007. // Mtime: time.Now().Unix(),
  16008. // ErrMsg: res.ErrMsg + "解析失败",
  16009. // Status: 1,
  16010. // PatientId: order_id,
  16011. // Stage: 10088,
  16012. // }
  16013. // service.CreateErrMsgLog(errlog)
  16014. // continue
  16015. // }
  16016. //
  16017. // } else {
  16018. // result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, c.GetAdminUserInfo().CurrentOrgId)
  16019. // fmt.Println(result)
  16020. //
  16021. // var dat map[string]interface{}
  16022. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  16023. // fmt.Println(dat)
  16024. // } else {
  16025. // fmt.Println(err)
  16026. // }
  16027. // userJSONBytes, _ := json.Marshal(dat)
  16028. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  16029. // utils.ErrorLog("解析失败:%v", err)
  16030. // //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16031. // adminUser := c.GetAdminUserInfo()
  16032. // errlog := &models.HisOrderError{
  16033. // UserOrgId: adminUser.CurrentOrgId,
  16034. // Ctime: time.Now().Unix(),
  16035. // Mtime: time.Now().Unix(),
  16036. // ErrMsg: res.ErrMsg + "解析失败",
  16037. // Status: 1,
  16038. // PatientId: order_id,
  16039. // Stage: 10106,
  16040. // }
  16041. // service.CreateErrMsgLog(errlog)
  16042. // continue
  16043. // }
  16044. // }
  16045. //
  16046. // if res.Infcode != 0 {
  16047. // adminUser := c.GetAdminUserInfo()
  16048. // errlog := &models.HisOrderError{
  16049. // UserOrgId: adminUser.CurrentOrgId,
  16050. // Ctime: time.Now().Unix(),
  16051. // Mtime: time.Now().Unix(),
  16052. // ErrMsg: res.ErrMsg,
  16053. // Status: 1,
  16054. // PatientId: order_id,
  16055. // Stage: 10106,
  16056. // }
  16057. // service.CreateErrMsgLog(errlog)
  16058. // continue
  16059. // } else {
  16060. // hisFundSettleListResult := &models.HisFundSettleListResult{
  16061. // Number: res.Output.SetlListId,
  16062. // Status: 1,
  16063. // Ctime: time.Now().Unix(),
  16064. // Mtime: time.Now().Unix(),
  16065. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  16066. // IsUpload: 1,
  16067. // OrderId: order_id,
  16068. // }
  16069. // service.CreateUploadRecord(hisFundSettleListResult)
  16070. // continue
  16071. // }
  16072. // }
  16073. //}
  16074. func (c *HisApiController) GetOrgInfo() {
  16075. miConfig, _ := service.FindMedicalInsuranceInfo(4)
  16076. service.Gdyb1201("", miConfig.OrgName, "1122", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1, "")
  16077. }
  16078. func (c *HisApiController) GetHisPatientInfo() {
  16079. medical_insurance_card := c.GetString("medical_insurance_card")
  16080. id_card_type, _ := c.GetInt64("id_card_type")
  16081. id_card := c.GetString("id_card")
  16082. adminInfo := c.GetAdminUserInfo()
  16083. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  16084. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  16085. appRole, _ := service.GetAppRole(adminInfo.CurrentOrgId)
  16086. IdCardNo := ""
  16087. if id_card_type == 1 {
  16088. IdCardNo = medical_insurance_card
  16089. } else if id_card_type == 2 {
  16090. IdCardNo = id_card
  16091. }
  16092. if config.IsOpen == 1 {
  16093. 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
  16094. resp, requestErr := http.Get(api)
  16095. if requestErr != nil {
  16096. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16097. return
  16098. }
  16099. defer resp.Body.Close()
  16100. body, ioErr := ioutil.ReadAll(resp.Body)
  16101. if ioErr != nil {
  16102. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  16103. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16104. return
  16105. }
  16106. var respJSON map[string]interface{}
  16107. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  16108. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  16109. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16110. return
  16111. }
  16112. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  16113. userJSONBytes, _ := json.Marshal(userJSON)
  16114. var res ResultTwo
  16115. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  16116. utils.ErrorLog("解析失败:%v", err)
  16117. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16118. return
  16119. }
  16120. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16121. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  16122. infoStr := string(Iinfos)
  16123. idetinfoStr := string(Idetinfos)
  16124. if res.Infcode == 0 {
  16125. his := models.VMHisPatient{
  16126. Status: 1,
  16127. Ctime: time.Now().Unix(),
  16128. Mtime: time.Now().Unix(),
  16129. PsnNo: res.Output.Baseinfo.PsnNo,
  16130. PsnCertType: res.Output.Baseinfo.PsnCertType,
  16131. Certno: res.Output.Baseinfo.Certno,
  16132. PsnName: res.Output.Baseinfo.PsnName,
  16133. Gend: res.Output.Baseinfo.Gend,
  16134. Naty: res.Output.Baseinfo.Naty,
  16135. Iinfo: infoStr,
  16136. Idetinfo: idetinfoStr,
  16137. UserOrgId: adminInfo.CurrentOrgId,
  16138. IsReturn: 1,
  16139. IdCardType: id_card_type,
  16140. }
  16141. c.ServeSuccessJSON(map[string]interface{}{
  16142. "info": his,
  16143. })
  16144. } else {
  16145. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16146. return
  16147. }
  16148. }
  16149. }
  16150. //func GetBasBaseInfo() (jsonStr string, err error) {
  16151. //
  16152. // handle := syscall.NewLazyDLL("SSCard.dll")
  16153. // add := handle.NewProc("ReadCardBas")
  16154. // str := make([]byte, 1024)
  16155. // str1 := make([]byte, 1024)
  16156. // ret, _, _ := add.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  16157. // fmt.Println(ConvertToString(string(str), "gbk", "utf-8"))
  16158. //
  16159. // fmt.Println(ConvertToString(string(str1), "gbk", "utf-8"))
  16160. //
  16161. // fmt.Println("> Add(4,5)的结果为:", ret)
  16162. // handle.Release()
  16163. //
  16164. // return "", nil
  16165. //
  16166. //}
  16167. //func GetQRBaseInfo() (jsonStr string, err error) {
  16168. // handle := syscall.LoadDLL("SSCard.dll")
  16169. // ReadCardBas := handle.FindProc("GetQRBase")
  16170. //
  16171. // str := make([]byte, 256)
  16172. // str1 := make([]byte, 256)
  16173. // r, _, _ := ReadCardBas.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  16174. //
  16175. // fmt.Println(string(str))
  16176. // fmt.Println(r)
  16177. // return string(str), nil
  16178. //}
  16179. //func CardInit() int {
  16180. // DllTestDef := syscall.MustLoadDLL("SSCard.dll")
  16181. // add := DllTestDef.MustFindProc("Init")
  16182. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  16183. // if err != nil {
  16184. // fmt.Println("SSCard的运算结果为:", ret)
  16185. // }
  16186. // result := int(ret)
  16187. // return result
  16188. //}
  16189. //func CardInit() int {
  16190. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  16191. // if err != nil {
  16192. // fmt.Println("SSCard的运算结果为:", ret)
  16193. // }
  16194. // fmt.Println(err)
  16195. // result := int(ret)
  16196. // return result
  16197. //}
  16198. func IntPtr(n int) uintptr {
  16199. return uintptr(n)
  16200. }
  16201. func StrPtr(s string) uintptr {
  16202. return uintptr(unsafe.Pointer(syscall.StringBytePtr(s)))
  16203. }
  16204. type Result2001 struct {
  16205. Cainfo interface{} `json:"cainfo"`
  16206. ErrMsg string `json:"err_msg"`
  16207. InfRefmsgid string `json:"inf_refmsgid"`
  16208. Infcode int64 `json:"infcode"`
  16209. Output struct {
  16210. Trtinfo struct {
  16211. PsnNo string `json:"psn_no"`
  16212. TrtChkType string `json:"trt_chk_type"`
  16213. FundPayType string `json:"fund_pay_type"`
  16214. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  16215. Begndate string `json:"begndate"`
  16216. Enddate string `json:"enddate"`
  16217. TrtChkRslt string `json:"trt_chk_rslt"`
  16218. } `json:"trtinfo"`
  16219. } `json:"output"`
  16220. RefmsgTime string `json:"refmsg_time"`
  16221. RespondTime string `json:"respond_time"`
  16222. Signtype interface{} `json:"signtype"`
  16223. WarnMsg interface{} `json:"warn_msg"`
  16224. }
  16225. type Result2001Org10265 struct {
  16226. Cainfo interface{} `json:"cainfo"`
  16227. ErrMsg string `json:"err_msg"`
  16228. InfRefmsgid string `json:"inf_refmsgid"`
  16229. Infcode string `json:"infcode"`
  16230. Output struct {
  16231. Trtinfo struct {
  16232. PsnNo string `json:"psn_no"`
  16233. TrtChkType string `json:"trt_chk_type"`
  16234. FundPayType string `json:"fund_pay_type"`
  16235. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  16236. Begndate string `json:"begndate"`
  16237. Enddate string `json:"enddate"`
  16238. TrtChkRslt string `json:"trt_chk_rslt"`
  16239. } `json:"trtinfo"`
  16240. } `json:"output"`
  16241. RefmsgTime string `json:"refmsg_time"`
  16242. RespondTime string `json:"respond_time"`
  16243. Signtype interface{} `json:"signtype"`
  16244. WarnMsg interface{} `json:"warn_msg"`
  16245. }
  16246. type ResultTwo struct {
  16247. ErrMsg string `json:"err_msg"`
  16248. InfRefmsgid string `json:"inf_refmsgid"`
  16249. Infcode int64 `json:"infcode"`
  16250. Output struct {
  16251. Baseinfo struct {
  16252. //Brdy string `json:"brdy"`
  16253. Certno string `json:"certno"`
  16254. Gend string `json:"gend"`
  16255. Naty string `json:"naty"`
  16256. PsnCertType string `json:"psn_cert_type"`
  16257. PsnName string `json:"psn_name"`
  16258. PsnNo string `json:"psn_no"`
  16259. } `json:"baseinfo"`
  16260. Idetinfo []interface{} `json:"idetinfo"`
  16261. Iinfo []struct {
  16262. Balc float64 `json:"balc"`
  16263. CvlservFlag string `json:"cvlserv_flag"`
  16264. EmpName string `json:"emp_name"`
  16265. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  16266. Insutype string `json:"insutype"`
  16267. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  16268. //PausInsuDate string `json:"paus_insu_date"`
  16269. //PsnInsuDate string `json:"psn_insu_date"`
  16270. PsnInsuStas string `json:"psn_insu_stas"`
  16271. PsnType string `json:"psn_type"`
  16272. } `json:"insuinfo"`
  16273. } `json:"output"`
  16274. RefmsgTime string `json:"refmsg_time"`
  16275. RespondTime string `json:"respond_time"`
  16276. Signtype interface{} `json:"signtype"`
  16277. WarnInfo interface{} `json:"warn_info"`
  16278. }
  16279. type ResultTwo10265 struct {
  16280. ErrMsg string `json:"err_msg"`
  16281. InfRefmsgid string `json:"inf_refmsgid"`
  16282. Infcode string `json:"infcode"`
  16283. Output struct {
  16284. Baseinfo struct {
  16285. //Brdy string `json:"brdy"`
  16286. Certno string `json:"certno"`
  16287. Gend string `json:"gend"`
  16288. Naty string `json:"naty"`
  16289. PsnCertType string `json:"psn_cert_type"`
  16290. PsnName string `json:"psn_name"`
  16291. PsnNo string `json:"psn_no"`
  16292. } `json:"baseinfo"`
  16293. Idetinfo []interface{} `json:"idetinfo"`
  16294. Iinfo []struct {
  16295. Balc float64 `json:"balc"`
  16296. CvlservFlag string `json:"cvlserv_flag"`
  16297. EmpName string `json:"emp_name"`
  16298. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  16299. Insutype string `json:"insutype"`
  16300. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  16301. PsnInsuStas string `json:"psn_insu_stas"`
  16302. PsnType string `json:"psn_type"`
  16303. } `json:"insuinfo"`
  16304. } `json:"output"`
  16305. RefmsgTime string `json:"refmsg_time"`
  16306. RespondTime string `json:"respond_time"`
  16307. Signtype interface{} `json:"signtype"`
  16308. WarnInfo interface{} `json:"warn_info"`
  16309. }
  16310. type ResultThree struct {
  16311. Cainfo interface{} `json:"cainfo"`
  16312. ErrMsg string `json:"err_msg"`
  16313. InfRefmsgid string `json:"inf_refmsgid"`
  16314. Infcode int64 `json:"infcode"`
  16315. Output struct {
  16316. Data struct {
  16317. IptOtpNo string `json:"ipt_otp_no"`
  16318. MdtrtID string `json:"mdtrt_id"`
  16319. PsnNo string `json:"psn_no"`
  16320. } `json:"data"`
  16321. } `json:"output"`
  16322. RefmsgTime string `json:"refmsg_time"`
  16323. RespondTime string `json:"respond_time"`
  16324. Signtype interface{} `json:"signtype"`
  16325. WarnMsg interface{} `json:"warn_msg"`
  16326. }
  16327. type ResultThree10265 struct {
  16328. Cainfo interface{} `json:"cainfo"`
  16329. ErrMsg string `json:"err_msg"`
  16330. InfRefmsgid string `json:"inf_refmsgid"`
  16331. Infcode string `json:"infcode"`
  16332. Output struct {
  16333. Data struct {
  16334. IptOtpNo string `json:"ipt_otp_no"`
  16335. MdtrtID string `json:"mdtrt_id"`
  16336. PsnNo string `json:"psn_no"`
  16337. } `json:"data"`
  16338. } `json:"output"`
  16339. RefmsgTime string `json:"refmsg_time"`
  16340. RespondTime string `json:"respond_time"`
  16341. Signtype interface{} `json:"signtype"`
  16342. WarnMsg interface{} `json:"warn_msg"`
  16343. }
  16344. type ResultFour struct {
  16345. Cainfo string `json:"cainfo"`
  16346. ErrMsg string `json:"err_msg"`
  16347. InfRefmsgid string `json:"inf_refmsgid"`
  16348. Infcode int64 `json:"infcode"`
  16349. Output struct {
  16350. Result []struct {
  16351. BasMednFlag string `json:"bas_medn_flag"`
  16352. ChldMedcFlag string `json:"chld_medc_flag"`
  16353. ChrgitmLv string `json:"chrgitm_lv"`
  16354. Cnt float64 `json:"cnt"`
  16355. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  16356. DrtReimFlag string `json:"drt_reim_flag"`
  16357. FeedetlSn string `json:"feedetl_sn"`
  16358. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  16359. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  16360. InscpScpAmt float64 `json:"inscp_scp_amt"`
  16361. ListSpItemFlag string `json:"list_sp_item_flag"`
  16362. LmtUsedFlag string `json:"lmt_used_flag"`
  16363. MedChrgitmType string `json:"med_chrgitm_type"`
  16364. Memo string `json:"memo"`
  16365. OverlmtAmt float64 `json:"overlmt_amt"`
  16366. PreselfpayAmt float64 `json:"preselfpay_amt"`
  16367. Pric float64 `json:"pric"`
  16368. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  16369. SelfpayProp float64 `json:"selfpay_prop"`
  16370. } `json:"result"`
  16371. } `json:"output"`
  16372. RefmsgTime string `json:"refmsg_time"`
  16373. RespondTime string `json:"respond_time"`
  16374. Signtype string `json:"signtype"`
  16375. WarnMsg string `json:"warn_msg"`
  16376. }
  16377. type ResultFour10265 struct {
  16378. Cainfo string `json:"cainfo"`
  16379. ErrMsg string `json:"err_msg"`
  16380. InfRefmsgid string `json:"inf_refmsgid"`
  16381. Infcode string `json:"infcode"`
  16382. Output struct {
  16383. Result []struct {
  16384. BasMednFlag string `json:"bas_medn_flag"`
  16385. ChldMedcFlag string `json:"chld_medc_flag"`
  16386. ChrgitmLv string `json:"chrgitm_lv"`
  16387. Cnt float64 `json:"cnt"`
  16388. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  16389. DrtReimFlag string `json:"drt_reim_flag"`
  16390. FeedetlSn string `json:"feedetl_sn"`
  16391. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  16392. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  16393. InscpScpAmt float64 `json:"inscp_scp_amt"`
  16394. ListSpItemFlag string `json:"list_sp_item_flag"`
  16395. LmtUsedFlag string `json:"lmt_used_flag"`
  16396. MedChrgitmType string `json:"med_chrgitm_type"`
  16397. Memo string `json:"memo"`
  16398. OverlmtAmt float64 `json:"overlmt_amt"`
  16399. PreselfpayAmt float64 `json:"preselfpay_amt"`
  16400. Pric float64 `json:"pric"`
  16401. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  16402. SelfpayProp float64 `json:"selfpay_prop"`
  16403. } `json:"result"`
  16404. } `json:"output"`
  16405. RefmsgTime string `json:"refmsg_time"`
  16406. RespondTime string `json:"respond_time"`
  16407. Signtype string `json:"signtype"`
  16408. WarnMsg string `json:"warn_msg"`
  16409. }
  16410. type ResultMemo struct {
  16411. InsuAdmdvs string `json:"insuAdmdvs"`
  16412. }
  16413. // [{"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}]
  16414. type ResultIDInfo struct {
  16415. Begntime string `json:"begntime"`
  16416. Endtime string `json:"endtime"`
  16417. Memo string `json:"memo"`
  16418. }
  16419. type ResultFive struct {
  16420. Balc float64 `json:"balc"`
  16421. CvlservFlag string `json:"cvlserv_flag"`
  16422. EmpName string `json:"emp_name"`
  16423. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  16424. Insutype string `json:"insutype"`
  16425. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  16426. PausInsuDate string `json:"paus_insu_date"`
  16427. PsnInsuDate string `json:"psn_insu_date"`
  16428. PsnInsuStas string `json:"psn_insu_stas"`
  16429. PsnType string `json:"psn_type"`
  16430. }
  16431. type ResultSix struct {
  16432. Cainfo interface{} `json:"cainfo"`
  16433. ErrMsg string `json:"err_msg"`
  16434. InfRefmsgid string `json:"inf_refmsgid"`
  16435. Infcode int64 `json:"infcode"`
  16436. Output struct {
  16437. } `json:"output"`
  16438. RefmsgTime string `json:"refmsg_time"`
  16439. RespondTime string `json:"respond_time"`
  16440. Signtype interface{} `json:"signtype"`
  16441. WarnMsg interface{} `json:"warn_msg"`
  16442. }
  16443. type FJ3507Result struct {
  16444. Cainfo interface{} `json:"cainfo"`
  16445. ErrMsg string `json:"err_msg"`
  16446. InfRefmsgid string `json:"inf_refmsgid"`
  16447. Infcode int64 `json:"infcode"`
  16448. Output struct {
  16449. retRslt string `json:"retRslt"`
  16450. msgRslt string `json:"msgRslt"`
  16451. } `json:"output"`
  16452. RefmsgTime string `json:"refmsg_time"`
  16453. RespondTime string `json:"respond_time"`
  16454. Signtype interface{} `json:"signtype"`
  16455. WarnMsg interface{} `json:"warn_msg"`
  16456. }
  16457. type Result2406 struct {
  16458. Cainfo interface{} `json:"cainfo"`
  16459. ErrMsg string `json:"err_msg"`
  16460. InfRefmsgid string `json:"inf_refmsgid"`
  16461. Infcode int64 `json:"infcode"`
  16462. Output struct {
  16463. Result struct {
  16464. IptPsnSpFlagDetlId string `json:"ipt_psn_sp_flag_detl_id"`
  16465. } `json:"result"`
  16466. } `json:"output"`
  16467. RefmsgTime string `json:"refmsg_time"`
  16468. RespondTime string `json:"respond_time"`
  16469. Signtype interface{} `json:"signtype"`
  16470. WarnMsg interface{} `json:"warn_msg"`
  16471. }
  16472. type GZResultSix struct {
  16473. Cainfo interface{} `json:"cainfo"`
  16474. ErrMsg string `json:"err_msg"`
  16475. InfRefmsgid string `json:"inf_refmsgid"`
  16476. Infcode int64 `json:"infcode"`
  16477. Output string `json:"output"`
  16478. RefmsgTime string `json:"refmsg_time"`
  16479. RespondTime string `json:"respond_time"`
  16480. Signtype interface{} `json:"signtype"`
  16481. WarnMsg interface{} `json:"warn_msg"`
  16482. }
  16483. type ResultSix10265 struct {
  16484. Cainfo interface{} `json:"cainfo"`
  16485. ErrMsg string `json:"err_msg"`
  16486. InfRefmsgid string `json:"inf_refmsgid"`
  16487. Infcode string `json:"infcode"`
  16488. Output struct {
  16489. } `json:"output"`
  16490. RefmsgTime string `json:"refmsg_time"`
  16491. RespondTime string `json:"respond_time"`
  16492. Signtype interface{} `json:"signtype"`
  16493. WarnMsg interface{} `json:"warn_msg"`
  16494. }
  16495. type ResultSeven struct {
  16496. Cainfo string `json:"cainfo"`
  16497. ErrMsg string `json:"err_msg"`
  16498. InfRefmsgid string `json:"inf_refmsgid"`
  16499. Infcode int64 `json:"infcode"`
  16500. Output struct {
  16501. Setlinfo struct {
  16502. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  16503. AcctPay float64 `json:"acct_pay"`
  16504. ActPayDedc float64 `json:"act_pay_dedc"`
  16505. Age float64 `json:"age"`
  16506. Balc float64 `json:"balc"`
  16507. Certno string `json:"certno"`
  16508. ClrOptins string `json:"clr_optins"`
  16509. ClrType string `json:"clr_type"`
  16510. ClrWay string `json:"clr_way"`
  16511. CvlservFlag string `json:"cvlserv_flag"`
  16512. CvlservPay float64 `json:"cvlserv_pay"`
  16513. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  16514. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  16515. Gend string `json:"gend"`
  16516. HifesPay float64 `json:"hifes_pay"`
  16517. HifmiPay float64 `json:"hifmi_pay"`
  16518. HifpPay float64 `json:"hifp_pay"`
  16519. HospPartAmt float64 `json:"hosp_part_amt"`
  16520. InscpScpAmt float64 `json:"inscp_scp_amt"`
  16521. Insutype string `json:"insutype"`
  16522. MafPay float64 `json:"maf_pay"`
  16523. MdtrtCertType string `json:"mdtrt_cert_type"`
  16524. HifobPay float64 `json:"hifob_pay"`
  16525. MdtrtID string `json:"mdtrt_id"`
  16526. MedType string `json:"med_type"`
  16527. MedfeeSumamt float64 `json:"medfee_sumamt"`
  16528. MedinsSetlID string `json:"medins_setl_id"`
  16529. Naty string `json:"naty"`
  16530. OthPay float64 `json:"oth_pay"`
  16531. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  16532. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  16533. PreselfpayAmt float64 `json:"preselfpay_amt"`
  16534. PsnCashPay float64 `json:"psn_cash_pay"`
  16535. PsnCertType string `json:"psn_cert_type"`
  16536. PsnName string `json:"psn_name"`
  16537. PsnNo string `json:"psn_no"`
  16538. PsnPartAmt float64 `json:"psn_part_amt"`
  16539. PsnType string `json:"psn_type"`
  16540. SetlID string `json:"setl_id"`
  16541. SetlTime string `json:"setl_time"`
  16542. } `json:"setlinfo"`
  16543. Setldetail interface{} `json:"setldetail"`
  16544. } `json:"output"`
  16545. RefmsgTime string `json:"refmsg_time"`
  16546. RespondTime string `json:"respond_time"`
  16547. Signtype interface{} `json:"signtype"`
  16548. WarnMsg interface{} `json:"warn_msg"`
  16549. }
  16550. type ResultSevenAH struct {
  16551. Cainfo string `json:"cainfo"`
  16552. ErrMsg string `json:"err_msg"`
  16553. InfRefmsgid string `json:"inf_refmsgid"`
  16554. Infcode int64 `json:"infcode"`
  16555. Output struct {
  16556. Setlinfo struct {
  16557. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  16558. AcctPay float64 `json:"acct_pay"`
  16559. ActPayDedc float64 `json:"act_pay_dedc"`
  16560. Age float64 `json:"age"`
  16561. Balc float64 `json:"balc"`
  16562. Certno string `json:"certno"`
  16563. ClrOptins string `json:"clr_optins"`
  16564. ClrType string `json:"clr_type"`
  16565. ClrWay string `json:"clr_way"`
  16566. CvlservFlag string `json:"cvlserv_flag"`
  16567. CvlservPay float64 `json:"cvlserv_pay"`
  16568. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  16569. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  16570. Gend string `json:"gend"`
  16571. HifesPay float64 `json:"hifes_pay"`
  16572. HifmiPay float64 `json:"hifmi_pay"`
  16573. HifpPay float64 `json:"hifp_pay"`
  16574. HospPartAmt float64 `json:"hosp_part_amt"`
  16575. InscpScpAmt float64 `json:"inscp_scp_amt"`
  16576. Insutype string `json:"insutype"`
  16577. MafPay float64 `json:"maf_pay"`
  16578. MdtrtCertType string `json:"mdtrt_cert_type"`
  16579. HifobPay float64 `json:"hifob_pay"`
  16580. MdtrtID string `json:"mdtrt_id"`
  16581. MedType string `json:"med_type"`
  16582. MedfeeSumamt float64 `json:"medfee_sumamt"`
  16583. MedinsSetlID string `json:"medins_setl_id"`
  16584. Naty string `json:"naty"`
  16585. OthPay float64 `json:"oth_pay"`
  16586. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  16587. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  16588. PreselfpayAmt float64 `json:"preselfpay_amt"`
  16589. PsnCashPay float64 `json:"psn_cash_pay"`
  16590. PsnCertType string `json:"psn_cert_type"`
  16591. PsnName string `json:"psn_name"`
  16592. PsnNo string `json:"psn_no"`
  16593. PsnPartAmt float64 `json:"psn_part_amt"`
  16594. PsnType string `json:"psn_type"`
  16595. SetlID string `json:"setl_id"`
  16596. SetlTime int64 `json:"setl_time"`
  16597. } `json:"setlinfo"`
  16598. Setldetail interface{} `json:"setldetail"`
  16599. } `json:"output"`
  16600. RefmsgTime string `json:"refmsg_time"`
  16601. RespondTime string `json:"respond_time"`
  16602. Signtype interface{} `json:"signtype"`
  16603. WarnMsg interface{} `json:"warn_msg"`
  16604. }
  16605. type ResultSeven10265 struct {
  16606. Cainfo string `json:"cainfo"`
  16607. ErrMsg string `json:"err_msg"`
  16608. InfRefmsgid string `json:"inf_refmsgid"`
  16609. Infcode string `json:"infcode"`
  16610. Output struct {
  16611. Setlinfo struct {
  16612. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  16613. AcctPay float64 `json:"acct_pay"`
  16614. ActPayDedc float64 `json:"act_pay_dedc"`
  16615. Age float64 `json:"age"`
  16616. Balc float64 `json:"balc"`
  16617. Certno string `json:"certno"`
  16618. ClrOptins string `json:"clr_optins"`
  16619. ClrType string `json:"clr_type"`
  16620. ClrWay string `json:"clr_way"`
  16621. CvlservFlag string `json:"cvlserv_flag"`
  16622. CvlservPay float64 `json:"cvlserv_pay"`
  16623. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  16624. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  16625. Gend string `json:"gend"`
  16626. HifesPay float64 `json:"hifes_pay"`
  16627. HifmiPay float64 `json:"hifmi_pay"`
  16628. HifpPay float64 `json:"hifp_pay"`
  16629. HospPartAmt float64 `json:"hosp_part_amt"`
  16630. InscpScpAmt float64 `json:"inscp_scp_amt"`
  16631. Insutype string `json:"insutype"`
  16632. MafPay float64 `json:"maf_pay"`
  16633. MdtrtCertType string `json:"mdtrt_cert_type"`
  16634. HifobPay float64 `json:"hifob_pay"`
  16635. MdtrtID string `json:"mdtrt_id"`
  16636. MedType string `json:"med_type"`
  16637. MedfeeSumamt float64 `json:"medfee_sumamt"`
  16638. MedinsSetlID string `json:"medins_setl_id"`
  16639. Naty string `json:"naty"`
  16640. OthPay float64 `json:"oth_pay"`
  16641. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  16642. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  16643. PreselfpayAmt float64 `json:"preselfpay_amt"`
  16644. PsnCashPay float64 `json:"psn_cash_pay"`
  16645. PsnCertType string `json:"psn_cert_type"`
  16646. PsnName string `json:"psn_name"`
  16647. PsnNo string `json:"psn_no"`
  16648. PsnPartAmt float64 `json:"psn_part_amt"`
  16649. PsnType string `json:"psn_type"`
  16650. SetlID string `json:"setl_id"`
  16651. SetlTime string `json:"setl_time"`
  16652. } `json:"setlinfo"`
  16653. Setldetail interface{} `json:"setldetail"`
  16654. } `json:"output"`
  16655. RefmsgTime string `json:"refmsg_time"`
  16656. RespondTime string `json:"respond_time"`
  16657. Signtype interface{} `json:"signtype"`
  16658. WarnMsg interface{} `json:"warn_msg"`
  16659. }
  16660. type ResultSeven10265Two struct {
  16661. Cainfo string `json:"cainfo"`
  16662. ErrMsg string `json:"err_msg"`
  16663. InfRefmsgid string `json:"inf_refmsgid"`
  16664. Infcode string `json:"infcode"`
  16665. Output struct {
  16666. Setlinfo struct {
  16667. AcctMulaidPay string `json:"acct_mulaid_pay"`
  16668. AcctPay float64 `json:"acct_pay"`
  16669. ActPayDedc float64 `json:"act_pay_dedc"`
  16670. Age float64 `json:"age"`
  16671. Balc float64 `json:"balc"`
  16672. Certno string `json:"certno"`
  16673. ClrOptins string `json:"clr_optins"`
  16674. ClrType string `json:"clr_type"`
  16675. ClrWay string `json:"clr_way"`
  16676. CvlservFlag string `json:"cvlserv_flag"`
  16677. CvlservPay float64 `json:"cvlserv_pay"`
  16678. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  16679. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  16680. Gend string `json:"gend"`
  16681. HifesPay float64 `json:"hifes_pay"`
  16682. HifmiPay float64 `json:"hifmi_pay"`
  16683. HifpPay float64 `json:"hifp_pay"`
  16684. HospPartAmt string `json:"hosp_part_amt"`
  16685. InscpScpAmt float64 `json:"inscp_scp_amt"`
  16686. Insutype string `json:"insutype"`
  16687. MafPay float64 `json:"maf_pay"`
  16688. MdtrtCertType string `json:"mdtrt_cert_type"`
  16689. HifobPay float64 `json:"hifob_pay"`
  16690. MdtrtID string `json:"mdtrt_id"`
  16691. MedType string `json:"med_type"`
  16692. MedfeeSumamt float64 `json:"medfee_sumamt"`
  16693. MedinsSetlID string `json:"medins_setl_id"`
  16694. Naty string `json:"naty"`
  16695. OthPay float64 `json:"oth_pay"`
  16696. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  16697. PoolPropSelfpay string `json:"pool_prop_selfpay"`
  16698. PreselfpayAmt float64 `json:"preselfpay_amt"`
  16699. PsnCashPay float64 `json:"psn_cash_pay"`
  16700. PsnCertType string `json:"psn_cert_type"`
  16701. PsnName string `json:"psn_name"`
  16702. PsnNo string `json:"psn_no"`
  16703. PsnPartAmt float64 `json:"psn_part_amt"`
  16704. PsnType string `json:"psn_type"`
  16705. SetlID string `json:"setl_id"`
  16706. SetlTime string `json:"setl_time"`
  16707. } `json:"setlinfo"`
  16708. Setldetail interface{} `json:"setldetail"`
  16709. } `json:"output"`
  16710. RefmsgTime string `json:"refmsg_time"`
  16711. RespondTime string `json:"respond_time"`
  16712. Signtype interface{} `json:"signtype"`
  16713. WarnMsg interface{} `json:"warn_msg"`
  16714. }
  16715. type GZResultSeven10265Two struct {
  16716. Cainfo string `json:"cainfo"`
  16717. ErrMsg string `json:"err_msg"`
  16718. InfRefmsgid string `json:"inf_refmsgid"`
  16719. Infcode int64 `json:"infcode"`
  16720. Output struct {
  16721. Setlinfo struct {
  16722. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  16723. AcctPay float64 `json:"acct_pay"`
  16724. ActPayDedc float64 `json:"act_pay_dedc"`
  16725. Age float64 `json:"age"`
  16726. Balc float64 `json:"balc"`
  16727. Certno string `json:"certno"`
  16728. ClrOptins string `json:"clr_optins"`
  16729. ClrType string `json:"clr_type"`
  16730. ClrWay string `json:"clr_way"`
  16731. CvlservFlag string `json:"cvlserv_flag"`
  16732. CvlservPay float64 `json:"cvlserv_pay"`
  16733. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  16734. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  16735. Gend string `json:"gend"`
  16736. HifesPay float64 `json:"hifes_pay"`
  16737. HifmiPay float64 `json:"hifmi_pay"`
  16738. HifpPay float64 `json:"hifp_pay"`
  16739. HospPartAmt float64 `json:"hosp_part_amt"`
  16740. InscpScpAmt float64 `json:"inscp_scp_amt"`
  16741. Insutype string `json:"insutype"`
  16742. MafPay float64 `json:"maf_pay"`
  16743. MdtrtCertType string `json:"mdtrt_cert_type"`
  16744. HifobPay float64 `json:"hifob_pay"`
  16745. MdtrtID string `json:"mdtrt_id"`
  16746. MedType string `json:"med_type"`
  16747. MedfeeSumamt float64 `json:"medfee_sumamt"`
  16748. MedinsSetlID string `json:"medins_setl_id"`
  16749. Naty string `json:"naty"`
  16750. OthPay float64 `json:"oth_pay"`
  16751. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  16752. PoolPropSelfpay string `json:"pool_prop_selfpay"`
  16753. PreselfpayAmt float64 `json:"preselfpay_amt"`
  16754. PsnCashPay float64 `json:"psn_cash_pay"`
  16755. PsnCertType string `json:"psn_cert_type"`
  16756. PsnName string `json:"psn_name"`
  16757. PsnNo string `json:"psn_no"`
  16758. PsnPartAmt float64 `json:"psn_part_amt"`
  16759. PsnType string `json:"psn_type"`
  16760. SetlID string `json:"setl_id"`
  16761. SetlTime string `json:"setl_time"`
  16762. } `json:"setlinfo"`
  16763. Setldetail interface{} `json:"setldetail"`
  16764. } `json:"output"`
  16765. RefmsgTime string `json:"refmsg_time"`
  16766. RespondTime string `json:"respond_time"`
  16767. Signtype interface{} `json:"signtype"`
  16768. WarnMsg interface{} `json:"warn_msg"`
  16769. }
  16770. type ResultEight struct {
  16771. Cainfo string `json:"cainfo"`
  16772. ErrMsg string `json:"err_msg"`
  16773. InfRefmsgid string `json:"inf_refmsgid"`
  16774. Infcode int64 `json:"infcode"`
  16775. Output struct {
  16776. Stmtinfo struct {
  16777. SetlOptins string `json:"setl_optins"`
  16778. StmtRslt string `json:"stmt_rslt"`
  16779. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  16780. } `json:"stmtinfo"`
  16781. } `json:"output"`
  16782. RefmsgTime string `json:"refmsg_time"`
  16783. RespondTime string `json:"respond_time"`
  16784. Signtype interface{} `json:"signtype"`
  16785. WarnMsg interface{} `json:"warn_msg"`
  16786. }
  16787. type ResultEightFor10188 struct {
  16788. Cainfo string `json:"cainfo"`
  16789. ErrMsg string `json:"err_msg"`
  16790. InfRefmsgid string `json:"inf_refmsgid"`
  16791. Infcode string `json:"infcode"`
  16792. Output struct {
  16793. Stmtinfo struct {
  16794. SetlOptins string `json:"setl_optins"`
  16795. StmtRslt string `json:"stmt_rslt"`
  16796. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  16797. } `json:"stmtinfo"`
  16798. } `json:"output"`
  16799. RefmsgTime string `json:"refmsg_time"`
  16800. RespondTime string `json:"respond_time"`
  16801. Signtype interface{} `json:"signtype"`
  16802. WarnMsg interface{} `json:"warn_msg"`
  16803. }
  16804. type ResultNine struct {
  16805. Cainfo string `json:"cainfo"`
  16806. ErrMsg string `json:"err_msg"`
  16807. InfRefmsgid string `json:"inf_refmsgid"`
  16808. Infcode int64 `json:"infcode"`
  16809. Output struct {
  16810. FileQuryNo string `json:"file_qury_no"`
  16811. } `json:"output"`
  16812. RefmsgTime string `json:"refmsg_time"`
  16813. RespondTime string `json:"respond_time"`
  16814. Signtype interface{} `json:"signtype"`
  16815. WarnMsg interface{} `json:"warn_msg"`
  16816. }
  16817. type ResultTen struct {
  16818. Cainfo string `json:"cainfo"`
  16819. ErrMsg string `json:"err_msg"`
  16820. InfRefmsgid string `json:"inf_refmsgid"`
  16821. Infcode int64 `json:"infcode"`
  16822. Output struct {
  16823. Fileinfo struct {
  16824. DldEndtime string `json:"dld_endtime"`
  16825. FileQuryNo string `json:"file_qury_no"`
  16826. Filename string `json:"filename"`
  16827. } `json:"fileinfo"`
  16828. } `json:"output"`
  16829. RefmsgTime string `json:"refmsg_time"`
  16830. RespondTime string `json:"respond_time"`
  16831. Signtype interface{} `json:"signtype"`
  16832. WarnMsg interface{} `json:"warn_msg"`
  16833. }
  16834. type Result5262 struct {
  16835. ErrMsg string `json:"err_msg"`
  16836. InfRefmsgid string `json:"inf_refmsgid"`
  16837. Infcode int64 `json:"infcode"`
  16838. Output struct {
  16839. PageInfo struct {
  16840. Size int `json:"size"`
  16841. RecordCounts int `json:"record_counts"`
  16842. } `json:"page_info"`
  16843. Idetinfo []interface{} `json:"idetinfo"`
  16844. Result []struct {
  16845. SetlID string `json:"setl_id"`
  16846. MedinsSetlID string `json:"medins_setl_id,omitempty"`
  16847. MdtrtID string `json:"mdtrt_id"`
  16848. InitSetlID string `json:"init_setl_id,omitempty"`
  16849. PsnNo string `json:"psn_no"`
  16850. PsnInsuRltsID string `json:"psn_insu_rlts_id,omitempty"`
  16851. PsnName string `json:"psn_name"`
  16852. PsnCertType string `json:"psn_cert_type"`
  16853. Certno string `json:"certno"`
  16854. Gend string `json:"gend,omitempty"`
  16855. Naty string `json:"naty,omitempty"`
  16856. Brdy string `json:"brdy,omitempty"`
  16857. Age float64 `json:"age,omitempty"`
  16858. Insutype string `json:"insutype,omitempty"`
  16859. PsnType string `json:"psn_type"`
  16860. CvlservFlag string `json:"cvlserv_flag"`
  16861. CvlservLv string `json:"cvlserv_lv,omitempty"`
  16862. SpPsnType string `json:"sp_psn_type,omitempty"`
  16863. SpPsnTypeLv string `json:"sp_psn_type_lv,omitempty"`
  16864. ClctGrde string `json:"clct_grde,omitempty"`
  16865. FlxempeFlag string `json:"flxempe_flag,omitempty"`
  16866. NwbFlag string `json:"nwb_flag,omitempty"`
  16867. InsuAdmdvs string `json:"insu_admdvs"`
  16868. EmpNo string `json:"emp_no,omitempty"`
  16869. EmpName string `json:"emp_name,omitempty"`
  16870. EmpType string `json:"emp_type,omitempty"`
  16871. EconType string `json:"econ_type,omitempty"`
  16872. AfilIndu string `json:"afil_indu,omitempty"`
  16873. AfilRlts string `json:"afil_rlts,omitempty"`
  16874. EmpMgtType string `json:"emp_mgt_type,omitempty"`
  16875. PayLoc string `json:"pay_loc,omitempty"`
  16876. FixmedinsCode string `json:"fixmedins_code"`
  16877. FixmedinsName string `json:"fixmedins_name"`
  16878. HospLv string `json:"hosp_lv,omitempty"`
  16879. FixBlngAdmdvs string `json:"fix_blng_admdvs,omitempty"`
  16880. LmtpricHospLv string `json:"lmtpric_hosp_lv,omitempty"`
  16881. DedcHospLv string `json:"dedc_hosp_lv,omitempty"`
  16882. Begndate string `json:"begndate"`
  16883. Enddate string `json:"enddate"`
  16884. SetlTime string `json:"setl_time"`
  16885. MdtrtCertType string `json:"mdtrt_cert_type,omitempty"`
  16886. MdtrtCertNo string `json:"mdtrt_cert_no,omitempty"`
  16887. MedType string `json:"med_type"`
  16888. SetlType string `json:"setl_type,omitempty"`
  16889. ClrType string `json:"clr_type,omitempty"`
  16890. ClrWay string `json:"clr_way,omitempty"`
  16891. PsnSetlway string `json:"psn_setlway,omitempty"`
  16892. ClrOptins string `json:"clr_optins,omitempty"`
  16893. MedfeeSumamt float64 `json:"medfee_sumamt,omitempty"`
  16894. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt,omitempty"`
  16895. OverlmtSelfpay float64 `json:"overlmt_selfpay,omitempty"`
  16896. PreselfpayAmt float64 `json:"preselfpay_amt,omitempty"`
  16897. InscpAmt float64 `json:"inscp_amt,omitempty"`
  16898. DedcStd float64 `json:"dedc_std,omitempty"`
  16899. CrtDedc float64 `json:"crt_dedc,omitempty"`
  16900. ActPayDedc float64 `json:"act_pay_dedc,omitempty"`
  16901. HifpPay float64 `json:"hifp_pay,omitempty"`
  16902. PoolPropSelfpay float64 `json:"pool_prop_selfpay,omitempty"`
  16903. HiAgreSumfee float64 `json:"hi_agre_sumfee,omitempty"`
  16904. CvlservPay float64 `json:"cvlserv_pay,omitempty"`
  16905. HifesPay float64 `json:"hifes_pay,omitempty"`
  16906. HifmiPay float64 `json:"hifmi_pay,omitempty"`
  16907. HifobPay float64 `json:"hifob_pay,omitempty"`
  16908. HifdmPay float64 `json:"hifdm_pay,omitempty"`
  16909. MafPay float64 `json:"maf_pay,omitempty"`
  16910. OthfundPay float64 `json:"othfund_pay,omitempty"`
  16911. FundPaySumamt float64 `json:"fund_pay_sumamt,omitempty"`
  16912. PsnPay float64 `json:"psn_pay,omitempty"`
  16913. AcctPay float64 `json:"acct_pay,omitempty"`
  16914. CashPayamt float64 `json:"cash_payamt,omitempty"`
  16915. OwnpayHospPart float64 `json:"ownpay_hosp_part,omitempty"`
  16916. Balc float64 `json:"balc,omitempty"`
  16917. AcctMulaidPay float64 `json:"acct_mulaid_pay,omitempty"`
  16918. RefdSetlFlag string `json:"refd_setl_flag,omitempty"`
  16919. CalIptCnt string `json:"cal_ipt_cnt,omitempty"`
  16920. SetlCashpayWay string `json:"setl_cashpay_way,omitempty"`
  16921. Year string `json:"year,omitempty"`
  16922. DiseNo string `json:"dise_no,omitempty"`
  16923. DiseName string `json:"dise_name,omitempty"`
  16924. Invono string `json:"invono,omitempty"`
  16925. ManlReimRea string `json:"manl_reim_rea,omitempty"`
  16926. ValiFlag string `json:"vali_flag,omitempty"`
  16927. Memo string `json:"memo,omitempty"`
  16928. Rid string `json:"rid"`
  16929. UpdtTime string `json:"updt_time,omitempty"`
  16930. CrterID string `json:"crter_id,omitempty"`
  16931. CrterName string `json:"crter_name,omitempty"`
  16932. CrteTime string `json:"crte_time,omitempty"`
  16933. CrteOptinsNo string `json:"crte_optins_no,omitempty"`
  16934. OpterID string `json:"opter_id,omitempty"`
  16935. OpterName string `json:"opter_name,omitempty"`
  16936. OptTime string `json:"opt_time,omitempty"`
  16937. OptinsNo string `json:"optins_no,omitempty"`
  16938. PoolareaNo string `json:"poolarea_no,omitempty"`
  16939. } `json:"result"`
  16940. } `json:"output"`
  16941. RefmsgTime string `json:"refmsg_time"`
  16942. RespondTime string `json:"respond_time"`
  16943. Signtype interface{} `json:"signtype"`
  16944. WarnInfo interface{} `json:"warn_info"`
  16945. }
  16946. type Result5267 struct {
  16947. ErrMsg string `json:"err_msg"`
  16948. InfRefmsgid string `json:"inf_refmsgid"`
  16949. Infcode int64 `json:"infcode"`
  16950. Output struct {
  16951. PageInfo struct {
  16952. Size int `json:"size"`
  16953. RecordCounts int `json:"record_counts"`
  16954. } `json:"pageinfo"`
  16955. Result []struct {
  16956. SetlID string `json:"setl_id"`
  16957. ClrOptins string `json:"clr_optins"`
  16958. MedinsSetlID string `json:"medins_setl_id,omitempty"`
  16959. MdtrtID string `json:"mdtrt_id"`
  16960. InitSetlID string `json:"init_setl_id,omitempty"`
  16961. PsnNo string `json:"psn_no"`
  16962. PsnInsuRltsID string `json:"psn_insu_rlts_id,omitempty"`
  16963. PsnName string `json:"psn_name"`
  16964. PsnCertType string `json:"psn_cert_type"`
  16965. Certno string `json:"certno"`
  16966. Gend string `json:"gend,omitempty"`
  16967. Naty string `json:"naty,omitempty"`
  16968. Brdy string `json:"brdy,omitempty"`
  16969. Age float64 `json:"age,omitempty"`
  16970. Insutype string `json:"insutype,omitempty"`
  16971. PsnType string `json:"psn_type"`
  16972. CvlservFlag string `json:"cvlserv_flag"`
  16973. CvlservLv string `json:"cvlserv_lv,omitempty"`
  16974. SpPsnType string `json:"sp_psn_type,omitempty"`
  16975. SpPsnTypeLv string `json:"sp_psn_type_lv,omitempty"`
  16976. ClctGrde string `json:"clct_grde,omitempty"`
  16977. FlxempeFlag string `json:"flxempe_flag,omitempty"`
  16978. NwbFlag string `json:"nwb_flag,omitempty"`
  16979. InsuAdmdvs string `json:"insu_admdvs"`
  16980. EmpNo string `json:"emp_no,omitempty"`
  16981. EmpName string `json:"emp_name,omitempty"`
  16982. EmpType string `json:"emp_type,omitempty"`
  16983. EconType string `json:"econ_type,omitempty"`
  16984. AfilIndu string `json:"afil_indu,omitempty"`
  16985. AfilRlts string `json:"afil_rlts,omitempty"`
  16986. EmpMgtType string `json:"emp_mgt_type,omitempty"`
  16987. PayLoc string `json:"pay_loc,omitempty"`
  16988. FixmedinsCode string `json:"fixmedins_code"`
  16989. FixmedinsName string `json:"fixmedins_name"`
  16990. HospLv string `json:"hosp_lv,omitempty"`
  16991. FixBlngAdmdvs string `json:"fix_blng_admdvs,omitempty"`
  16992. LmtpricHospLv string `json:"lmtpric_hosp_lv,omitempty"`
  16993. DedcHospLv string `json:"dedc_hosp_lv,omitempty"`
  16994. Begndate string `json:"begndate,omitempty"`
  16995. Enddate string `json:"enddate,omitempty"`
  16996. SetlTime string `json:"setl_time,omitempty"`
  16997. MdtrtCertType string `json:"mdtrt_cert_type,omitempty"`
  16998. MdtrtCertNo string `json:"mdtrt_cert_no,omitempty"`
  16999. MedType string `json:"med_type"`
  17000. SetlType string `json:"setl_type,omitempty"`
  17001. ClrType string `json:"clr_type,omitempty"`
  17002. ClrWay string `json:"clr_way,omitempty"`
  17003. PsnSetlway string `json:"psn_setlway,omitempty"`
  17004. MedfeeSumamt float64 `json:"medfee_sumamt,omitempty"`
  17005. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt,omitempty"`
  17006. OverlmtSelfpay float64 `json:"overlmt_selfpay,omitempty"`
  17007. PreselfpayAmt float64 `json:"preselfpay_amt,omitempty"`
  17008. InscpAmt float64 `json:"inscp_amt,omitempty"`
  17009. DedcStd float64 `json:"dedc_std,omitempty"`
  17010. CrtDedc float64 `json:"crt_dedc,omitempty"`
  17011. ActPayDedc float64 `json:"act_pay_dedc,omitempty"`
  17012. HifpPay float64 `json:"hifp_pay,omitempty"`
  17013. PoolPropSelfpay float64 `json:"pool_prop_selfpay,omitempty"`
  17014. HiAgreSumfee float64 `json:"hi_agre_sumfee,omitempty"`
  17015. CvlservPay float64 `json:"cvlserv_pay,omitempty"`
  17016. HifesPay float64 `json:"hifes_pay,omitempty"`
  17017. HifmiPay float64 `json:"hifmi_pay,omitempty"`
  17018. HifobPay float64 `json:"hifob_pay,omitempty"`
  17019. HifdmPay float64 `json:"hifdm_pay,omitempty"`
  17020. MafPay float64 `json:"maf_pay,omitempty"`
  17021. OthfundPay float64 `json:"othfund_pay,omitempty"`
  17022. FundPaySumamt float64 `json:"fund_pay_sumamt,omitempty"`
  17023. PsnPay float64 `json:"psn_pay,omitempty"`
  17024. AcctPay float64 `json:"acct_pay,omitempty"`
  17025. CashPayamt float64 `json:"cash_payamt,omitempty"`
  17026. OwnpayHospPart float64 `json:"ownpay_hosp_part,omitempty"`
  17027. Balc float64 `json:"balc,omitempty"`
  17028. AcctMulaidPay float64 `json:"acct_mulaid_pay,omitempty"`
  17029. RefdSetlFlag string `json:"refd_setl_flag,omitempty"`
  17030. CalIptCnt string `json:"cal_ipt_cnt,omitempty"`
  17031. SetlCashpayWay string `json:"setl_cashpay_way,omitempty"`
  17032. Year string `json:"year,omitempty"`
  17033. DiseNo string `json:"dise_no,omitempty"`
  17034. DiseName string `json:"dise_name,omitempty"`
  17035. Invono string `json:"invono,omitempty"`
  17036. ManlReimRea string `json:"manl_reim_rea,omitempty"`
  17037. Memo string `json:"memo,omitempty"`
  17038. UpdtTime string `json:"updt_time,omitempty"`
  17039. OpterID string `json:"opter_id,omitempty"`
  17040. OpterName string `json:"opter_name,omitempty"`
  17041. OptTime string `json:"opt_time,omitempty"`
  17042. OptinsNo string `json:"optins_no,omitempty"`
  17043. PoolareaNo string `json:"poolarea_no,omitempty"`
  17044. } `json:"result"`
  17045. } `json:"output"`
  17046. RefmsgTime string `json:"refmsg_time"`
  17047. RespondTime string `json:"respond_time"`
  17048. Signtype interface{} `json:"signtype"`
  17049. WarnInfo interface{} `json:"warn_info"`
  17050. }
  17051. // type Autogenerated struct {
  17052. // Output struct {
  17053. // Setlinfo struct {
  17054. // SetlTime string `json:"setl_time"`
  17055. // CvlservPay float64 `json:"cvlserv_pay"`
  17056. // Year string `json:"year"`
  17057. // MedType string `json:"med_type"`
  17058. // PsnPay float64 `json:"psn_pay"`
  17059. // OpterID string `json:"opter_id"`
  17060. // Begndate string `json:"begndate"`
  17061. // FlxempeFlag string `json:"flxempe_flag"`
  17062. // HifmiPay float64 `json:"hifmi_pay"`
  17063. // PsnNo string `json:"psn_no"`
  17064. // ActPayDedc float64 `json:"act_pay_dedc"`
  17065. // MedinsSetlID interface{} `json:"medins_setl_id"`
  17066. // AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  17067. // ClrWay string `json:"clr_way"`
  17068. // OthPay float64 `json:"oth_pay"`
  17069. // Gend string `json:"gend"`
  17070. // MdtrtID string `json:"mdtrt_id"`
  17071. // AcctPay float64 `json:"acct_pay"`
  17072. // InscpScpAmt float64 `json:"inscp_scp_amt"`
  17073. // Insutype string `json:"insutype"`
  17074. // Invono interface{} `json:"invono"`
  17075. // Enddate string `json:"enddate"`
  17076. // CashPayamt float64 `json:"cash_payamt"`
  17077. // PsnType string `json:"psn_type"`
  17078. // FixmedinsName string `json:"fixmedins_name"`
  17079. // HifpPay float64 `json:"hifp_pay"`
  17080. // NewFlag interface{} `json:"new_flag"`
  17081. // OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  17082. // PreselfpayAmt float64 `json:"preselfpay_amt"`
  17083. // PayLoc string `json:"pay_loc"`
  17084. // ClrType string `json:"clr_type"`
  17085. // RefdSetlFlag string `json:"refd_setl_flag"`
  17086. // CvlservFlag string `json:"cvlserv_flag"`
  17087. // EmpName string `json:"emp_name"`
  17088. // Brdy string `json:"brdy"`
  17089. // Naty string `json:"naty"`
  17090. // Certno string `json:"certno"`
  17091. // DiseCode string `json:"dise_code"`
  17092. // FixmedinsCode string `json:"fixmedins_code"`
  17093. // DedcHospLv string `json:"dedc_hosp_lv"`
  17094. // OpterName string `json:"opter_name"`
  17095. // Balc float64 `json:"balc"`
  17096. // FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  17097. // PsnCertType string `json:"psn_cert_type"`
  17098. // HifobPay float64 `json:"hifob_pay"`
  17099. // MedfeeSumamt float64 `json:"medfee_sumamt"`
  17100. // HifesPay float64 `json:"hifes_pay"`
  17101. // FundPaySumamt float64 `json:"fund_pay_sumamt"`
  17102. // OptTime string `json:"opt_time"`
  17103. // FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  17104. // SetlID string `json:"setl_id"`
  17105. // MafPay float64 `json:"maf_pay"`
  17106. // PsnName string `json:"psn_name"`
  17107. // InsuOptins interface{} `json:"insu_optins"`
  17108. // PrefFundPay interface{} `json:"pref_fund_pay"`
  17109. // ClrOptins string `json:"clr_optins"`
  17110. // PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  17111. // DiseName string `json:"dise_name"`
  17112. // LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  17113. // Age float64 `json:"age"`
  17114. // DtrtCertType string `json:"dtrt_cert_type"`
  17115. // HospLv string `json:"hosp_lv"`
  17116. // } `json:"setlinfo"`
  17117. // Setldetail []struct {
  17118. // FundPayType string `json:"fund_pay_type"`
  17119. // FundPayamt float64 `json:"fund_payamt"`
  17120. // SetlProcInfo interface{} `json:"setl_proc_info"`
  17121. // CrtPaybLmtAmt interface{} `json:"crt_payb_lmt_amt"`
  17122. // InscpScpAmt interface{} `json:"inscp_scp_amt"`
  17123. // FundPayTypeName interface{} `json:"fund_pay_type_name"`
  17124. // PrefFundPay interface{} `json:"pref_fund_pay"`
  17125. // } `json:"setldetail"`
  17126. // } `json:"output"`
  17127. // Infcode int `json:"infcode"`
  17128. // WarnMsg interface{} `json:"warn_msg"`
  17129. // Cainfo interface{} `json:"cainfo"`
  17130. // ErrMsg interface{} `json:"err_msg"`
  17131. // RefmsgTime string `json:"refmsg_time"`
  17132. // Signtype interface{} `json:"signtype"`
  17133. // RespondTime string `json:"respond_time"`
  17134. // InfRefmsgid string `json:"inf_refmsgid"`
  17135. // }
  17136. type Result002 struct {
  17137. Cainfo interface{} `json:"cainfo"`
  17138. ErrMsg string `json:"err_msg"`
  17139. InfRefmsgid string `json:"inf_refmsgid"`
  17140. Infcode int64 `json:"infcode"`
  17141. Output struct {
  17142. RxFile string `json:"rx_file"`
  17143. SignDigest string `json:"sign_digest"`
  17144. SignCertSn string `json:"sign_cert_sn"`
  17145. SignCertDn string `json:"sign_cert_dn"`
  17146. } `json:"output"`
  17147. RefmsgTime string `json:"refmsg_time"`
  17148. RespondTime string `json:"respond_time"`
  17149. Signtype interface{} `json:"signtype"`
  17150. WarnMsg interface{} `json:"warn_msg"`
  17151. }
  17152. type Result003 struct {
  17153. Cainfo interface{} `json:"cainfo"`
  17154. ErrMsg string `json:"err_msg"`
  17155. InfRefmsgid string `json:"inf_refmsgid"`
  17156. Infcode int64 `json:"infcode"`
  17157. Output struct {
  17158. HiRxno string `json:"hi_rxno"`
  17159. RxStasCodg string `json:"rx_stas_codg"`
  17160. RxStasName string `json:"rx_stas_name"`
  17161. } `json:"output"`
  17162. RefmsgTime string `json:"refmsg_time"`
  17163. RespondTime string `json:"respond_time"`
  17164. Signtype interface{} `json:"signtype"`
  17165. WarnMsg interface{} `json:"warn_msg"`
  17166. }
  17167. type ResultEleven struct {
  17168. Cainfo string `json:"cainfo"`
  17169. ErrMsg string `json:"err_msg"`
  17170. InfRefmsgid string `json:"inf_refmsgid"`
  17171. Infcode int64 `json:"infcode"`
  17172. Output struct {
  17173. Setlinfo struct {
  17174. SetlTime string `json:"setl_time"`
  17175. CvlservPay float64 `json:"cvlserv_pay"`
  17176. Year string `json:"year"`
  17177. MedType string `json:"med_type"`
  17178. PsnPay float64 `json:"psn_pay"`
  17179. OpterID string `json:"opter_id"`
  17180. Begndate string `json:"begndate"`
  17181. FlxempeFlag string `json:"flxempe_flag"`
  17182. HifmiPay float64 `json:"hifmi_pay"`
  17183. PsnNo string `json:"psn_no"`
  17184. ActPayDedc float64 `json:"act_pay_dedc"`
  17185. MedinsSetlID interface{} `json:"medins_setl_id"`
  17186. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  17187. ClrWay string `json:"clr_way"`
  17188. OthPay float64 `json:"oth_pay"`
  17189. Gend string `json:"gend"`
  17190. MdtrtID string `json:"mdtrt_id"`
  17191. AcctPay float64 `json:"acct_pay"`
  17192. InscpScpAmt float64 `json:"inscp_scp_amt"`
  17193. Insutype string `json:"insutype"`
  17194. Invono interface{} `json:"invono"`
  17195. Enddate string `json:"enddate"`
  17196. CashPayamt float64 `json:"cash_payamt"`
  17197. PsnType string `json:"psn_type"`
  17198. FixmedinsName string `json:"fixmedins_name"`
  17199. HifpPay float64 `json:"hifp_pay"`
  17200. NewFlag interface{} `json:"new_flag"`
  17201. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  17202. PreselfpayAmt float64 `json:"preselfpay_amt"`
  17203. PayLoc string `json:"pay_loc"`
  17204. ClrType string `json:"clr_type"`
  17205. RefdSetlFlag string `json:"refd_setl_flag"`
  17206. CvlservFlag string `json:"cvlserv_flag"`
  17207. EmpName string `json:"emp_name"`
  17208. Brdy string `json:"brdy"`
  17209. Naty string `json:"naty"`
  17210. Certno string `json:"certno"`
  17211. DiseCode string `json:"dise_code"`
  17212. FixmedinsCode string `json:"fixmedins_code"`
  17213. DedcHospLv string `json:"dedc_hosp_lv"`
  17214. OpterName string `json:"opter_name"`
  17215. Balc float64 `json:"balc"`
  17216. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  17217. PsnCertType string `json:"psn_cert_type"`
  17218. HifobPay float64 `json:"hifob_pay"`
  17219. MedfeeSumamt float64 `json:"medfee_sumamt"`
  17220. HifesPay float64 `json:"hifes_pay"`
  17221. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  17222. OptTime string `json:"opt_time"`
  17223. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  17224. SetlID string `json:"setl_id"`
  17225. MafPay float64 `json:"maf_pay"`
  17226. PsnName string `json:"psn_name"`
  17227. InsuOptins interface{} `json:"insu_optins"`
  17228. PrefFundPay interface{} `json:"pref_fund_pay"`
  17229. ClrOptins string `json:"clr_optins"`
  17230. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  17231. DiseName string `json:"dise_name"`
  17232. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  17233. Age float64 `json:"age"`
  17234. DtrtCertType string `json:"dtrt_cert_type"`
  17235. HospLv string `json:"hosp_lv"`
  17236. PsnCashPay float64 `json:"psn_cash_pay"`
  17237. } `json:"setlinfo"`
  17238. } `json:"output"`
  17239. RefmsgTime string `json:"refmsg_time"`
  17240. RespondTime string `json:"respond_time"`
  17241. Signtype interface{} `json:"signtype"`
  17242. WarnMsg interface{} `json:"warn_msg"`
  17243. }
  17244. type ResultElevenah struct {
  17245. Cainfo string `json:"cainfo"`
  17246. ErrMsg string `json:"err_msg"`
  17247. InfRefmsgid string `json:"inf_refmsgid"`
  17248. Infcode int64 `json:"infcode"`
  17249. Output struct {
  17250. Setlinfo struct {
  17251. SetlTime int64 `json:"setl_time"`
  17252. CvlservPay float64 `json:"cvlserv_pay"`
  17253. Year string `json:"year"`
  17254. MedType string `json:"med_type"`
  17255. PsnPay float64 `json:"psn_pay"`
  17256. OpterID string `json:"opter_id"`
  17257. Begndate int64 `json:"begndate"`
  17258. FlxempeFlag string `json:"flxempe_flag"`
  17259. HifmiPay float64 `json:"hifmi_pay"`
  17260. PsnNo string `json:"psn_no"`
  17261. ActPayDedc float64 `json:"act_pay_dedc"`
  17262. MedinsSetlID interface{} `json:"medins_setl_id"`
  17263. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  17264. ClrWay string `json:"clr_way"`
  17265. OthPay float64 `json:"oth_pay"`
  17266. Gend string `json:"gend"`
  17267. MdtrtID string `json:"mdtrt_id"`
  17268. AcctPay float64 `json:"acct_pay"`
  17269. InscpScpAmt float64 `json:"inscp_scp_amt"`
  17270. Insutype string `json:"insutype"`
  17271. Invono interface{} `json:"invono"`
  17272. Enddate int64 `json:"enddate"`
  17273. CashPayamt float64 `json:"cash_payamt"`
  17274. PsnType string `json:"psn_type"`
  17275. FixmedinsName string `json:"fixmedins_name"`
  17276. HifpPay float64 `json:"hifp_pay"`
  17277. NewFlag interface{} `json:"new_flag"`
  17278. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  17279. PreselfpayAmt float64 `json:"preselfpay_amt"`
  17280. PayLoc string `json:"pay_loc"`
  17281. ClrType string `json:"clr_type"`
  17282. RefdSetlFlag string `json:"refd_setl_flag"`
  17283. CvlservFlag string `json:"cvlserv_flag"`
  17284. EmpName string `json:"emp_name"`
  17285. Brdy int64 `json:"brdy"`
  17286. Naty string `json:"naty"`
  17287. Certno string `json:"certno"`
  17288. DiseCode string `json:"dise_code"`
  17289. FixmedinsCode string `json:"fixmedins_code"`
  17290. DedcHospLv string `json:"dedc_hosp_lv"`
  17291. OpterName string `json:"opter_name"`
  17292. Balc float64 `json:"balc"`
  17293. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  17294. PsnCertType string `json:"psn_cert_type"`
  17295. HifobPay float64 `json:"hifob_pay"`
  17296. MedfeeSumamt float64 `json:"medfee_sumamt"`
  17297. HifesPay float64 `json:"hifes_pay"`
  17298. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  17299. OptTime int64 `json:"opt_time"`
  17300. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  17301. SetlID string `json:"setl_id"`
  17302. MafPay float64 `json:"maf_pay"`
  17303. PsnName string `json:"psn_name"`
  17304. InsuOptins interface{} `json:"insu_optins"`
  17305. PrefFundPay interface{} `json:"pref_fund_pay"`
  17306. ClrOptins string `json:"clr_optins"`
  17307. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  17308. DiseName string `json:"dise_name"`
  17309. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  17310. Age float64 `json:"age"`
  17311. DtrtCertType string `json:"dtrt_cert_type"`
  17312. HospLv string `json:"hosp_lv"`
  17313. PsnCashPay float64 `json:"psn_cash_pay"`
  17314. } `json:"setlinfo"`
  17315. } `json:"output"`
  17316. RefmsgTime string `json:"refmsg_time"`
  17317. RespondTime string `json:"respond_time"`
  17318. Signtype interface{} `json:"signtype"`
  17319. WarnMsg interface{} `json:"warn_msg"`
  17320. }
  17321. type ResultEleven10265 struct {
  17322. Cainfo string `json:"cainfo"`
  17323. ErrMsg string `json:"err_msg"`
  17324. InfRefmsgid string `json:"inf_refmsgid"`
  17325. Infcode string `json:"infcode"`
  17326. Output struct {
  17327. Setlinfo struct {
  17328. SetlTime string `json:"setl_time"`
  17329. CvlservPay float64 `json:"cvlserv_pay"`
  17330. Year string `json:"year"`
  17331. MedType string `json:"med_type"`
  17332. PsnPay float64 `json:"psn_pay"`
  17333. OpterID string `json:"opter_id"`
  17334. Begndate string `json:"begndate"`
  17335. FlxempeFlag string `json:"flxempe_flag"`
  17336. HifmiPay float64 `json:"hifmi_pay"`
  17337. PsnNo string `json:"psn_no"`
  17338. ActPayDedc float64 `json:"act_pay_dedc"`
  17339. MedinsSetlID interface{} `json:"medins_setl_id"`
  17340. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  17341. ClrWay string `json:"clr_way"`
  17342. OthPay float64 `json:"oth_pay"`
  17343. Gend string `json:"gend"`
  17344. MdtrtID string `json:"mdtrt_id"`
  17345. AcctPay float64 `json:"acct_pay"`
  17346. InscpScpAmt float64 `json:"inscp_scp_amt"`
  17347. Insutype string `json:"insutype"`
  17348. Invono interface{} `json:"invono"`
  17349. Enddate string `json:"enddate"`
  17350. CashPayamt float64 `json:"cash_payamt"`
  17351. PsnType string `json:"psn_type"`
  17352. FixmedinsName string `json:"fixmedins_name"`
  17353. HifpPay float64 `json:"hifp_pay"`
  17354. NewFlag interface{} `json:"new_flag"`
  17355. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  17356. PreselfpayAmt float64 `json:"preselfpay_amt"`
  17357. PayLoc string `json:"pay_loc"`
  17358. ClrType string `json:"clr_type"`
  17359. RefdSetlFlag string `json:"refd_setl_flag"`
  17360. CvlservFlag string `json:"cvlserv_flag"`
  17361. EmpName string `json:"emp_name"`
  17362. Brdy string `json:"brdy"`
  17363. Naty string `json:"naty"`
  17364. Certno string `json:"certno"`
  17365. DiseCode string `json:"dise_code"`
  17366. FixmedinsCode string `json:"fixmedins_code"`
  17367. DedcHospLv string `json:"dedc_hosp_lv"`
  17368. OpterName string `json:"opter_name"`
  17369. Balc float64 `json:"balc"`
  17370. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  17371. PsnCertType string `json:"psn_cert_type"`
  17372. HifobPay float64 `json:"hifob_pay"`
  17373. MedfeeSumamt float64 `json:"medfee_sumamt"`
  17374. HifesPay float64 `json:"hifes_pay"`
  17375. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  17376. OptTime string `json:"opt_time"`
  17377. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  17378. SetlID string `json:"setl_id"`
  17379. MafPay float64 `json:"maf_pay"`
  17380. PsnName string `json:"psn_name"`
  17381. InsuOptins interface{} `json:"insu_optins"`
  17382. PrefFundPay interface{} `json:"pref_fund_pay"`
  17383. ClrOptins string `json:"clr_optins"`
  17384. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  17385. DiseName string `json:"dise_name"`
  17386. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  17387. Age float64 `json:"age"`
  17388. DtrtCertType string `json:"dtrt_cert_type"`
  17389. HospLv string `json:"hosp_lv"`
  17390. PsnCashPay float64 `json:"psn_cash_pay"`
  17391. } `json:"setlinfo"`
  17392. } `json:"output"`
  17393. RefmsgTime string `json:"refmsg_time"`
  17394. RespondTime string `json:"respond_time"`
  17395. Signtype interface{} `json:"signtype"`
  17396. WarnMsg interface{} `json:"warn_msg"`
  17397. }
  17398. type ResultTwelve struct {
  17399. Cainfo string `json:"cainfo"`
  17400. ErrMsg string `json:"err_msg"`
  17401. InfRefmsgid string `json:"inf_refmsgid"`
  17402. Infcode int64 `json:"infcode"`
  17403. Output struct {
  17404. MdtrtId string `json:"mdtrt_id"`
  17405. ChrgBchno string `json:"chrg_bchno"`
  17406. PsnNo string `json:"psn_no"`
  17407. } `json:"output"`
  17408. RefmsgTime string `json:"refmsg_time"`
  17409. RespondTime string `json:"respond_time"`
  17410. Signtype interface{} `json:"signtype"`
  17411. WarnMsg interface{} `json:"warn_msg"`
  17412. }
  17413. type ResultThirteen struct {
  17414. ErrMsg string `json:"err_msg"`
  17415. InfRefmsgid string `json:"inf_refmsgid"`
  17416. Infcode int64 `json:"infcode"`
  17417. Output struct {
  17418. Result struct {
  17419. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  17420. } `json:"result"`
  17421. } `json:"output"`
  17422. RefmsgTime string `json:"refmsg_time"`
  17423. RespondTime string `json:"respond_time"`
  17424. Signtype interface{} `json:"signtype"`
  17425. WarnInfo interface{} `json:"warn_info"`
  17426. }
  17427. type ResultThirteen10265 struct {
  17428. ErrMsg string `json:"err_msg"`
  17429. InfRefmsgid string `json:"inf_refmsgid"`
  17430. Infcode string `json:"infcode"`
  17431. Output struct {
  17432. Result struct {
  17433. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  17434. } `json:"result"`
  17435. } `json:"output"`
  17436. RefmsgTime string `json:"refmsg_time"`
  17437. RespondTime string `json:"respond_time"`
  17438. Signtype interface{} `json:"signtype"`
  17439. WarnInfo interface{} `json:"warn_info"`
  17440. }
  17441. type ResultFourteen struct {
  17442. ErrMsg string `json:"err_msg"`
  17443. InfRefmsgid string `json:"inf_refmsgid"`
  17444. Infcode int64 `json:"infcode"`
  17445. Output struct {
  17446. } `json:"output"`
  17447. RefmsgTime string `json:"refmsg_time"`
  17448. RespondTime string `json:"respond_time"`
  17449. Signtype interface{} `json:"signtype"`
  17450. WarnInfo interface{} `json:"warn_info"`
  17451. }
  17452. type ResultCFYLJG001 struct {
  17453. ErrMsg string `json:"err_msg"`
  17454. InfRefmsgid string `json:"inf_refmsgid"`
  17455. Infcode int64 `json:"infcode"`
  17456. Output struct {
  17457. RxTraceCode string `json:"rx_trace_code"`
  17458. HiRxno string `json:"hi_rxno"`
  17459. } `json:"output"`
  17460. RefmsgTime string `json:"refmsg_time"`
  17461. RespondTime string `json:"respond_time"`
  17462. Signtype interface{} `json:"signtype"`
  17463. WarnInfo interface{} `json:"warn_info"`
  17464. }
  17465. type ResultCFYLJG007 struct {
  17466. ErrMsg string `json:"err_msg"`
  17467. InfRefmsgid string `json:"inf_refmsgid"`
  17468. Infcode int64 `json:"infcode"`
  17469. Output struct {
  17470. HiRxno string `json:"hi_rxno"`
  17471. RxStasName string `json:"rx_stas_name"`
  17472. RxUsedStasCodg string `json:"rx_used_stas_codg"`
  17473. Seltdelts []interface{} `json:"seltdelts"`
  17474. RxUsedStasName string `json:"rx_used_stas_name"`
  17475. RxStasCodg string `json:"rx_stas_codg"`
  17476. } `json:"output"`
  17477. RefmsgTime string `json:"refmsg_time"`
  17478. RespondTime string `json:"respond_time"`
  17479. Signtype interface{} `json:"signtype"`
  17480. WarnInfo interface{} `json:"warn_info"`
  17481. }
  17482. type ResultCFYLJG002 struct {
  17483. ErrMsg string `json:"err_msg"`
  17484. InfRefmsgid string `json:"inf_refmsgid"`
  17485. Infcode int64 `json:"infcode"`
  17486. Output struct {
  17487. RxFile string `json:"rx_file"`
  17488. SignDigest string `json:"sign_digest"`
  17489. SignCertSn string `json:"sign_cert_sn"`
  17490. SignCertDn string `json:"sign_cert_dn"`
  17491. } `json:"output"`
  17492. RefmsgTime string `json:"refmsg_time"`
  17493. RespondTime string `json:"respond_time"`
  17494. Signtype interface{} `json:"signtype"`
  17495. WarnInfo interface{} `json:"warn_info"`
  17496. }
  17497. type ResultCFYLJG003 struct {
  17498. ErrMsg string `json:"err_msg"`
  17499. InfRefmsgid string `json:"inf_refmsgid"`
  17500. Infcode int64 `json:"infcode"`
  17501. Output struct {
  17502. HiRxno string `json:"hi_rxno"`
  17503. RxStasCodg string `json:"rx_stas_codg"`
  17504. RxStasName string `json:"rx_stas_name"`
  17505. } `json:"output"`
  17506. RefmsgTime string `json:"refmsg_time"`
  17507. RespondTime string `json:"respond_time"`
  17508. Signtype interface{} `json:"signtype"`
  17509. WarnInfo interface{} `json:"warn_info"`
  17510. }
  17511. type ResultCFYLJG004 struct {
  17512. ErrMsg string `json:"err_msg"`
  17513. InfRefmsgid string `json:"inf_refmsgid"`
  17514. Infcode int64 `json:"infcode"`
  17515. Output struct {
  17516. HiRxno string `json:"hi_rxno"`
  17517. RxStasCodg string `json:"rx_stas_codg"`
  17518. RxStasName string `json:"rx_stas_name"`
  17519. } `json:"output"`
  17520. RefmsgTime string `json:"refmsg_time"`
  17521. RespondTime string `json:"respond_time"`
  17522. Signtype interface{} `json:"signtype"`
  17523. WarnInfo interface{} `json:"warn_info"`
  17524. }
  17525. type ResultCFYLJG008 struct {
  17526. ErrMsg string `json:"err_msg"`
  17527. InfRefmsgid string `json:"inf_refmsgid"`
  17528. Infcode int64 `json:"infcode"`
  17529. Output struct {
  17530. PoolareaNo string `json:"poolareaNo"`
  17531. AdmdvsName string `json:"admdvsName"`
  17532. Count string `json:"count"`
  17533. } `json:"output"`
  17534. RefmsgTime string `json:"refmsg_time"`
  17535. RespondTime string `json:"respond_time"`
  17536. Signtype interface{} `json:"signtype"`
  17537. WarnInfo interface{} `json:"warn_info"`
  17538. }
  17539. type ResultCFYLJG005 struct {
  17540. ErrMsg string `json:"err_msg"`
  17541. InfRefmsgid string `json:"inf_refmsgid"`
  17542. Infcode int64 `json:"infcode"`
  17543. Output struct {
  17544. HiRxNo string `json:"hi_rxno"`
  17545. FixMedinsCode string `json:"fixmedins_code"`
  17546. FixMedinsName string `json:"fixmedins_name"`
  17547. RxStasCodg string `json:"rx_stas_codg"`
  17548. RxStasName string `json:"rx_stas_name"`
  17549. RxUserdStasCog string `json:"rx_userd_stas_cog"`
  17550. RxUserdStasName string `json:"rx_userd_stas_name"`
  17551. PrscTime string `json:"prsc_time"`
  17552. RxDrugCnt float64 `json:"rx_drug_cnt"`
  17553. RxUsedWayCodg string `json:"rx_used_way_codg"`
  17554. RxUsedWayName string `json:"rx_used_way_name"`
  17555. RxFrquCodg string `json:"rx_frqu_codg"`
  17556. RxFrquName string `json:"rx_frqu_name"`
  17557. RxDosunt string `json:"rx_dosunt"`
  17558. RxDoscnt float64 `json:"rx_doscnt"`
  17559. RxDrordDscr string `json:"rx_drord_dscr"`
  17560. ValiDays int64 `json:"vali_days"`
  17561. ValiEndTime string `json:"vali_end_time"`
  17562. ReptFlag string `json:"rept_flag"`
  17563. MaxReptCnt int64 `json:"max_rept_cnt"`
  17564. ReptdCnt int64 `json:"reptd_cnt"`
  17565. MinInrvDays int64 `json:"min_inrv_days"`
  17566. RxTypeCode string `json:"rx_type_code"`
  17567. RxTypeName string `json:"rx_type_name"`
  17568. LongRxFlag string `json:"long_rx_flag"`
  17569. RxDetlList []struct {
  17570. MedListCodg string `json:"med_list_codg"`
  17571. MedinsListCodg string `json:"medins_list_codg"`
  17572. HospPrepFlag string `json:"hosp_prep_flag"`
  17573. RxItemTypeCode string `json:"rx_item_type_code"`
  17574. RxItemTypeName string `json:"rx_item_type_name"`
  17575. TcmDrugTypeName string `json:"tcmdrug_type_name"`
  17576. TcmDrugTypeCode string `json:"tcmdrug_type_code"`
  17577. TcmHerbFoote string `json:"tcmherb_foote"`
  17578. MednTypeCode string `json:"medn_type_code"`
  17579. MednTypeName string `json:"medn_type_name"`
  17580. MainMedcFlag string `json:"main_medc_flag"`
  17581. UrgtFlag string `json:"urgt_flag"`
  17582. BasMednFlag string `json:"bas_medn_flag"`
  17583. ImpDrugFlag string `json:"imp_drug_flag"`
  17584. ProdBarc string `json:"prod_barc"`
  17585. DrugProdname string `json:"drug_prodname"`
  17586. GennameCodg string `json:"genname_codg"`
  17587. DrugGenname string `json:"drug_genname"`
  17588. DrugDosform string `json:"drug_dosform"`
  17589. DrugSpec string `json:"drug_spec"`
  17590. PrdrName string `json:"prdr_name"`
  17591. MedcWayCodg string `json:"medc_way_codg"`
  17592. MedcWayDscr string `json:"medc_way_dscr"`
  17593. MedcBegntime string `json:"medc_begntime"`
  17594. MedcEndtime string `json:"medc_endtime"`
  17595. MedcDays float64 `json:"medc_days"`
  17596. DrugPric float64 `json:"drug_pric"`
  17597. DrugSumamt float64 `json:"drug_sumamt"`
  17598. DrugCnt float64 `json:"drug_cnt"`
  17599. DrugDosunt string `json:"drug_dosunt"`
  17600. SinDoscnt float64 `json:"sin_doscnt"`
  17601. SinDosunt string `json:"sin_dosunt"`
  17602. UsedFrquCodg string `json:"used_frqu_codg"`
  17603. UsedFrquName string `json:"used_frqu_name"`
  17604. DrugTotlcnt string `json:"drug_totlcnt"`
  17605. DrugTotlcntEmp string `json:"drug_totlcnt_emp"`
  17606. DiseCodg string `json:"dise_codg"`
  17607. HospApprFlag string `json:"hosp_appr_flag"`
  17608. } `json:"rx_detl_list"`
  17609. RxOtpinfo struct {
  17610. MedType string `json:"med_type"`
  17611. IptOtpNo string `json:"ipt_otp_no"`
  17612. OtpIptFlag string `json:"otp_ipt_flag"`
  17613. PatnName string `json:"patn_name"`
  17614. PatnAge float64 `json:"patn_age"`
  17615. PatnHgt float64 `json:"patn_hgt"`
  17616. PatnWt float64 `json:"patn_wt"`
  17617. Gend string `json:"gend"`
  17618. GesoVal float64 `json:"geso_val"`
  17619. NwbFlag string `json:"nwb_flag"`
  17620. NwbAge string `json:"nwb_age"`
  17621. SuckPrdFlag string `json:"suck_prd_flag"`
  17622. AlgsHis string `json:"algs_his"`
  17623. Insutype string `json:"insutype"`
  17624. PrscDeptName string `json:"prsc_dept_name"`
  17625. PrscDrName string `json:"prsc_dr_name"`
  17626. PharName string `json:"phar_name"`
  17627. PharChkTime string `json:"phar_chk_time"`
  17628. MdtrtTime string `json:"mdtrt_time"`
  17629. DiseCodg string `json:"dise_codg"`
  17630. DiseName string `json:"dise_name"`
  17631. SpDiseFlag string `json:"sp_dise_flag"`
  17632. MaindiagCode string `json:"maindiag_code"`
  17633. MaindiagName string `json:"maindiag_name"`
  17634. DiseCondDscr string `json:"dise_cond_dscr"`
  17635. FstdiagFlag string `json:"fstdiag_flag"`
  17636. } `json:"rx_otpinfo"`
  17637. RxDiseList []struct {
  17638. DiagType string `json:"diag_type"`
  17639. MaindiagFlag string `json:"maindiag_flag"`
  17640. DiagSrtNo string `json:"diag_srt_no"`
  17641. DiagCode string `json:"diag_code"`
  17642. DiagName string `json:"diag_name"`
  17643. DiagDept string `json:"diag_dept"`
  17644. DiagDrNo string `json:"diag_dr_no"`
  17645. DiagDrName string `json:"diag_dr_name"`
  17646. DiagTime string `json:"diag_time"`
  17647. TcmDiseCode string `json:"tcm_dise_code"`
  17648. TcmDiseName string `json:"tcm_dise_name"`
  17649. TcmSympCode string `json:"tcmsymp_code"`
  17650. TcmSymp string `json:"tcmsymp"`
  17651. } `json:"rx_dise_list"`
  17652. } `json:"output"`
  17653. RefmsgTime string `json:"refmsg_time"`
  17654. RespondTime string `json:"respond_time"`
  17655. Signtype interface{} `json:"signtype"`
  17656. WarnInfo interface{} `json:"warn_info"`
  17657. }
  17658. type ResultCFYLJG006 struct {
  17659. ErrMsg string `json:"err_msg"`
  17660. InfRefmsgid string `json:"inf_refmsgid"`
  17661. Infcode int64 `json:"infcode"`
  17662. Output struct {
  17663. HiRxNo string `json:"hi_rxno"`
  17664. PharCode string `json:"phar_code"`
  17665. PharName string `json:"phar_name"`
  17666. RxChkOpnn string `json:"rx_chk_opnn"`
  17667. RxChkTime string `json:"rx_chk_time"`
  17668. RxChkStasCodg string `json:"rx_chk_stas_codg"`
  17669. RxChkStasName string `json:"rx_chk_stas_name"`
  17670. RxStasCodg string `json:"rx_stas_codg"`
  17671. RxStasName string `json:"rx_stas_name"`
  17672. } `json:"output"`
  17673. RefmsgTime string `json:"refmsg_time"`
  17674. RespondTime string `json:"respond_time"`
  17675. Signtype interface{} `json:"signtype"`
  17676. WarnInfo interface{} `json:"warn_info"`
  17677. }
  17678. type ResultFourteen10265 struct {
  17679. ErrMsg string `json:"err_msg"`
  17680. InfRefmsgid string `json:"inf_refmsgid"`
  17681. Infcode string `json:"infcode"`
  17682. Output struct {
  17683. } `json:"output"`
  17684. RefmsgTime string `json:"refmsg_time"`
  17685. RespondTime string `json:"respond_time"`
  17686. Signtype interface{} `json:"signtype"`
  17687. WarnInfo interface{} `json:"warn_info"`
  17688. }
  17689. type ResultSixteen struct {
  17690. Cainfo string `json:"cainfo"`
  17691. ErrMsg string `json:"err_msg"`
  17692. InfRefmsgid string `json:"inf_refmsgid"`
  17693. Infcode int64 `json:"infcode"`
  17694. Output struct {
  17695. Setlinfo struct {
  17696. MdtrtID string `json:"mdtrt_id"`
  17697. SetlID string `json:"setl_id"`
  17698. ClrOptins string `json:"clr_optins"`
  17699. SetlTime string `json:"setl_time"`
  17700. MedfeeSumamt float64 `json:"medfee_sumamt"`
  17701. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  17702. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  17703. PreselfpayAmt float64 `json:"preselfpay_amt"`
  17704. InscpScpAmt float64 `json:"inscp_scp_amt"`
  17705. ActPayDedc float64 `json:"act_pay_dedc"`
  17706. HifpPay float64 `json:"hifp_pay"`
  17707. PoolPropSe float64 `json:"pool_prop_selfpay"`
  17708. Lfpay float64 `json:"selfpay"`
  17709. CvlservPay float64 `json:"cvlserv_pay"`
  17710. HifesPay float64 `json:"hifes_pay"`
  17711. HifmiPay float64 `json:"hifmi_pay"`
  17712. HifobPay float64 `json:"hifob_pay"`
  17713. MafPay float64 `json:"maf_pay"`
  17714. OthPay float64 `json:"oth_pay"`
  17715. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  17716. PsnPartAmt float64 `json:"psn_part_amt"`
  17717. AcctPay float64 `json:"acct_pay"`
  17718. Balc float64 `json:"balc"`
  17719. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  17720. HospPartAmt float64 `json:"hosp_part_amt"`
  17721. MedinsSetlID string `json:"medins_setl_id"`
  17722. PdnCashPay string `json:"pdn_cash_pay"`
  17723. } `json:"setlinfo"`
  17724. } `json:"output"`
  17725. RefmsgTime string `json:"refmsg_time"`
  17726. RespondTime string `json:"respond_time"`
  17727. Signtype interface{} `json:"signtype"`
  17728. WarnMsg interface{} `json:"warn_msg"`
  17729. }
  17730. type ResultSixteen10265 struct {
  17731. Cainfo string `json:"cainfo"`
  17732. ErrMsg string `json:"err_msg"`
  17733. InfRefmsgid string `json:"inf_refmsgid"`
  17734. Infcode string `json:"infcode"`
  17735. Output struct {
  17736. Setlinfo struct {
  17737. MdtrtID string `json:"mdtrt_id"`
  17738. SetlID string `json:"setl_id"`
  17739. ClrOptins string `json:"clr_optins"`
  17740. SetlTime string `json:"setl_time"`
  17741. MedfeeSumamt float64 `json:"medfee_sumamt"`
  17742. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  17743. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  17744. PreselfpayAmt float64 `json:"preselfpay_amt"`
  17745. InscpScpAmt float64 `json:"inscp_scp_amt"`
  17746. ActPayDedc float64 `json:"act_pay_dedc"`
  17747. HifpPay float64 `json:"hifp_pay"`
  17748. PoolPropSe float64 `json:"pool_prop_selfpay"`
  17749. Lfpay float64 `json:"selfpay"`
  17750. CvlservPay float64 `json:"cvlserv_pay"`
  17751. HifesPay float64 `json:"hifes_pay"`
  17752. HifmiPay float64 `json:"hifmi_pay"`
  17753. HifobPay float64 `json:"hifob_pay"`
  17754. MafPay float64 `json:"maf_pay"`
  17755. OthPay float64 `json:"oth_pay"`
  17756. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  17757. PsnPartAmt float64 `json:"psn_part_amt"`
  17758. AcctPay float64 `json:"acct_pay"`
  17759. Balc float64 `json:"balc"`
  17760. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  17761. HospPartAmt float64 `json:"hosp_part_amt"`
  17762. MedinsSetlID string `json:"medins_setl_id"`
  17763. PdnCashPay string `json:"pdn_cash_pay"`
  17764. } `json:"setlinfo"`
  17765. } `json:"output"`
  17766. RefmsgTime string `json:"refmsg_time"`
  17767. RespondTime string `json:"respond_time"`
  17768. Signtype interface{} `json:"signtype"`
  17769. WarnMsg interface{} `json:"warn_msg"`
  17770. }
  17771. type ResultSixteen10265Two struct {
  17772. Cainfo string `json:"cainfo"`
  17773. ErrMsg string `json:"err_msg"`
  17774. InfRefmsgid string `json:"inf_refmsgid"`
  17775. Infcode string `json:"infcode"`
  17776. Output struct {
  17777. Setlinfo interface{} `json:"setlinfo"`
  17778. } `json:"output"`
  17779. RefmsgTime string `json:"refmsg_time"`
  17780. RespondTime string `json:"respond_time"`
  17781. Signtype interface{} `json:"signtype"`
  17782. WarnMsg interface{} `json:"warn_msg"`
  17783. }
  17784. type ResultgzSixteen10265Two struct {
  17785. Cainfo string `json:"cainfo"`
  17786. ErrMsg string `json:"err_msg"`
  17787. InfRefmsgid string `json:"inf_refmsgid"`
  17788. Infcode int64 `json:"infcode"`
  17789. Output struct {
  17790. Setlinfo interface{} `json:"setlinfo"`
  17791. } `json:"output"`
  17792. RefmsgTime string `json:"refmsg_time"`
  17793. RespondTime string `json:"respond_time"`
  17794. Signtype interface{} `json:"signtype"`
  17795. WarnMsg interface{} `json:"warn_msg"`
  17796. }
  17797. type ResultSeventeen struct {
  17798. ErrMsg string `json:"err_msg"`
  17799. InfRefmsgid string `json:"inf_refmsgid"`
  17800. Infcode int64 `json:"infcode"`
  17801. Output struct {
  17802. SetlListId string `json:"setl_list_id"`
  17803. } `json:"output"`
  17804. RefmsgTime string `json:"refmsg_time"`
  17805. RespondTime string `json:"respond_time"`
  17806. Signtype string `json:"signtype"`
  17807. WarnInfo string `json:"warn_info"`
  17808. }
  17809. type ResultSeventeenOther struct {
  17810. ErrMsg string `json:"err_msg"`
  17811. InfRefmsgid string `json:"inf_refmsgid"`
  17812. Infcode string `json:"infcode"`
  17813. Output struct {
  17814. SetlListId string `json:"setl_list_id"`
  17815. } `json:"output"`
  17816. RefmsgTime string `json:"refmsg_time"`
  17817. RespondTime string `json:"respond_time"`
  17818. Signtype string `json:"signtype"`
  17819. WarnInfo string `json:"warn_info"`
  17820. }
  17821. type Result90991 struct {
  17822. ErrMsg string `json:"err_msg"`
  17823. InfRefmsgid string `json:"inf_refmsgid"`
  17824. Infcode int64 `json:"infcode"`
  17825. Output struct {
  17826. Result struct {
  17827. PsnNo string `json:"psn_no"`
  17828. CardStat string `json:"card_stat"`
  17829. Certno string `json:"certno"`
  17830. PsnName string `json:"psn_name"`
  17831. CheckStat string `json:"check_stat"`
  17832. SscnoCheckStat string `json:"sscno_check_stat"`
  17833. } `json:"result"`
  17834. } `json:"output"`
  17835. RefmsgTime string `json:"refmsg_time"`
  17836. RespondTime string `json:"respond_time"`
  17837. Signtype interface{} `json:"signtype"`
  17838. WarnInfo interface{} `json:"warn_info"`
  17839. }
  17840. type Result90100 struct {
  17841. ErrMsg string `json:"err_msg"`
  17842. InfRefmsgid string `json:"inf_refmsgid"`
  17843. Infcode int64 `json:"infcode"`
  17844. Output struct {
  17845. PoolareaNo string `json:"poolarea_no"`
  17846. PoolareaNoName string `json:"poolarea_no_name"`
  17847. Insutype string `json:"insutype"`
  17848. InsutypeName string `json:"insutype_name"`
  17849. ClctType string `json:"clct_type"`
  17850. ClctTypeName string `json:"clct_type_name"`
  17851. ClctFlag string `json:"clct_flag"`
  17852. ClctFlagName string `json:"clct_flag_name"`
  17853. AccrymBegn string `json:"accrym_begn"`
  17854. AccrymEnd string `json:"accrym_end"`
  17855. ClctTime string `json:"clct_time"`
  17856. ClctstdCrtfRuleCodg string `json:"clctstd_crtf_rule_codg"`
  17857. } `json:"output"`
  17858. RefmsgTime string `json:"refmsg_time"`
  17859. RespondTime string `json:"respond_time"`
  17860. Signtype interface{} `json:"signtype"`
  17861. WarnInfo interface{} `json:"warn_info"`
  17862. }
  17863. type Custom struct {
  17864. DetItemFeeSumamt string
  17865. Cut string
  17866. FeedetlSn string
  17867. Price string
  17868. MedListCodg string
  17869. Type int64
  17870. AdviceId int64
  17871. ProjectId int64
  17872. ItemId int64
  17873. }
  17874. type Result5301 struct {
  17875. ErrMsg string `json:"err_msg"`
  17876. InfRefmsgid string `json:"inf_refmsgid"`
  17877. Infcode int64 `json:"infcode"`
  17878. Output struct {
  17879. Result []struct {
  17880. OpspDiseCode string `json:"opsp_dise_code"`
  17881. OpspDiseName string `json:"opsp_dise_name"`
  17882. Begndate string `json:"begndate"`
  17883. Enddate string `json:"enddate"`
  17884. } `json:"feedetail"`
  17885. } `json:"output"`
  17886. RefmsgTime string `json:"refmsg_time"`
  17887. RespondTime string `json:"respond_time"`
  17888. Signtype interface{} `json:"signtype"`
  17889. WarnInfo interface{} `json:"warn_info"`
  17890. }
  17891. type Result5301For10265 struct {
  17892. ErrMsg string `json:"err_msg"`
  17893. InfRefmsgid string `json:"inf_refmsgid"`
  17894. Infcode string `json:"infcode"`
  17895. Output struct {
  17896. Result []struct {
  17897. OpspDiseCode string `json:"opsp_dise_code"`
  17898. OpspDiseName string `json:"opsp_dise_name"`
  17899. Begndate string `json:"begndate"`
  17900. Enddate string `json:"enddate"`
  17901. } `json:"feedetail"`
  17902. } `json:"output"`
  17903. RefmsgTime string `json:"refmsg_time"`
  17904. RespondTime string `json:"respond_time"`
  17905. Signtype interface{} `json:"signtype"`
  17906. WarnInfo interface{} `json:"warn_info"`
  17907. }
  17908. //获取个人信息----挂号-----上传就诊信息
  17909. func (c *HisApiController) GetRegisterInfo() {
  17910. id, _ := c.GetInt64("id")
  17911. record_time := c.GetString("record_time")
  17912. settlementValue, _ := c.GetInt64("settlement_value")
  17913. medical_insurance_card := c.GetString("medical_insurance_card")
  17914. name := c.GetString("name")
  17915. id_card_type, _ := c.GetInt64("id_card_type")
  17916. certificates, _ := c.GetInt64("certificates")
  17917. medical_care, _ := c.GetInt64("medical_care")
  17918. birthday := c.GetString("birthday")
  17919. id_card := c.GetString("id_card")
  17920. register_type, _ := c.GetInt64("register")
  17921. doctor, _ := c.GetInt64("doctor")
  17922. department, _ := c.GetInt64("department")
  17923. gender, _ := c.GetInt64("sex")
  17924. registration_fee, _ := c.GetFloat("registration_fee")
  17925. medical_expenses, _ := c.GetFloat("medical_expenses")
  17926. social_type, _ := c.GetInt64("social_type")
  17927. admin_user_id, _ := c.GetInt64("admin_user_id")
  17928. insuplc_admdvs := c.GetString("insuplc_admdvs")
  17929. mdtrt_type := c.GetString("mdtrt_type")
  17930. if id_card_type == 5 {
  17931. id_card_type = 4
  17932. }
  17933. timeLayout := "2006-01-02"
  17934. loc, _ := time.LoadLocation("Local")
  17935. birthdays, _ := time.ParseInLocation(timeLayout+" 15:04:05", birthday+" 00:00:00", loc)
  17936. birthUnix := birthdays.Unix()
  17937. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  17938. if err != nil {
  17939. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  17940. return
  17941. }
  17942. recordDateTime := theTime.Unix()
  17943. adminInfo := c.GetAdminUserInfo()
  17944. var patient service.Patients
  17945. if id == 0 {
  17946. patient, _ = service.GetPatientByIDCard(id_card, adminInfo.CurrentOrgId)
  17947. } else {
  17948. patient, _ = service.GetPatientByIDTwo(adminInfo.CurrentOrgId, id)
  17949. }
  17950. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  17951. if patientPrescription.ID == 0 {
  17952. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  17953. }
  17954. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  17955. if patient.ID == 0 {
  17956. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  17957. return
  17958. }
  17959. if len(patient.IdCardNo) == 0 {
  17960. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  17961. return
  17962. }
  17963. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  17964. roles, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, admin_user_id)
  17965. doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, doctor)
  17966. //就诊结算未完成,不能进行二次挂号
  17967. //his, _ := service.GetHisPatientInfoTwo(adminInfo.CurrentOrgId, patient.ID, recordDateTime)
  17968. //if len(his) >= 1 {
  17969. // order, _ := service.GetNewHisOrderTwo(adminInfo.CurrentOrgId, his[len(his)-1].Number, his[len(his)-1].PatientId, recordDateTime)
  17970. // if len(his) >= 1 && order.ID == 0 {
  17971. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisPatientParamWrong)
  17972. // return
  17973. // }
  17974. //}
  17975. //var register_log string
  17976. if config.IsOpen == 1 {
  17977. var res ResultTwo
  17978. var res10265 ResultTwo10265
  17979. var PsnNo string
  17980. var PsnCertType string
  17981. var Certno string
  17982. var PsnName string
  17983. var Gend string
  17984. var Naty string
  17985. var Brdy string
  17986. var Age float64
  17987. var infoStr string
  17988. var idetinfoStr string
  17989. var infocode int64
  17990. var verify_number string
  17991. fmt.Println(verify_number)
  17992. if miConfig.MdtrtareaAdmvs == "421300" || miConfig.MdtrtareaAdmvs == "420200" || miConfig.MdtrtareaAdmvs == "421182" || miConfig.MdtrtareaAdmvs == "420902" {
  17993. psn_info, _ := service.GetPsnByPatientId(id)
  17994. PsnNo = psn_info.PsnNo
  17995. PsnCertType = psn_info.PsnCertType
  17996. Certno = psn_info.Certno
  17997. PsnName = psn_info.PsnName
  17998. Gend = psn_info.Gend
  17999. Naty = psn_info.Naty
  18000. Brdy = psn_info.Brdy
  18001. Age = psn_info.Age
  18002. infoStr = psn_info.Insuinfo
  18003. idetinfoStr = psn_info.Idetinfo
  18004. infocode = 0
  18005. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  18006. psn_info, _ := service.GetPsnByPatientId(id)
  18007. PsnNo = psn_info.PsnNo
  18008. PsnCertType = psn_info.PsnCertType
  18009. Certno = psn_info.Certno
  18010. PsnName = psn_info.PsnName
  18011. Gend = psn_info.Gend
  18012. Naty = psn_info.Naty
  18013. Brdy = psn_info.Brdy
  18014. Age = psn_info.Age
  18015. infoStr = psn_info.Insuinfo
  18016. idetinfoStr = psn_info.Idetinfo
  18017. infocode = 0
  18018. verify_number = psn_info.VerifyNumber
  18019. } else if miConfig.MdtrtareaAdmvs == "150499" {
  18020. if id_card_type == 2 {
  18021. //请求内网数据
  18022. api := "http://172.16.13.254:9532/" + "nmyb/1101?cert_no=" + patient.IdCardNo +
  18023. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  18024. "&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
  18025. resp, requestErr := http.Get(api)
  18026. if requestErr != nil {
  18027. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18028. return
  18029. }
  18030. body, ioErr := ioutil.ReadAll(resp.Body)
  18031. if ioErr != nil {
  18032. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  18033. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18034. return
  18035. }
  18036. var respJSON map[string]interface{}
  18037. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  18038. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18039. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18040. return
  18041. }
  18042. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  18043. result_byte, _ := json.Marshal(respJSON)
  18044. result := string(result_byte)
  18045. var dat map[string]interface{}
  18046. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  18047. fmt.Println(dat)
  18048. } else {
  18049. fmt.Println(err)
  18050. }
  18051. userJSONBytes, _ := json.Marshal(dat)
  18052. var res ResultTwo
  18053. var resTwo10265 ResultTwo10265
  18054. if miConfig.Code == "H15049901371" {
  18055. if err := json.Unmarshal(userJSONBytes, &resTwo10265); err != nil {
  18056. utils.ErrorLog("解析失败:%v", err)
  18057. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18058. return
  18059. }
  18060. Infcode, _ := strconv.ParseInt(resTwo10265.Infcode, 10, 64)
  18061. res.Infcode = Infcode
  18062. res.ErrMsg = resTwo10265.ErrMsg
  18063. res.Output = resTwo10265.Output
  18064. res.InfRefmsgid = resTwo10265.InfRefmsgid
  18065. res.RespondTime = resTwo10265.RespondTime
  18066. res.WarnInfo = resTwo10265.WarnInfo
  18067. } else {
  18068. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  18069. utils.ErrorLog("解析失败:%v", err)
  18070. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18071. return
  18072. }
  18073. }
  18074. //var insutypes []string
  18075. //var insutype string
  18076. //var is390 int = 0
  18077. //var is310 int = 0
  18078. //for _, item := range res.Output.Iinfo {
  18079. // if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  18080. // insutypes = append(insutypes, item.Insutype)
  18081. // }
  18082. //}
  18083. //if len(insutypes) == 1 {
  18084. // insutype = insutypes[0]
  18085. //} else {
  18086. // for _, i := range insutypes {
  18087. // if i == "390" {
  18088. // is390 = 1
  18089. // }
  18090. //
  18091. // if i == "310" {
  18092. // is310 = 1
  18093. // }
  18094. // }
  18095. //}
  18096. //if is390 == 1 {
  18097. // insutype = "390"
  18098. //}
  18099. //if is310 == 1 {
  18100. // insutype = "310"
  18101. //}
  18102. //if len(insutypes) == 0 {
  18103. // insutype = "310"
  18104. //}
  18105. PsnNo = res.Output.Baseinfo.PsnNo
  18106. PsnCertType = res.Output.Baseinfo.PsnCertType
  18107. Certno = res.Output.Baseinfo.Certno
  18108. PsnName = res.Output.Baseinfo.PsnName
  18109. Gend = res.Output.Baseinfo.Gend
  18110. Naty = res.Output.Baseinfo.Naty
  18111. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  18112. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  18113. infoStr = string(Iinfos)
  18114. idetinfoStr = string(Idetinfos)
  18115. infocode = res.Infcode
  18116. //infocode = 0
  18117. //verify_number = psn_info.VerifyNumber
  18118. } else {
  18119. psn_info, _ := service.GetPsnByPatientId(id)
  18120. PsnNo = psn_info.PsnNo
  18121. PsnCertType = psn_info.PsnCertType
  18122. Certno = psn_info.Certno
  18123. PsnName = psn_info.PsnName
  18124. Gend = psn_info.Gend
  18125. Naty = psn_info.Naty
  18126. Brdy = psn_info.Brdy
  18127. Age = psn_info.Age
  18128. infoStr = psn_info.Insuinfo
  18129. idetinfoStr = psn_info.Idetinfo
  18130. infocode = 0
  18131. verify_number = psn_info.VerifyNumber
  18132. }
  18133. } else if miConfig.MdtrtareaAdmvs == "350500" {
  18134. if id_card_type == 1 {
  18135. psn_info, _ := service.GetPsnByPatientId(id)
  18136. PsnNo = psn_info.PsnNo
  18137. PsnCertType = psn_info.PsnCertType
  18138. Certno = psn_info.Certno
  18139. PsnName = psn_info.PsnName
  18140. Gend = psn_info.Gend
  18141. Naty = psn_info.Naty
  18142. Brdy = psn_info.Brdy
  18143. Age = psn_info.Age
  18144. infoStr = psn_info.Insuinfo
  18145. idetinfoStr = psn_info.Idetinfo
  18146. infocode = 0
  18147. verify_number = psn_info.VerifyNumber
  18148. } else if id_card_type == 2 {
  18149. 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)
  18150. fmt.Println(errMsgLog)
  18151. saveLog(result, requestLog, "1101", "人员基本信息获取")
  18152. if err := json.Unmarshal([]byte(result), &res); err != nil {
  18153. utils.ErrorLog("解析失败:%v", err)
  18154. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18155. return
  18156. }
  18157. PsnNo = res.Output.Baseinfo.PsnNo
  18158. PsnCertType = res.Output.Baseinfo.PsnCertType
  18159. Certno = res.Output.Baseinfo.Certno
  18160. PsnName = res.Output.Baseinfo.PsnName
  18161. Gend = res.Output.Baseinfo.Gend
  18162. Naty = res.Output.Baseinfo.Naty
  18163. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  18164. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  18165. infoStr = string(Iinfos)
  18166. idetinfoStr = string(Idetinfos)
  18167. infocode = res.Infcode
  18168. }
  18169. } else if miConfig.MdtrtareaAdmvs == "360302" {
  18170. if id_card_type == 1 {
  18171. psn_info, _ := service.GetPsnByPatientId(id)
  18172. PsnNo = psn_info.PsnNo
  18173. PsnCertType = psn_info.PsnCertType
  18174. Certno = psn_info.Certno
  18175. PsnName = psn_info.PsnName
  18176. Gend = psn_info.Gend
  18177. Naty = psn_info.Naty
  18178. Brdy = psn_info.Brdy
  18179. Age = psn_info.Age
  18180. infoStr = psn_info.Insuinfo
  18181. idetinfoStr = psn_info.Idetinfo
  18182. infocode = 0
  18183. verify_number = psn_info.VerifyNumber
  18184. } else if id_card_type == 2 {
  18185. 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, "")
  18186. saveLog(result, requestLog, "1101", "人员基本信息获取")
  18187. if err := json.Unmarshal([]byte(result), &res); err != nil {
  18188. utils.ErrorLog("解析失败:%v", err)
  18189. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18190. return
  18191. }
  18192. PsnNo = res.Output.Baseinfo.PsnNo
  18193. PsnCertType = res.Output.Baseinfo.PsnCertType
  18194. Certno = res.Output.Baseinfo.Certno
  18195. PsnName = res.Output.Baseinfo.PsnName
  18196. Gend = res.Output.Baseinfo.Gend
  18197. Naty = res.Output.Baseinfo.Naty
  18198. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  18199. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  18200. infoStr = string(Iinfos)
  18201. idetinfoStr = string(Idetinfos)
  18202. infocode = res.Infcode
  18203. } else {
  18204. psn_info, _ := service.GetPsnByPatientId(id)
  18205. PsnNo = psn_info.PsnNo
  18206. PsnCertType = psn_info.PsnCertType
  18207. Certno = psn_info.Certno
  18208. PsnName = psn_info.PsnName
  18209. Gend = psn_info.Gend
  18210. Naty = psn_info.Naty
  18211. Brdy = psn_info.Brdy
  18212. Age = psn_info.Age
  18213. infoStr = psn_info.Insuinfo
  18214. idetinfoStr = psn_info.Idetinfo
  18215. infocode = 0
  18216. verify_number = psn_info.VerifyNumber
  18217. }
  18218. } else if miConfig.MdtrtareaAdmvs == "341203" {
  18219. psn_info, _ := service.GetPsnByPatientId(id)
  18220. PsnNo = psn_info.PsnNo
  18221. PsnCertType = psn_info.PsnCertType
  18222. Certno = psn_info.Certno
  18223. PsnName = psn_info.PsnName
  18224. Gend = psn_info.Gend
  18225. Naty = psn_info.Naty
  18226. Brdy = psn_info.Brdy
  18227. Age = psn_info.Age
  18228. infoStr = psn_info.Insuinfo
  18229. idetinfoStr = psn_info.Idetinfo
  18230. infocode = 0
  18231. verify_number = psn_info.VerifyNumber
  18232. } else if miConfig.MdtrtareaAdmvs == "430800" {
  18233. if id_card_type == 1 {
  18234. psn_info, _ := service.GetPsnByPatientId(id)
  18235. PsnNo = psn_info.PsnNo
  18236. PsnCertType = psn_info.PsnCertType
  18237. Certno = psn_info.Certno
  18238. PsnName = psn_info.PsnName
  18239. Gend = psn_info.Gend
  18240. Naty = psn_info.Naty
  18241. Brdy = psn_info.Brdy
  18242. Age = psn_info.Age
  18243. infoStr = psn_info.Insuinfo
  18244. idetinfoStr = psn_info.Idetinfo
  18245. infocode = 0
  18246. verify_number = psn_info.VerifyNumber
  18247. } else if id_card_type == 2 {
  18248. 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)
  18249. saveLog(result, requestLog, "1101", "人员基本信息获取")
  18250. if err := json.Unmarshal([]byte(result), &res); err != nil {
  18251. utils.ErrorLog("解析失败:%v", err)
  18252. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18253. return
  18254. }
  18255. PsnNo = res.Output.Baseinfo.PsnNo
  18256. PsnCertType = res.Output.Baseinfo.PsnCertType
  18257. Certno = res.Output.Baseinfo.Certno
  18258. PsnName = res.Output.Baseinfo.PsnName
  18259. Gend = res.Output.Baseinfo.Gend
  18260. Naty = res.Output.Baseinfo.Naty
  18261. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  18262. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  18263. infoStr = string(Iinfos)
  18264. idetinfoStr = string(Idetinfos)
  18265. infocode = res.Infcode
  18266. } else if id_card_type == 4 {
  18267. psn_info, _ := service.GetPsnByPatientId(id)
  18268. PsnNo = psn_info.PsnNo
  18269. PsnCertType = psn_info.PsnCertType
  18270. Certno = psn_info.Certno
  18271. PsnName = psn_info.PsnName
  18272. Gend = psn_info.Gend
  18273. Naty = psn_info.Naty
  18274. Brdy = psn_info.Brdy
  18275. Age = psn_info.Age
  18276. infoStr = psn_info.Insuinfo
  18277. idetinfoStr = psn_info.Idetinfo
  18278. infocode = 0
  18279. verify_number = psn_info.VerifyNumber
  18280. }
  18281. } else if miConfig.MdtrtareaAdmvs == "131023" {
  18282. var result string
  18283. var requestLog string
  18284. 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), "")
  18285. if id_card_type == 4 {
  18286. psn_info, _ := service.GetPsnByPatientId(id)
  18287. PsnNo = psn_info.PsnNo
  18288. PsnCertType = psn_info.PsnCertType
  18289. Certno = psn_info.Certno
  18290. PsnName = psn_info.PsnName
  18291. Gend = psn_info.Gend
  18292. Naty = psn_info.Naty
  18293. Brdy = psn_info.Brdy
  18294. Age = psn_info.Age
  18295. infoStr = psn_info.Insuinfo
  18296. idetinfoStr = psn_info.Idetinfo
  18297. infocode = 0
  18298. verify_number = psn_info.VerifyNumber
  18299. } else {
  18300. saveLog(result, requestLog, "1101", "人员基本信息获取")
  18301. if miConfig.Code == "H15049901371" {
  18302. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  18303. utils.ErrorLog("解析失败:%v", err)
  18304. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18305. return
  18306. }
  18307. res.ErrMsg = res10265.ErrMsg
  18308. res.Output = res10265.Output
  18309. res.InfRefmsgid = res10265.InfRefmsgid
  18310. } else {
  18311. if err := json.Unmarshal([]byte(result), &res); err != nil {
  18312. utils.ErrorLog("解析失败:%v", err)
  18313. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18314. return
  18315. }
  18316. }
  18317. PsnNo = res.Output.Baseinfo.PsnNo
  18318. PsnCertType = res.Output.Baseinfo.PsnCertType
  18319. Certno = res.Output.Baseinfo.Certno
  18320. PsnName = res.Output.Baseinfo.PsnName
  18321. Gend = res.Output.Baseinfo.Gend
  18322. Naty = res.Output.Baseinfo.Naty
  18323. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  18324. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  18325. infoStr = string(Iinfos)
  18326. idetinfoStr = string(Idetinfos)
  18327. if miConfig.Code == "H15049901371" {
  18328. infocode, _ = strconv.ParseInt(res10265.Infcode, 10, 64)
  18329. } else {
  18330. infocode = res.Infcode
  18331. }
  18332. }
  18333. } else if miConfig.MdtrtareaAdmvs == "441799" {
  18334. psn_info, _ := service.GetPsnByPatientId(id)
  18335. PsnNo = psn_info.PsnNo
  18336. PsnCertType = psn_info.PsnCertType
  18337. Certno = psn_info.Certno
  18338. PsnName = psn_info.PsnName
  18339. Gend = psn_info.Gend
  18340. Naty = psn_info.Naty
  18341. Brdy = psn_info.Brdy
  18342. Age = psn_info.Age
  18343. infoStr = psn_info.Insuinfo
  18344. idetinfoStr = psn_info.Idetinfo
  18345. infocode = 0
  18346. verify_number = psn_info.VerifyNumber
  18347. } else if miConfig.MdtrtareaAdmvs == "450721" {
  18348. psn_info, _ := service.GetPsnByPatientId(id)
  18349. PsnNo = psn_info.PsnNo
  18350. PsnCertType = psn_info.PsnCertType
  18351. Certno = psn_info.Certno
  18352. PsnName = psn_info.PsnName
  18353. Gend = psn_info.Gend
  18354. Naty = psn_info.Naty
  18355. Brdy = psn_info.Brdy
  18356. Age = psn_info.Age
  18357. infoStr = psn_info.Insuinfo
  18358. idetinfoStr = psn_info.Idetinfo
  18359. infocode = 0
  18360. verify_number = psn_info.VerifyNumber
  18361. } else {
  18362. var result string
  18363. var requestLog string
  18364. //if miConfig.UserOrgId == 10138 {
  18365. if id_card_type != 4 || id_card_type != 1 {
  18366. var insa string
  18367. if len(patient.InsuplcAdmdvs) > 0 {
  18368. insa = patient.InsuplcAdmdvs
  18369. } else {
  18370. insa = miConfig.InsuplcAdmdvs
  18371. }
  18372. //psn_info, _ := service.GetPsnByPatientId(id)
  18373. //result, requestLog = service.Gdyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_info.VerifyNumber)
  18374. 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)
  18375. }
  18376. //}
  18377. //else {
  18378. // var insa string
  18379. // if len(patient.InsuplcAdmdvs) > 0 {
  18380. // insa = patient.InsuplcAdmdvs
  18381. // } else {
  18382. // insa = miConfig.InsuplcAdmdvs
  18383. // }
  18384. // 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)
  18385. //}
  18386. if id_card_type == 4 || id_card_type == 1 {
  18387. psn_info, _ := service.GetPsnByPatientId(id)
  18388. PsnNo = psn_info.PsnNo
  18389. PsnCertType = psn_info.PsnCertType
  18390. Certno = psn_info.Certno
  18391. PsnName = psn_info.PsnName
  18392. Gend = psn_info.Gend
  18393. Naty = psn_info.Naty
  18394. Brdy = psn_info.Brdy
  18395. Age = psn_info.Age
  18396. infoStr = psn_info.Insuinfo
  18397. idetinfoStr = psn_info.Idetinfo
  18398. infocode = 0
  18399. verify_number = psn_info.VerifyNumber
  18400. } else {
  18401. saveLog(result, requestLog, "1101", "人员基本信息获取")
  18402. if miConfig.Code == "H15049901371" {
  18403. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  18404. utils.ErrorLog("解析失败:%v", err)
  18405. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18406. return
  18407. }
  18408. res.ErrMsg = res10265.ErrMsg
  18409. res.Output = res10265.Output
  18410. res.InfRefmsgid = res10265.InfRefmsgid
  18411. } else {
  18412. if err := json.Unmarshal([]byte(result), &res); err != nil {
  18413. utils.ErrorLog("解析失败:%v", err)
  18414. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18415. return
  18416. }
  18417. }
  18418. PsnNo = res.Output.Baseinfo.PsnNo
  18419. PsnCertType = res.Output.Baseinfo.PsnCertType
  18420. Certno = res.Output.Baseinfo.Certno
  18421. PsnName = res.Output.Baseinfo.PsnName
  18422. Gend = res.Output.Baseinfo.Gend
  18423. Naty = res.Output.Baseinfo.Naty
  18424. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  18425. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  18426. infoStr = string(Iinfos)
  18427. idetinfoStr = string(Idetinfos)
  18428. if miConfig.Code == "H15049901371" {
  18429. infocode, _ = strconv.ParseInt(res10265.Infcode, 10, 64)
  18430. } else {
  18431. infocode = res.Infcode
  18432. }
  18433. }
  18434. }
  18435. if infocode == 0 {
  18436. his := models.VMHisPatient{
  18437. Name: name,
  18438. Gender: gender,
  18439. Birthday: birthUnix,
  18440. MedicalTreatmentType: medical_care,
  18441. IdType: certificates,
  18442. IdCardNo: id_card,
  18443. BalanceAccountsType: settlementValue,
  18444. SocialType: social_type,
  18445. MedicalInsuranceNumber: medical_insurance_card,
  18446. RegisterType: register_type,
  18447. RegisterCost: registration_fee,
  18448. TreatmentCost: medical_expenses,
  18449. Status: 1,
  18450. Ctime: time.Now().Unix(),
  18451. Mtime: time.Now().Unix(),
  18452. PsnNo: PsnNo,
  18453. PsnCertType: PsnCertType,
  18454. Certno: Certno,
  18455. PsnName: PsnName,
  18456. Gend: Gend,
  18457. Naty: Naty,
  18458. Brdy: Brdy,
  18459. Age: Age,
  18460. Iinfo: infoStr,
  18461. Idetinfo: idetinfoStr,
  18462. PatientId: patient.ID,
  18463. RecordDate: theTime.Unix(),
  18464. UserOrgId: adminInfo.CurrentOrgId,
  18465. AdminUserId: admin_user_id,
  18466. IsReturn: 1,
  18467. IdCardType: id_card_type,
  18468. Doctor: doctor,
  18469. Departments: department,
  18470. MdtrtGrpType: mdtrt_type,
  18471. }
  18472. timestamp := time.Now().Unix()
  18473. tempTime := time.Unix(timestamp, 0)
  18474. timeFormat := tempTime.Format("20060102150405")
  18475. chrgBchno := rand.Intn(100000) + 10000
  18476. ipt_otp_no := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  18477. his.Number = ipt_otp_no
  18478. //count, _ := service.FindHisRegisterRecord(theTime.Unix(), patient.ID, adminInfo.CurrentOrgId)
  18479. department, _ := service.GetDepartMentDetail(department)
  18480. //doctor_id := strconv.FormatInt(patientPrescription., 10)
  18481. IdCardNo := ""
  18482. if id_card_type == 1 {
  18483. // IdCardNo = medical_insurance_card
  18484. IdCardNo = patient.IdCardNo
  18485. } else {
  18486. IdCardNo = patient.IdCardNo
  18487. }
  18488. var rf []*ResultFive
  18489. json.Unmarshal([]byte(his.Iinfo), &rf)
  18490. var insutypes []*ResultFive
  18491. var insutype string
  18492. var insuplc_admdvs_temp string
  18493. var is390 int = 0
  18494. var is310 int = 0
  18495. for _, item := range rf {
  18496. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  18497. insutypes = append(insutypes, item)
  18498. }
  18499. }
  18500. if len(insutypes) == 1 {
  18501. insutype = insutypes[0].Insutype
  18502. insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  18503. if insutype == "390" {
  18504. is390 = 1
  18505. }
  18506. if insutype == "310" {
  18507. is310 = 1
  18508. }
  18509. } else {
  18510. for _, i := range insutypes {
  18511. if i.Insutype == "390" {
  18512. is390 = 1
  18513. }
  18514. if i.Insutype == "310" {
  18515. is310 = 1
  18516. }
  18517. }
  18518. }
  18519. if is390 == 1 {
  18520. insutype = "390"
  18521. }
  18522. if is310 == 1 {
  18523. insutype = "310"
  18524. }
  18525. fmt.Println(social_type)
  18526. if social_type > 0 {
  18527. insutype = strconv.FormatInt(social_type, 10)
  18528. }
  18529. var infocode int64
  18530. var resThree ResultThree
  18531. var resThree10265 ResultThree10265
  18532. if len(insuplc_admdvs) == 0 {
  18533. psn_info, _ := service.GetPsnByPatientId(id)
  18534. //if len(psn_info.InsuplcAdmdvs) > 0 {
  18535. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  18536. //}
  18537. } else {
  18538. insuplc_admdvs_temp = insuplc_admdvs
  18539. }
  18540. if miConfig.MdtrtareaAdmvs == "421300" {
  18541. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  18542. psn_info, _ := service.GetPsnByPatientId(id)
  18543. api := "http://192.168.124.4:9532/" + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  18544. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  18545. "&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
  18546. resp, requestErr := http.Get(api)
  18547. if requestErr != nil {
  18548. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18549. return
  18550. }
  18551. body, ioErr := ioutil.ReadAll(resp.Body)
  18552. if ioErr != nil {
  18553. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  18554. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18555. return
  18556. }
  18557. var respJSON map[string]interface{}
  18558. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  18559. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18560. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18561. return
  18562. }
  18563. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  18564. result, _ := json.Marshal(respJSON)
  18565. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  18566. utils.ErrorLog("解析失败:%v", err)
  18567. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18568. return
  18569. }
  18570. infocode = resThree.Infcode
  18571. } else if miConfig.MdtrtareaAdmvs == "420200" {
  18572. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  18573. //if strings.Contains(insuplc_admdvs_temp, "4202") {
  18574. // insuplc_admdvs_temp =
  18575. //}
  18576. //if strings.Contains(insuplc_admdvs_temp, "4413") {
  18577. // insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  18578. //}
  18579. api := "http://192.168.0.197:9532/" + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  18580. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  18581. "&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
  18582. resp, requestErr := http.Get(api)
  18583. if requestErr != nil {
  18584. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18585. return
  18586. }
  18587. body, ioErr := ioutil.ReadAll(resp.Body)
  18588. if ioErr != nil {
  18589. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  18590. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18591. return
  18592. }
  18593. var respJSON map[string]interface{}
  18594. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  18595. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18596. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18597. return
  18598. }
  18599. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  18600. result, _ := json.Marshal(respJSON)
  18601. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  18602. utils.ErrorLog("解析失败:%v", err)
  18603. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18604. return
  18605. }
  18606. infocode = resThree.Infcode
  18607. } else if miConfig.MdtrtareaAdmvs == "420902" {
  18608. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  18609. //if strings.Contains(insuplc_admdvs_temp, "4202") {
  18610. // insuplc_admdvs_temp =
  18611. //}
  18612. //if strings.Contains(insuplc_admdvs_temp, "4413") {
  18613. // insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  18614. //}
  18615. utils.ErrorLog("解析失败:%v", insutype)
  18616. utils.ErrorLog("解析失败:%v", PsnNo)
  18617. utils.ErrorLog("解析失败:%v", Certno)
  18618. utils.ErrorLog("解析失败:%v", ipt_otp_no)
  18619. utils.ErrorLog("解析失败:%v", hb_doctor_info.UserName)
  18620. utils.ErrorLog("解析失败:%v", insuplc_admdvs_temp)
  18621. utils.ErrorLog("解析失败:%v", hb_doctor_info.DoctorNumber)
  18622. utils.ErrorLog("解析失败:%v", PsnNo)
  18623. utils.ErrorLog("解析失败:%v", department.Number)
  18624. utils.ErrorLog("解析失败:%v", department.Name)
  18625. utils.ErrorLog("解析失败:%v", roles.UserName)
  18626. api := miConfig.Url + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  18627. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  18628. "&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
  18629. resp, requestErr := http.Get(api)
  18630. if requestErr != nil {
  18631. utils.ErrorLog("解析失败:%v", requestErr)
  18632. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18633. return
  18634. }
  18635. body, ioErr := ioutil.ReadAll(resp.Body)
  18636. if ioErr != nil {
  18637. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  18638. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18639. return
  18640. }
  18641. var respJSON map[string]interface{}
  18642. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  18643. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18644. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18645. return
  18646. }
  18647. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  18648. result, _ := json.Marshal(respJSON)
  18649. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  18650. utils.ErrorLog("解析失败:%v", err)
  18651. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18652. return
  18653. }
  18654. infocode = resThree.Infcode
  18655. } else if miConfig.MdtrtareaAdmvs == "421182" {
  18656. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  18657. //if strings.Contains(insuplc_admdvs_temp, "4202") {
  18658. // insuplc_admdvs_temp =
  18659. //}
  18660. //if strings.Contains(insuplc_admdvs_temp, "4413") {
  18661. // insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  18662. //}
  18663. api := miConfig.Url + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  18664. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  18665. "&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
  18666. resp, requestErr := http.Get(api)
  18667. if requestErr != nil {
  18668. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18669. return
  18670. }
  18671. body, ioErr := ioutil.ReadAll(resp.Body)
  18672. if ioErr != nil {
  18673. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  18674. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18675. return
  18676. }
  18677. var respJSON map[string]interface{}
  18678. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  18679. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18680. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18681. return
  18682. }
  18683. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  18684. result, _ := json.Marshal(respJSON)
  18685. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  18686. utils.ErrorLog("解析失败:%v", err)
  18687. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18688. return
  18689. }
  18690. infocode = resThree.Infcode
  18691. } else if miConfig.MdtrtareaAdmvs == "150499" {
  18692. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  18693. psn_info, _ := service.GetPsnByPatientId(id)
  18694. var verify_number string
  18695. if id_card_type == 4 {
  18696. verify_number = psn_info.VerifyNumber
  18697. } else if id_card_type == 1 {
  18698. bas := strings.Split(psn_info.CardInfo, "|")
  18699. cardNumber := bas[2]
  18700. verify_number = cardNumber
  18701. }
  18702. api := "http://172.16.13.254:9532/" + "nmyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  18703. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  18704. "&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
  18705. resp, requestErr := http.Get(api)
  18706. if requestErr != nil {
  18707. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18708. return
  18709. }
  18710. body, ioErr := ioutil.ReadAll(resp.Body)
  18711. if ioErr != nil {
  18712. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  18713. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18714. return
  18715. }
  18716. var respJSON map[string]interface{}
  18717. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  18718. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18719. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18720. return
  18721. }
  18722. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  18723. result, _ := json.Marshal(respJSON)
  18724. //if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  18725. // utils.ErrorLog("解析失败:%v", err)
  18726. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18727. // return
  18728. //}
  18729. //infocode = resThree.Infcode
  18730. //result, _ := json.Marshal(respJSON)
  18731. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  18732. utils.ErrorLog("解析失败:%v", err)
  18733. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18734. return
  18735. }
  18736. resThree.ErrMsg = resThree10265.ErrMsg
  18737. resThree.Output = resThree10265.Output
  18738. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  18739. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  18740. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  18741. psn_info, _ := service.GetPsnByPatientId(id)
  18742. his.PsnNo = psn_info.PsnNo
  18743. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  18744. var cert_no string
  18745. if id_card_type == 3 {
  18746. psn_info.VerifyNumber = IdCardNo + "|" + psn_info.VerifyNumber
  18747. cert_no = IdCardNo
  18748. } else if id_card_type == 4 {
  18749. cert_no = IdCardNo
  18750. psn_info.VerifyNumber = psn_info.VerifyNumber
  18751. } else {
  18752. bas := strings.Split(psn_info.CardInfo, "|")
  18753. cert_no = bas[2]
  18754. }
  18755. var hisPrescription []*models.HisPrescription
  18756. for _, item := range rf {
  18757. if item.Insutype == insutype {
  18758. //insuplc_admdvs = item.InsuplcAdmdvs
  18759. his.InsuplcAdmdvs = insuplc_admdvs
  18760. }
  18761. }
  18762. his.Insutype = insutype
  18763. res3101 := Check3101ForOne(c, patient.ID, his, admin_user_id, "1", record_time, hisPrescription)
  18764. fmt.Println(res3101)
  18765. fmt.Println(res3101.Infcode)
  18766. if res3101.Infcode == "0" {
  18767. fmt.Println("33333333")
  18768. if len(res3101.Output.Result) > 0 {
  18769. fmt.Println("222222")
  18770. for _, item := range res3101.Output.Result {
  18771. if len(res3101.ErrMsg) == 0 {
  18772. res3101.ErrMsg = item.VolaCont
  18773. } else {
  18774. res3101.ErrMsg = res3101.ErrMsg + "\n" + item.VolaCont
  18775. }
  18776. }
  18777. c.ServeSuccessJSON(map[string]interface{}{
  18778. "failed_code": -10,
  18779. "msg": res3101.ErrMsg,
  18780. })
  18781. return
  18782. } else {
  18783. fmt.Println("11111")
  18784. var api string
  18785. if miConfig.MdtrtareaAdmvs == "320921" {
  18786. ipt_otp_no = timeFormat
  18787. api = "http://192.168.2.3:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  18788. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  18789. "&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
  18790. } else {
  18791. ipt_otp_no = timeFormat
  18792. api = "http://192.168.5.251:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  18793. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  18794. "&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
  18795. }
  18796. resp, requestErr := http.Get(api)
  18797. if requestErr != nil {
  18798. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18799. return
  18800. }
  18801. body, ioErr := ioutil.ReadAll(resp.Body)
  18802. if ioErr != nil {
  18803. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  18804. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18805. return
  18806. }
  18807. var respJSON map[string]interface{}
  18808. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  18809. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18810. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18811. return
  18812. }
  18813. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  18814. result, _ := json.Marshal(respJSON)
  18815. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  18816. utils.ErrorLog("解析失败:%v", err)
  18817. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18818. return
  18819. }
  18820. resThree.ErrMsg = resThree10265.ErrMsg
  18821. resThree.Output = resThree10265.Output
  18822. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  18823. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  18824. }
  18825. } else if res3101.Infcode != "0" {
  18826. c.ServeSuccessJSON(map[string]interface{}{
  18827. "failed_code": -10,
  18828. "msg": res3101.ErrMsg,
  18829. })
  18830. return
  18831. }
  18832. } else if miConfig.MdtrtareaAdmvs == "350500" {
  18833. psn_info, _ := service.GetPsnByPatientId(id)
  18834. var cert_no string
  18835. if id_card_type == 1 {
  18836. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  18837. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  18838. } else if id_card_type == 4 {
  18839. cert_no = psn_info.VerifyNumber
  18840. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  18841. } else {
  18842. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  18843. cert_no = psn_info.VerifyNumber
  18844. }
  18845. 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)
  18846. saveLog(result, requestLog, "2201", "挂号")
  18847. if miConfig.Code == "H15049901371" {
  18848. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  18849. utils.ErrorLog("解析失败:%v", err)
  18850. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18851. return
  18852. }
  18853. resThree.ErrMsg = resThree10265.ErrMsg
  18854. resThree.Output = resThree10265.Output
  18855. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  18856. } else {
  18857. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  18858. utils.ErrorLog("解析失败:%v", err)
  18859. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18860. return
  18861. }
  18862. }
  18863. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  18864. } else if miConfig.MdtrtareaAdmvs == "360302" { //江西萍乡
  18865. psn_info, _ := service.GetPsnByPatientId(id)
  18866. var result string
  18867. var requestLog string
  18868. if id_card_type == 1 {
  18869. bas := strings.Split(psn_info.CardInfo, "|")
  18870. basNumber := bas[2]
  18871. card_sn := bas[3]
  18872. 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)
  18873. saveLog(result, requestLog, "2201A", "挂号")
  18874. } else if id_card_type == 2 {
  18875. 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, "", "", "", "", "", "")
  18876. saveLog(result, requestLog, "2201A", "挂号")
  18877. } else {
  18878. 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)
  18879. saveLog(result, requestLog, "2201A", "挂号")
  18880. }
  18881. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  18882. utils.ErrorLog("解析失败:%v", err)
  18883. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18884. return
  18885. }
  18886. infocode = resThree.Infcode
  18887. } else if miConfig.MdtrtareaAdmvs == "341203" {
  18888. psn_info, _ := service.GetPsnByPatientId(id)
  18889. his.PsnNo = psn_info.PsnNo
  18890. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  18891. var cert_no string
  18892. if id_card_type == 1 {
  18893. bas := strings.Split(psn_info.CardInfo, "|")
  18894. cert_no = bas[2]
  18895. } else if id_card_type == 4 {
  18896. cert_no = IdCardNo
  18897. psn_info.VerifyNumber = psn_info.VerifyNumber
  18898. } else {
  18899. cert_no = IdCardNo
  18900. psn_info.VerifyNumber = cert_no
  18901. }
  18902. for _, item := range rf {
  18903. if item.Insutype == insutype {
  18904. his.InsuplcAdmdvs = insuplc_admdvs
  18905. }
  18906. }
  18907. his.Insutype = insutype
  18908. var api string
  18909. ipt_otp_no = timeFormat
  18910. api = miConfig.SecretKey + "ahyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  18911. "&org_name=" + miConfig.OrgName + "&opera=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  18912. "&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
  18913. resp, requestErr := http.Get(api)
  18914. if requestErr != nil {
  18915. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18916. return
  18917. }
  18918. body, ioErr := ioutil.ReadAll(resp.Body)
  18919. if ioErr != nil {
  18920. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  18921. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18922. return
  18923. }
  18924. var respJSON map[string]interface{}
  18925. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  18926. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18927. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18928. return
  18929. }
  18930. status := respJSON["data"].(map[string]interface{})["status"].(string)
  18931. if status == "0" {
  18932. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  18933. c.ServeSuccessJSON(map[string]interface{}{
  18934. "failed_code": -10,
  18935. "msg": err_msg,
  18936. })
  18937. return
  18938. }
  18939. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  18940. result, _ := json.Marshal(respJSON)
  18941. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  18942. utils.ErrorLog("解析失败:%v", err)
  18943. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18944. return
  18945. }
  18946. infocode = resThree.Infcode
  18947. } else if miConfig.MdtrtareaAdmvs == "430800" {
  18948. psn_info, _ := service.GetPsnByPatientId(id)
  18949. var result string
  18950. var requestLog string
  18951. if id_card_type == 1 {
  18952. bas := strings.Split(psn_info.CardInfo, "|")
  18953. basNumber := bas[2]
  18954. card_sn := bas[3]
  18955. 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)
  18956. saveLog(result, requestLog, "2201A", "挂号")
  18957. } else if id_card_type == 2 {
  18958. 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, "", "")
  18959. saveLog(result, requestLog, "2201A", "挂号")
  18960. } else {
  18961. 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, "", "")
  18962. saveLog(result, requestLog, "2201A", "挂号")
  18963. }
  18964. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  18965. utils.ErrorLog("解析失败:%v", err)
  18966. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18967. return
  18968. }
  18969. infocode = resThree.Infcode
  18970. } else if miConfig.MdtrtareaAdmvs == "131023" {
  18971. psn_info, _ := service.GetPsnByPatientId(id)
  18972. 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)
  18973. saveLog(result, requestLog, "2201A", "挂号")
  18974. if miConfig.Code == "H15049901371" {
  18975. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  18976. utils.ErrorLog("解析失败:%v", err)
  18977. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18978. return
  18979. }
  18980. resThree.ErrMsg = resThree10265.ErrMsg
  18981. resThree.Output = resThree10265.Output
  18982. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  18983. } else {
  18984. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  18985. utils.ErrorLog("解析失败:%v", err)
  18986. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18987. return
  18988. }
  18989. }
  18990. if miConfig.Code == "H15049901371" {
  18991. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  18992. } else {
  18993. infocode = resThree.Infcode
  18994. }
  18995. } else {
  18996. psn_info, _ := service.GetPsnByPatientId(id)
  18997. if id_card_type == 4 || id_card_type == 1 {
  18998. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  18999. }
  19000. var rf []*ResultFive
  19001. json.Unmarshal([]byte(psn_info.Insuinfo), &rf)
  19002. var insutypes []*ResultFive
  19003. var insutype string
  19004. var is390 int = 0
  19005. var is310 int = 0
  19006. for _, item := range rf {
  19007. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  19008. insutypes = append(insutypes, item)
  19009. }
  19010. }
  19011. if len(insutypes) == 1 {
  19012. insutype = insutypes[0].Insutype
  19013. insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  19014. } else {
  19015. for _, i := range insutypes {
  19016. if i.Insutype == "390" {
  19017. is390 = 1
  19018. }
  19019. if i.Insutype == "310" {
  19020. is310 = 1
  19021. }
  19022. }
  19023. }
  19024. if is390 == 1 {
  19025. insutype = "390"
  19026. }
  19027. if is310 == 1 {
  19028. insutype = "310"
  19029. }
  19030. fmt.Println(len(insutypes))
  19031. if len(insutypes) == 0 {
  19032. for index, item := range rf {
  19033. if index == 0 {
  19034. insutype = item.Insutype
  19035. insuplc_admdvs = item.InsuplcAdmdvs
  19036. }
  19037. }
  19038. fmt.Println(insutype)
  19039. fmt.Println(insuplc_admdvs)
  19040. }
  19041. if social_type > 0 {
  19042. insutype = strconv.FormatInt(social_type, 10)
  19043. }
  19044. fmt.Println("--------")
  19045. fmt.Println(psn_info)
  19046. fmt.Println(psn_info.PsnNo)
  19047. if miConfig.MdtrtareaAdmvs == "441202" {
  19048. var hisPrescription []*models.HisPrescription
  19049. res3101 := Checkgd3101ForOne(c, patient.ID, his, admin_user_id, "1", record_time, hisPrescription)
  19050. if res3101.Infcode == 0 {
  19051. fmt.Println("33333333")
  19052. if len(res3101.Output.Result) > 0 {
  19053. fmt.Println("222222")
  19054. for _, item := range res3101.Output.Result {
  19055. if len(res3101.ErrMsg) == 0 {
  19056. res3101.ErrMsg = item.VolaCont
  19057. } else {
  19058. res3101.ErrMsg = res3101.ErrMsg + "\n" + item.VolaCont
  19059. }
  19060. }
  19061. c.ServeSuccessJSON(map[string]interface{}{
  19062. "failed_code": -10,
  19063. "msg": res3101.ErrMsg,
  19064. })
  19065. return
  19066. } else {
  19067. hour := time.Now().Format("15")
  19068. min := time.Now().Format("04")
  19069. sec := time.Now().Format("05")
  19070. record_time_two := record_time + " " + hour + ":" + min + ":" + sec
  19071. fmt.Println(record_time_two)
  19072. 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)
  19073. saveLog(result, requestLog, "2201A", "挂号")
  19074. if miConfig.Code == "H15049901371" {
  19075. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  19076. utils.ErrorLog("解析失败:%v", err)
  19077. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19078. return
  19079. }
  19080. resThree.ErrMsg = resThree10265.ErrMsg
  19081. resThree.Output = resThree10265.Output
  19082. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  19083. } else {
  19084. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  19085. utils.ErrorLog("解析失败:%v", err)
  19086. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19087. return
  19088. }
  19089. }
  19090. if miConfig.Code == "H15049901371" {
  19091. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  19092. } else {
  19093. infocode = resThree.Infcode
  19094. }
  19095. }
  19096. } else if res3101.Infcode != 0 {
  19097. c.ServeSuccessJSON(map[string]interface{}{
  19098. "failed_code": -10,
  19099. "msg": res3101.ErrMsg,
  19100. })
  19101. return
  19102. }
  19103. } else if miConfig.MdtrtareaAdmvs == "441799" {
  19104. doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  19105. psn_info, _ := service.GetPsnByPatientId(id)
  19106. var verify_number string
  19107. if id_card_type == 4 {
  19108. verify_number = psn_info.VerifyNumber
  19109. } else if id_card_type == 1 {
  19110. bas := strings.Split(psn_info.CardInfo, "|")
  19111. cardNumber := bas[2]
  19112. verify_number = cardNumber
  19113. } else {
  19114. verify_number = psn_info.Certno
  19115. }
  19116. api := miConfig.Url + "gdyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  19117. "&org_name=" + miConfig.OrgName + "&operator=" + roles.UserName + "&doctor=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  19118. "&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
  19119. resp, requestErr := http.Get(api)
  19120. if requestErr != nil {
  19121. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19122. return
  19123. }
  19124. body, ioErr := ioutil.ReadAll(resp.Body)
  19125. if ioErr != nil {
  19126. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19127. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19128. return
  19129. }
  19130. var respJSON map[string]interface{}
  19131. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  19132. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19133. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19134. return
  19135. }
  19136. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  19137. result, _ := json.Marshal(respJSON)
  19138. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  19139. utils.ErrorLog("解析失败:%v", err)
  19140. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19141. return
  19142. }
  19143. infocode = resThree.Infcode
  19144. } else {
  19145. hour := time.Now().Format("15")
  19146. min := time.Now().Format("04")
  19147. sec := time.Now().Format("05")
  19148. record_time_two := record_time + " " + hour + ":" + min + ":" + sec
  19149. if id_card_type == 1 {
  19150. for _, item := range rf {
  19151. if item.Insutype == strconv.FormatInt(social_type, 10) {
  19152. if strconv.FormatInt(social_type, 10) == "310" && item.PsnInsuStas == "1" {
  19153. insuplc_admdvs_temp = item.InsuplcAdmdvs
  19154. } else if strconv.FormatInt(social_type, 10) == "390" {
  19155. insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  19156. } else {
  19157. insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  19158. }
  19159. }
  19160. }
  19161. }
  19162. if miConfig.MdtrtareaAdmvs == "440205" && strconv.FormatInt(social_type, 10) == "390" {
  19163. insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  19164. }
  19165. if id_card_type == 1 {
  19166. utils.ErrorLog("解析失败:%v", psn_info.CardInfo)
  19167. bas := strings.Split(psn_info.CardInfo, "|")
  19168. basNumber := bas[1]
  19169. IdCardNo = basNumber
  19170. }
  19171. if miConfig.MdtrtareaAdmvs == "450721" && id_card_type == 1 {
  19172. IdCardNo = psn_info.VerifyNumber
  19173. }
  19174. 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)
  19175. saveLog(result, requestLog, "2201A", "挂号")
  19176. if miConfig.Code == "H15049901371" {
  19177. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  19178. utils.ErrorLog("解析失败:%v", err)
  19179. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19180. return
  19181. }
  19182. resThree.ErrMsg = resThree10265.ErrMsg
  19183. resThree.Output = resThree10265.Output
  19184. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  19185. } else {
  19186. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  19187. utils.ErrorLog("解析失败:%v", err)
  19188. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19189. return
  19190. }
  19191. }
  19192. if miConfig.Code == "H15049901371" {
  19193. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  19194. } else {
  19195. infocode = resThree.Infcode
  19196. }
  19197. }
  19198. }
  19199. if infocode != 0 {
  19200. adminUser := c.GetAdminUserInfo()
  19201. errlog := &models.HisOrderError{
  19202. UserOrgId: adminUser.CurrentOrgId,
  19203. Ctime: time.Now().Unix(),
  19204. Mtime: time.Now().Unix(),
  19205. ErrMsg: resThree.ErrMsg,
  19206. Status: 1,
  19207. PatientId: id,
  19208. RecordTime: recordDateTime,
  19209. Stage: 2,
  19210. }
  19211. service.CreateErrMsgLog(errlog)
  19212. c.ServeSuccessJSON(map[string]interface{}{
  19213. "failed_code": -10,
  19214. "msg": resThree.ErrMsg,
  19215. })
  19216. return
  19217. }
  19218. his.Number = resThree.Output.Data.MdtrtID
  19219. his.PsnNo = resThree.Output.Data.PsnNo
  19220. his.IptOtpNo = resThree.Output.Data.IptOtpNo
  19221. his.IdCardNo = patient.IdCardNo
  19222. his.PhoneNumber = patient.Phone
  19223. his.UserOrgId = adminInfo.CurrentOrgId
  19224. his.Insutype = insutype
  19225. his.Ctime = time.Now().Unix()
  19226. his.Mtime = time.Now().Unix()
  19227. his.InsuplcAdmdvs = insuplc_admdvs_temp
  19228. if miConfig.MdtrtareaAdmvs == "421300" && strings.Contains(insuplc_admdvs_temp, "4213") {
  19229. his.InsuplcAdmdvs = miConfig.MdtrtareaAdmvs
  19230. }
  19231. if miConfig.MdtrtareaAdmvs == "420200" && strings.Contains(insuplc_admdvs_temp, "4202") {
  19232. his.InsuplcAdmdvs = miConfig.MdtrtareaAdmvs
  19233. }
  19234. if miConfig.MdtrtareaAdmvs == "421182" && strings.Contains(insuplc_admdvs_temp, "4211") {
  19235. his.InsuplcAdmdvs = miConfig.MdtrtareaAdmvs
  19236. }
  19237. his.Status = 1
  19238. his.MdtrtGrpType = mdtrt_type
  19239. service.UpdateHisPatientStatus(&his)
  19240. service.UpdateHisPrescriptionHisID(his.ID, patient.ID, recordDateTime, adminInfo.CurrentOrgId)
  19241. c.ServeSuccessJSON(map[string]interface{}{
  19242. "his_info": his,
  19243. })
  19244. } else {
  19245. adminUser := c.GetAdminUserInfo()
  19246. errlog := &models.HisOrderError{
  19247. UserOrgId: adminUser.CurrentOrgId,
  19248. Ctime: time.Now().Unix(),
  19249. Mtime: time.Now().Unix(),
  19250. ErrMsg: res.ErrMsg,
  19251. Status: 1,
  19252. PatientId: id,
  19253. RecordTime: recordDateTime,
  19254. Stage: 1,
  19255. }
  19256. service.CreateErrMsgLog(errlog)
  19257. c.ServeSuccessJSON(map[string]interface{}{
  19258. "failed_code": -10,
  19259. "msg": res.ErrMsg,
  19260. })
  19261. return
  19262. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  19263. }
  19264. }
  19265. }
  19266. func (c *HisApiController) GetUploadInfo() {
  19267. id, _ := c.GetInt64("id")
  19268. record_time := c.GetString("record_time")
  19269. his_patient_id, _ := c.GetInt64("his_patient_id")
  19270. order_id, _ := c.GetInt64("order_id")
  19271. pay_way, _ := c.GetInt64("pay_way")
  19272. pay_ways := c.GetString("pay_ways")
  19273. oth_desc := c.GetString("oth_desc")
  19274. pay_price, _ := c.GetFloat("pay_price")
  19275. pay_card_no := c.GetString("pay_card_no")
  19276. discount_price, _ := c.GetFloat("discount_price")
  19277. preferential_price, _ := c.GetFloat("preferential_price")
  19278. reality_price, _ := c.GetFloat("reality_price")
  19279. found_price, _ := c.GetFloat("found_price")
  19280. medical_insurance_price, _ := c.GetFloat("medical_insurance_price")
  19281. private_price, _ := c.GetFloat("private_price")
  19282. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  19283. admin_user_id, _ := c.GetInt64("admin_user_id")
  19284. fapiao_code := c.GetString("fapiao_code")
  19285. fapiao_number := c.GetString("fapiao_number")
  19286. diagnosis_id := c.GetString("diagnosis")
  19287. sick_type, _ := c.GetInt64("sick_type")
  19288. reg_type, _ := c.GetInt64("p_type")
  19289. begin_time := c.GetString("begin_time")
  19290. acct_used_flag_num, _ := c.GetInt64("acct_used_flag")
  19291. cash_pay := c.GetString("cash_pay")
  19292. band_card_pay := c.GetString("band_card_pay")
  19293. wechat_pay := c.GetString("wechat_pay")
  19294. ali_pay := c.GetString("ali_pay")
  19295. jifen_pay := c.GetString("jifen_pay")
  19296. acct_used_flag := strconv.FormatInt(acct_used_flag_num, 10)
  19297. fmt.Println(acct_used_flag)
  19298. id_str := c.GetString("ids")
  19299. ids_arr := strings.Split(id_str, ",")
  19300. timeLayout := "2006-01-02"
  19301. loc, _ := time.LoadLocation("Local")
  19302. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  19303. if err != nil {
  19304. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  19305. return
  19306. }
  19307. recordDateTime := theTime.Unix()
  19308. adminUser := c.GetAdminUserInfo()
  19309. var tempOrder models.HisOrder
  19310. tempOrder, _ = service.GetHisOrderByID(order_id)
  19311. var prescriptions []*models.HisPrescription
  19312. var start_time int64
  19313. var end_time int64
  19314. //押金模块
  19315. dec_way := c.GetString("dec_way") //是否使用押金支付bool类型
  19316. tmp_decimal := c.GetString("tmp_decimal")
  19317. var decimal float64 //本次使用的押金
  19318. var errmsg error
  19319. if dec_way == "true" && tmp_decimal == "0" || dec_way == "true" && tmp_decimal == "" {
  19320. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "押金不能为0")
  19321. return
  19322. }
  19323. if len(tmp_decimal) > 0 {
  19324. if tmp_decimal[0] == 45 {
  19325. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "押金不能为负数")
  19326. return
  19327. }
  19328. }
  19329. tt, errs := strconv.ParseFloat(tmp_decimal, 64)
  19330. fmt.Println(errs)
  19331. decimal = tt
  19332. //if adminUser.CurrentOrgId == 10106{
  19333. // if len(fapiao_code) == 0{
  19334. // fapiao_code = "144072080589"
  19335. // }
  19336. // if len(fapiao_number) == 0{
  19337. // order, _ := service.GetLastHisOrder(adminUser.CurrentOrgId)
  19338. // if order.ID == 0{
  19339. // fapiao_number = "00001520"
  19340. // }else{
  19341. // //fapiao_code = "00001520"
  19342. // fpNumber, _ := strconv.Atoi(order.FaPiaoNumber)
  19343. // var zero string
  19344. // if fpNumber >= 1000{
  19345. // zero = "0000" + strconv.Itoa(fpNumber)
  19346. // }else if fpNumber >= 10000{
  19347. // zero = "000" + strconv.Itoa(fpNumber)
  19348. // } else if fpNumber >= 100000{
  19349. // zero = "00" + strconv.Itoa(fpNumber)
  19350. // } else if fpNumber >= 1000000{
  19351. // zero = "0" + strconv.Itoa(fpNumber)
  19352. // }else {
  19353. // zero = strconv.Itoa(fpNumber)
  19354. // }
  19355. // fapiao_number = zero
  19356. // }
  19357. // }
  19358. //}
  19359. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  19360. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  19361. var patientPrescription models.HisPrescriptionInfo
  19362. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  19363. if patientPrescription.ID == 0 {
  19364. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  19365. }
  19366. //if patientPrescription.Do
  19367. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  19368. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  19369. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  19370. diagnosis_ids := strings.Split(diagnosis_id, ",")
  19371. var config []*models.HisXtDiagnoseConfig
  19372. for _, item := range diagnosis_ids {
  19373. id, _ := strconv.ParseInt(item, 10, 64)
  19374. diagnosisConfig, _ := service.FindDiagnoseById(id)
  19375. config = append(config, &diagnosisConfig)
  19376. }
  19377. sickConfig, _ := service.FindSickById(sick_type)
  19378. //if tempOrder.ID == 0 {
  19379. // tempOrder, _ = service.GetTodayHisOrder(adminUser.CurrentOrgId, id, recordDateTime, his.Number)
  19380. //}
  19381. if tempOrder.ID == 0 {
  19382. var result string
  19383. var requestLog string
  19384. var res2 ResultSix
  19385. var res3 GZResultSix
  19386. var ressix10265 ResultSix10265
  19387. if miConfig.MdtrtareaAdmvs == "421300" {
  19388. data := make(map[string]interface{})
  19389. client := &http.Client{}
  19390. data["psn_no"] = his.PsnNo
  19391. data["mdtrt_id"] = his.Number
  19392. data["opter"] = roles.UserName
  19393. data["org_name"] = miConfig.OrgName
  19394. data["med_type"] = strconv.FormatInt(reg_type, 10)
  19395. data["doctor_id"] = doctor_info.DoctorNumber
  19396. data["doctor_name"] = doctor_info.UserName
  19397. data["department"] = department.Name
  19398. data["fixmedins_code"] = miConfig.Code
  19399. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  19400. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  19401. data["secret_key"] = miConfig.SecretKey
  19402. data["sick_code"] = sickConfig.CountryCode
  19403. data["sick_name"] = sickConfig.ClassName
  19404. data["dept"] = strconv.FormatInt(department.ID, 10)
  19405. data["config"] = config
  19406. data["begin_time"] = begin_time
  19407. bytesData, _ := json.Marshal(data)
  19408. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  19409. resp, _ := client.Do(req)
  19410. defer resp.Body.Close()
  19411. body, ioErr := ioutil.ReadAll(resp.Body)
  19412. if ioErr != nil {
  19413. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19414. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19415. return
  19416. }
  19417. var respJSON map[string]interface{}
  19418. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  19419. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19420. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19421. return
  19422. }
  19423. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  19424. userJSONBytes, _ := json.Marshal(respJSON)
  19425. fmt.Println("log")
  19426. fmt.Println(string(userJSONBytes))
  19427. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  19428. utils.ErrorLog("解析失败:%v", err)
  19429. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19430. return
  19431. }
  19432. } else if miConfig.MdtrtareaAdmvs == "420200" {
  19433. data := make(map[string]interface{})
  19434. client := &http.Client{}
  19435. data["psn_no"] = his.PsnNo
  19436. data["mdtrt_id"] = his.Number
  19437. data["opter"] = roles.UserName
  19438. data["org_name"] = miConfig.OrgName
  19439. if reg_type == 11 && his.Insutype == "390" {
  19440. data["med_type"] = "110104"
  19441. } else {
  19442. data["med_type"] = strconv.FormatInt(reg_type, 10)
  19443. }
  19444. data["doctor_id"] = doctor_info.DoctorNumber
  19445. data["doctor_name"] = doctor_info.UserName
  19446. data["department"] = department.Name
  19447. data["fixmedins_code"] = miConfig.Code
  19448. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  19449. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  19450. data["secret_key"] = miConfig.SecretKey
  19451. data["sick_code"] = sickConfig.CountryCode
  19452. data["sick_name"] = sickConfig.ClassName
  19453. data["dept"] = strconv.FormatInt(department.ID, 10)
  19454. data["config"] = config
  19455. data["begin_time"] = begin_time
  19456. bytesData, _ := json.Marshal(data)
  19457. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  19458. resp, _ := client.Do(req)
  19459. defer resp.Body.Close()
  19460. body, ioErr := ioutil.ReadAll(resp.Body)
  19461. if ioErr != nil {
  19462. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19463. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19464. return
  19465. }
  19466. var respJSON map[string]interface{}
  19467. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  19468. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19469. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19470. return
  19471. }
  19472. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  19473. userJSONBytes, _ := json.Marshal(respJSON)
  19474. fmt.Println("log")
  19475. fmt.Println(string(userJSONBytes))
  19476. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  19477. utils.ErrorLog("解析失败:%v", err)
  19478. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19479. return
  19480. }
  19481. } else if miConfig.MdtrtareaAdmvs == "420902" {
  19482. data := make(map[string]interface{})
  19483. client := &http.Client{}
  19484. data["psn_no"] = his.PsnNo
  19485. data["mdtrt_id"] = his.Number
  19486. data["opter"] = roles.UserName
  19487. data["org_name"] = miConfig.OrgName
  19488. if reg_type == 11 && his.Insutype == "390" {
  19489. data["med_type"] = "110104"
  19490. } else {
  19491. data["med_type"] = strconv.FormatInt(reg_type, 10)
  19492. }
  19493. data["doctor_id"] = doctor_info.DoctorNumber
  19494. data["doctor_name"] = doctor_info.UserName
  19495. data["department"] = department.Name
  19496. data["fixmedins_code"] = miConfig.Code
  19497. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  19498. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  19499. data["secret_key"] = miConfig.SecretKey
  19500. data["sick_code"] = sickConfig.CountryCode
  19501. data["sick_name"] = sickConfig.ClassName
  19502. data["dept"] = strconv.FormatInt(department.ID, 10)
  19503. data["config"] = config
  19504. data["begin_time"] = begin_time
  19505. bytesData, _ := json.Marshal(data)
  19506. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2203", bytes.NewReader(bytesData))
  19507. resp, _ := client.Do(req)
  19508. defer resp.Body.Close()
  19509. body, ioErr := ioutil.ReadAll(resp.Body)
  19510. if ioErr != nil {
  19511. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19512. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19513. return
  19514. }
  19515. var respJSON map[string]interface{}
  19516. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  19517. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19518. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19519. return
  19520. }
  19521. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  19522. userJSONBytes, _ := json.Marshal(respJSON)
  19523. fmt.Println("log")
  19524. fmt.Println(string(userJSONBytes))
  19525. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  19526. utils.ErrorLog("解析失败:%v", err)
  19527. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19528. return
  19529. }
  19530. } else if miConfig.MdtrtareaAdmvs == "421182" {
  19531. data := make(map[string]interface{})
  19532. client := &http.Client{}
  19533. data["psn_no"] = his.PsnNo
  19534. data["mdtrt_id"] = his.Number
  19535. data["opter"] = roles.UserName
  19536. data["org_name"] = miConfig.OrgName
  19537. if reg_type == 11 && his.Insutype == "390" {
  19538. data["med_type"] = "110104"
  19539. } else {
  19540. data["med_type"] = strconv.FormatInt(reg_type, 10)
  19541. }
  19542. data["doctor_id"] = doctor_info.DoctorNumber
  19543. data["doctor_name"] = doctor_info.UserName
  19544. data["department"] = department.Name
  19545. data["fixmedins_code"] = miConfig.Code
  19546. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  19547. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  19548. data["secret_key"] = miConfig.SecretKey
  19549. data["sick_code"] = sickConfig.CountryCode
  19550. data["sick_name"] = sickConfig.ClassName
  19551. data["dept"] = strconv.FormatInt(department.ID, 10)
  19552. data["config"] = config
  19553. data["begin_time"] = begin_time
  19554. bytesData, _ := json.Marshal(data)
  19555. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2203", bytes.NewReader(bytesData))
  19556. resp, _ := client.Do(req)
  19557. defer resp.Body.Close()
  19558. body, ioErr := ioutil.ReadAll(resp.Body)
  19559. if ioErr != nil {
  19560. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19561. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19562. return
  19563. }
  19564. var respJSON map[string]interface{}
  19565. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  19566. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19567. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19568. return
  19569. }
  19570. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  19571. userJSONBytes, _ := json.Marshal(respJSON)
  19572. fmt.Println("log")
  19573. fmt.Println(string(userJSONBytes))
  19574. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  19575. utils.ErrorLog("解析失败:%v", err)
  19576. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19577. return
  19578. }
  19579. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  19580. data := make(map[string]interface{})
  19581. client := &http.Client{}
  19582. data["psn_no"] = his.PsnNo
  19583. data["mdtrt_id"] = his.Number
  19584. data["doctor"] = roles.UserName
  19585. data["department"] = department.Name
  19586. data["org_name"] = miConfig.OrgName
  19587. data["med_type"] = strconv.FormatInt(reg_type, 10)
  19588. data["doctor_id"] = doctor_info.DoctorNumber
  19589. data["new_doctor_name"] = doctor_info.UserName
  19590. data["fixmedins_code"] = miConfig.Code
  19591. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  19592. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  19593. data["secret_key"] = miConfig.SecretKey
  19594. data["sick_code"] = sickConfig.CountryCode
  19595. data["sick_name"] = sickConfig.ClassName
  19596. data["url"] = miConfig.Url
  19597. data["ak"] = miConfig.AccessKey
  19598. data["begin_time"] = begin_time
  19599. data["cainfo"] = miConfig.Cainfo
  19600. data["dept"] = strconv.FormatInt(department.ID, 10)
  19601. data["config"] = config
  19602. bytesData, _ := json.Marshal(data)
  19603. var req *http.Request
  19604. if miConfig.MdtrtareaAdmvs == "320921" {
  19605. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  19606. //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 +
  19607. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo
  19608. } else {
  19609. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  19610. }
  19611. resp, _ := client.Do(req)
  19612. defer resp.Body.Close()
  19613. body, ioErr := ioutil.ReadAll(resp.Body)
  19614. if ioErr != nil {
  19615. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19616. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19617. return
  19618. }
  19619. var respJSON map[string]interface{}
  19620. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  19621. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19622. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19623. return
  19624. }
  19625. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  19626. userJSONBytes, _ := json.Marshal(respJSON)
  19627. fmt.Println("log")
  19628. fmt.Println(string(userJSONBytes))
  19629. if err := json.Unmarshal(userJSONBytes, &ressix10265); err != nil {
  19630. utils.ErrorLog("解析失败:%v", err)
  19631. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19632. return
  19633. }
  19634. res2.InfRefmsgid = ressix10265.InfRefmsgid
  19635. res2.Output = ressix10265.Output
  19636. res2.ErrMsg = ressix10265.ErrMsg
  19637. res2.Cainfo = ressix10265.Cainfo
  19638. res2.WarnMsg = ressix10265.WarnMsg
  19639. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  19640. res2.Infcode = infocode
  19641. } else if miConfig.MdtrtareaAdmvs == "150499" {
  19642. data := make(map[string]interface{})
  19643. client := &http.Client{}
  19644. data["psn_no"] = his.PsnNo
  19645. data["mdtrt_id"] = his.Number
  19646. data["doctor"] = roles.UserName
  19647. data["department"] = department.Name
  19648. data["org_name"] = miConfig.OrgName
  19649. data["med_type"] = strconv.FormatInt(reg_type, 10)
  19650. data["doctor_id"] = doctor_info.DoctorNumber
  19651. data["new_doctor_name"] = doctor_info.UserName
  19652. data["fixmedins_code"] = miConfig.Code
  19653. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  19654. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  19655. data["secret_key"] = miConfig.SecretKey
  19656. data["sick_code"] = sickConfig.CountryCode
  19657. data["sick_name"] = sickConfig.ClassName
  19658. data["url"] = miConfig.Url
  19659. data["ak"] = miConfig.AccessKey
  19660. data["begin_time"] = begin_time
  19661. data["cainfo"] = miConfig.Cainfo
  19662. data["dept"] = strconv.FormatInt(department.ID, 10)
  19663. data["config"] = config
  19664. bytesData, _ := json.Marshal(data)
  19665. var req *http.Request
  19666. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2203", bytes.NewReader(bytesData))
  19667. resp, _ := client.Do(req)
  19668. defer resp.Body.Close()
  19669. body, ioErr := ioutil.ReadAll(resp.Body)
  19670. if ioErr != nil {
  19671. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19672. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19673. return
  19674. }
  19675. var respJSON map[string]interface{}
  19676. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  19677. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19678. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19679. return
  19680. }
  19681. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  19682. userJSONBytes, _ := json.Marshal(respJSON)
  19683. fmt.Println("log")
  19684. fmt.Println(string(userJSONBytes))
  19685. if err := json.Unmarshal(userJSONBytes, &ressix10265); err != nil {
  19686. utils.ErrorLog("解析失败:%v", err)
  19687. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19688. return
  19689. }
  19690. res2.InfRefmsgid = ressix10265.InfRefmsgid
  19691. res2.Output = ressix10265.Output
  19692. res2.ErrMsg = ressix10265.ErrMsg
  19693. res2.Cainfo = ressix10265.Cainfo
  19694. res2.WarnMsg = ressix10265.WarnMsg
  19695. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  19696. res2.Infcode = infocode
  19697. } else if miConfig.MdtrtareaAdmvs == "350500" {
  19698. 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)
  19699. saveLog(result, requestLog, "2203", "上传就诊信息")
  19700. var respJSON2 map[string]interface{}
  19701. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  19702. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19703. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19704. return
  19705. }
  19706. userJSONBytes2, _ := json.Marshal(respJSON2)
  19707. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  19708. utils.ErrorLog("解析失败:%v", err)
  19709. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19710. return
  19711. }
  19712. 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)
  19713. fmt.Println(result2)
  19714. fmt.Println(src_request)
  19715. } else if miConfig.MdtrtareaAdmvs == "441799" {
  19716. data := make(map[string]interface{})
  19717. client := &http.Client{}
  19718. data["psn_no"] = his.PsnNo
  19719. data["mdtrt_id"] = his.Number
  19720. data["doctor"] = roles.UserName
  19721. data["department"] = department.Name
  19722. data["org_name"] = miConfig.OrgName
  19723. data["med_type"] = strconv.FormatInt(reg_type, 10)
  19724. data["doctor_id"] = doctor_info.DoctorNumber
  19725. data["new_doctor_name"] = doctor_info.UserName
  19726. data["fixmedins_code"] = miConfig.Code
  19727. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  19728. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  19729. data["secret_key"] = miConfig.SecretKey
  19730. data["sick_code"] = sickConfig.CountryCode
  19731. data["sick_name"] = sickConfig.ClassName
  19732. data["url"] = miConfig.Url
  19733. data["ak"] = miConfig.AccessKey
  19734. data["begin_time"] = begin_time
  19735. data["cainfo"] = miConfig.Cainfo
  19736. data["dept"] = strconv.FormatInt(department.ID, 10)
  19737. data["config"] = config
  19738. bytesData, _ := json.Marshal(data)
  19739. var req *http.Request
  19740. req, _ = http.NewRequest("POST", "http://172.20.10.81:9532/"+"gdyb/2203", bytes.NewReader(bytesData))
  19741. resp, _ := client.Do(req)
  19742. defer resp.Body.Close()
  19743. body, ioErr := ioutil.ReadAll(resp.Body)
  19744. if ioErr != nil {
  19745. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19746. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19747. return
  19748. }
  19749. var respJSON map[string]interface{}
  19750. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  19751. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19752. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19753. return
  19754. }
  19755. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  19756. userJSONBytes, _ := json.Marshal(respJSON)
  19757. fmt.Println("log")
  19758. fmt.Println(string(userJSONBytes))
  19759. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  19760. utils.ErrorLog("解析失败:%v", err)
  19761. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19762. return
  19763. }
  19764. } else {
  19765. if miConfig.MdtrtareaAdmvs == "440781" { //
  19766. 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)
  19767. } else {
  19768. if miConfig.Code == "H15049901371" {
  19769. //赤峰地区国家医保医疗类别
  19770. //职工透析:医疗类别选特殊情况门诊990502
  19771. //居民定额血透门慢: 医疗类别选门诊慢病140104
  19772. var med_type string
  19773. if his.Insutype == "390" {
  19774. if reg_type == 14 {
  19775. med_type = "9933"
  19776. } else if reg_type == 11 {
  19777. med_type = "11"
  19778. }
  19779. } else if his.Insutype == "310" {
  19780. if reg_type == 14 {
  19781. med_type = "990502"
  19782. } else if reg_type == 11 {
  19783. med_type = "11"
  19784. }
  19785. }
  19786. 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)
  19787. } else {
  19788. 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)
  19789. }
  19790. }
  19791. saveLog(result, requestLog, "2203", "上传就诊信息")
  19792. var respJSON2 map[string]interface{}
  19793. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  19794. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19795. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19796. return
  19797. }
  19798. userJSONBytes2, _ := json.Marshal(respJSON2)
  19799. if miConfig.Code == "H15049901371" {
  19800. if err := json.Unmarshal(userJSONBytes2, &ressix10265); err != nil {
  19801. utils.ErrorLog("解析失败:%v", err)
  19802. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19803. return
  19804. }
  19805. res2.InfRefmsgid = ressix10265.InfRefmsgid
  19806. res2.Output = ressix10265.Output
  19807. res2.ErrMsg = ressix10265.ErrMsg
  19808. res2.Cainfo = ressix10265.Cainfo
  19809. res2.WarnMsg = ressix10265.WarnMsg
  19810. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  19811. res2.Infcode = infocode
  19812. } else {
  19813. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  19814. if err := json.Unmarshal(userJSONBytes2, &res3); err != nil {
  19815. utils.ErrorLog("解析失败:%v", err)
  19816. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19817. return
  19818. }
  19819. res2.Infcode = res3.Infcode
  19820. } else {
  19821. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  19822. utils.ErrorLog("解析失败:%v", err)
  19823. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19824. return
  19825. }
  19826. }
  19827. }
  19828. }
  19829. if res2.Infcode != 0 {
  19830. adminUser := c.GetAdminUserInfo()
  19831. errlog := &models.HisOrderError{
  19832. UserOrgId: adminUser.CurrentOrgId,
  19833. Ctime: time.Now().Unix(),
  19834. Mtime: time.Now().Unix(),
  19835. ErrMsg: res2.ErrMsg,
  19836. Status: 1,
  19837. PatientId: id,
  19838. RecordTime: recordDateTime,
  19839. Stage: 3,
  19840. }
  19841. service.CreateErrMsgLog(errlog)
  19842. c.ServeSuccessJSON(map[string]interface{}{
  19843. "failed_code": -10,
  19844. "msg": res2.ErrMsg,
  19845. })
  19846. return
  19847. } else {
  19848. his.Diagnosis = diagnosis_id
  19849. his.SickType = sickConfig.ID
  19850. //var p_type int64
  19851. //if reg_type == 1111 || reg_type == 1112 {
  19852. // p_type = 11
  19853. //
  19854. //}
  19855. his.PType = fmt.Sprintf("%d", reg_type)
  19856. service.UpdateHisPatientThree(&his)
  19857. data := make(map[string]interface{})
  19858. if settle_accounts_type == 1 { //日结
  19859. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  19860. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  19861. } else {
  19862. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  19863. }
  19864. //prescriptions, _ = service.GetNewHisPrescriptionTwo(adminUser.CurrentOrgId, his_patient_id, recordDateTime, reg_type)
  19865. data["pre"] = prescriptions
  19866. } else { //月结
  19867. start_time_str := c.GetString("start_time")
  19868. end_time_str := c.GetString("end_time")
  19869. timeLayout := "2006-01-02"
  19870. loc, _ := time.LoadLocation("Local")
  19871. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  19872. if err != nil {
  19873. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  19874. return
  19875. }
  19876. recordStartTime := theStartTime.Unix()
  19877. start_time = recordStartTime
  19878. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  19879. if err != nil {
  19880. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  19881. return
  19882. }
  19883. recordEndTime := theEndTime.Unix()
  19884. end_time = recordEndTime
  19885. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  19886. data["pre"] = prescriptions
  19887. }
  19888. timestamp := time.Now().Unix()
  19889. tempTime := time.Unix(timestamp, 0)
  19890. timeFormat := tempTime.Format("20060102150405")
  19891. chrgBchno := rand.Intn(100000) + 10000
  19892. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  19893. strconv.FormatInt(his.PatientId, 10)
  19894. client := &http.Client{}
  19895. data["psn_no"] = his.PsnNo
  19896. data["mdtrt_id"] = his.Number
  19897. data["chrg_bchno"] = chrg_bchno
  19898. data["org_name"] = miConfig.OrgName
  19899. data["doctor"] = doctor_info.UserName
  19900. data["doctor_id"] = doctor_info.DoctorNumber
  19901. data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  19902. data["fixmedins_code"] = miConfig.Code
  19903. data["dept_code"] = department.Number
  19904. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  19905. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  19906. data["secret_key"] = miConfig.SecretKey
  19907. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  19908. data["url"] = miConfig.Url
  19909. data["ak"] = miConfig.AccessKey
  19910. data["new_doctor_name"] = patientPrescription.Doctor
  19911. data["diag_code"] = sickConfig.CountryCode
  19912. data["cainfo"] = miConfig.Cainfo
  19913. data["opter"] = roles.UserName
  19914. var ids []int64
  19915. for _, item := range prescriptions {
  19916. ids = append(ids, item.ID)
  19917. }
  19918. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  19919. if config.IsOpen == 1 { //对接了医保,走医保流程
  19920. var res ResultFour
  19921. var resFour10265 ResultFour10265
  19922. if miConfig.MdtrtareaAdmvs == "421300" {
  19923. bytesData, _ := json.Marshal(data)
  19924. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  19925. resp, _ := client.Do(req)
  19926. defer resp.Body.Close()
  19927. body, ioErr := ioutil.ReadAll(resp.Body)
  19928. if ioErr != nil {
  19929. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19930. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19931. return
  19932. }
  19933. var respJSON map[string]interface{}
  19934. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  19935. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19936. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19937. return
  19938. }
  19939. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  19940. userJSONBytes, _ := json.Marshal(respJSON)
  19941. fmt.Println("log")
  19942. fmt.Println(string(userJSONBytes))
  19943. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19944. utils.ErrorLog("解析失败:%v", err)
  19945. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19946. return
  19947. }
  19948. } else if miConfig.MdtrtareaAdmvs == "420200" {
  19949. bytesData, _ := json.Marshal(data)
  19950. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  19951. resp, _ := client.Do(req)
  19952. defer resp.Body.Close()
  19953. body, ioErr := ioutil.ReadAll(resp.Body)
  19954. if ioErr != nil {
  19955. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19956. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19957. return
  19958. }
  19959. var respJSON map[string]interface{}
  19960. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  19961. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19962. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19963. return
  19964. }
  19965. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  19966. userJSONBytes, _ := json.Marshal(respJSON)
  19967. fmt.Println("log")
  19968. fmt.Println(string(userJSONBytes))
  19969. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19970. utils.ErrorLog("解析失败:%v", err)
  19971. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19972. return
  19973. }
  19974. } else if miConfig.MdtrtareaAdmvs == "420902" {
  19975. bytesData, _ := json.Marshal(data)
  19976. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2204", bytes.NewReader(bytesData))
  19977. resp, _ := client.Do(req)
  19978. defer resp.Body.Close()
  19979. body, ioErr := ioutil.ReadAll(resp.Body)
  19980. if ioErr != nil {
  19981. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19982. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19983. return
  19984. }
  19985. var respJSON map[string]interface{}
  19986. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  19987. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19988. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19989. return
  19990. }
  19991. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  19992. userJSONBytes, _ := json.Marshal(respJSON)
  19993. fmt.Println("log")
  19994. fmt.Println(string(userJSONBytes))
  19995. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19996. utils.ErrorLog("解析失败:%v", err)
  19997. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19998. return
  19999. }
  20000. } else if miConfig.MdtrtareaAdmvs == "421182" {
  20001. bytesData, _ := json.Marshal(data)
  20002. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2204", bytes.NewReader(bytesData))
  20003. resp, _ := client.Do(req)
  20004. defer resp.Body.Close()
  20005. body, ioErr := ioutil.ReadAll(resp.Body)
  20006. if ioErr != nil {
  20007. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  20008. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20009. return
  20010. }
  20011. var respJSON map[string]interface{}
  20012. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  20013. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  20014. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20015. return
  20016. }
  20017. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  20018. userJSONBytes, _ := json.Marshal(respJSON)
  20019. fmt.Println("log")
  20020. fmt.Println(string(userJSONBytes))
  20021. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20022. utils.ErrorLog("解析失败:%v", err)
  20023. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20024. return
  20025. }
  20026. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  20027. result3101 := Check3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  20028. if result3101.Infcode == "0" {
  20029. if len(result3101.Output.Result) > 0 {
  20030. var errMsgs []string
  20031. for _, item := range result3101.Output.Result {
  20032. errMsgs = append(errMsgs, item.VolaCont)
  20033. }
  20034. c.ServeSuccessJSON(map[string]interface{}{
  20035. "failed_code": -10,
  20036. "msg": errMsgs,
  20037. })
  20038. return
  20039. }
  20040. }
  20041. bytesData, _ := json.Marshal(data)
  20042. var req *http.Request
  20043. if miConfig.MdtrtareaAdmvs == "320921" {
  20044. data["diag_code"] = sickConfig.CountryCode
  20045. fmt.Println(data)
  20046. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  20047. } else {
  20048. data["diag_code"] = sickConfig.CountryCode
  20049. fmt.Println(data)
  20050. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  20051. }
  20052. resp, _ := client.Do(req)
  20053. defer resp.Body.Close()
  20054. body, ioErr := ioutil.ReadAll(resp.Body)
  20055. if ioErr != nil {
  20056. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  20057. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20058. return
  20059. }
  20060. var respJSON map[string]interface{}
  20061. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  20062. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  20063. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20064. return
  20065. }
  20066. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  20067. userJSONBytes, _ := json.Marshal(respJSON)
  20068. fmt.Println("log")
  20069. fmt.Println(string(userJSONBytes))
  20070. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  20071. utils.ErrorLog("解析失败:%v", err)
  20072. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20073. return
  20074. }
  20075. res.InfRefmsgid = resFour10265.InfRefmsgid
  20076. res.Output = resFour10265.Output
  20077. res.ErrMsg = resFour10265.ErrMsg
  20078. res.Cainfo = resFour10265.Cainfo
  20079. res.WarnMsg = resFour10265.WarnMsg
  20080. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  20081. res.Infcode = infocode
  20082. } else if miConfig.MdtrtareaAdmvs == "150499" {
  20083. var pagesize int = 2
  20084. var start int = 1
  20085. var stop int
  20086. var pagecount int
  20087. var curpage int
  20088. var isSuccess bool = true
  20089. data["doctor_id"] = doctor_info.DoctorNumber
  20090. //总页数,向上取整,注意除之前要先转换类型为float64
  20091. pagecount = int(math.Ceil(float64(len(prescriptions)) / float64(pagesize)))
  20092. for curpage = 1; curpage <= pagecount; curpage++ {
  20093. if curpage == 1 {
  20094. start = 1
  20095. } else {
  20096. start = (curpage-1)*pagesize + 1
  20097. }
  20098. stop = curpage * pagesize
  20099. if stop > len(prescriptions) {
  20100. stop = len(prescriptions)
  20101. }
  20102. //var requestLog string
  20103. data["pre"] = prescriptions[start-1 : stop]
  20104. fmt.Println(data["pre"])
  20105. bytesData, _ := json.Marshal(data)
  20106. var req *http.Request
  20107. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2204", bytes.NewReader(bytesData))
  20108. resp, _ := client.Do(req)
  20109. defer resp.Body.Close()
  20110. body, ioErr := ioutil.ReadAll(resp.Body)
  20111. if ioErr != nil {
  20112. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  20113. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20114. return
  20115. }
  20116. var respJSON map[string]interface{}
  20117. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  20118. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  20119. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20120. return
  20121. }
  20122. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  20123. userJSONBytes, _ := json.Marshal(respJSON)
  20124. fmt.Println("log")
  20125. fmt.Println(string(userJSONBytes))
  20126. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  20127. utils.ErrorLog("解析失败:%v", err)
  20128. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20129. return
  20130. }
  20131. res.InfRefmsgid = resFour10265.InfRefmsgid
  20132. res.Output = resFour10265.Output
  20133. res.ErrMsg = resFour10265.ErrMsg
  20134. res.Cainfo = resFour10265.Cainfo
  20135. res.WarnMsg = resFour10265.WarnMsg
  20136. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  20137. res.Infcode = infocode
  20138. if infocode == 0 {
  20139. res.Output.Result = append(res.Output.Result, res.Output.Result...)
  20140. } else {
  20141. isSuccess = false
  20142. errlog := &models.HisOrderError{
  20143. UserOrgId: adminUser.CurrentOrgId,
  20144. Ctime: time.Now().Unix(),
  20145. Mtime: time.Now().Unix(),
  20146. Number: chrg_bchno,
  20147. ErrMsg: "",
  20148. Status: 1,
  20149. PatientId: id,
  20150. RecordTime: recordDateTime,
  20151. Stage: 4,
  20152. }
  20153. service.CreateErrMsgLog(errlog)
  20154. c.ServeSuccessJSON(map[string]interface{}{
  20155. "failed_code": -10,
  20156. "msg": res.ErrMsg,
  20157. })
  20158. return
  20159. }
  20160. }
  20161. if isSuccess {
  20162. res.Infcode = 0
  20163. }
  20164. } else if miConfig.MdtrtareaAdmvs == "350500" {
  20165. 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)
  20166. var dat map[string]interface{}
  20167. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  20168. fmt.Println(dat)
  20169. } else {
  20170. fmt.Println(err)
  20171. }
  20172. saveLog(result, request_log, "2204", "上传费用明细")
  20173. userJSONBytes, _ := json.Marshal(dat)
  20174. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  20175. utils.ErrorLog("解析失败:%v", err)
  20176. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20177. return
  20178. }
  20179. res.InfRefmsgid = resFour10265.InfRefmsgid
  20180. res.Output = resFour10265.Output
  20181. res.ErrMsg = resFour10265.ErrMsg
  20182. res.Cainfo = resFour10265.Cainfo
  20183. res.WarnMsg = resFour10265.WarnMsg
  20184. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  20185. res.Infcode = infocode
  20186. } else if miConfig.MdtrtareaAdmvs == "441799" {
  20187. bytesData, _ := json.Marshal(data)
  20188. req, _ := http.NewRequest("POST", miConfig.Url+"gdyb/2204", bytes.NewReader(bytesData))
  20189. resp, _ := client.Do(req)
  20190. defer resp.Body.Close()
  20191. body, ioErr := ioutil.ReadAll(resp.Body)
  20192. if ioErr != nil {
  20193. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  20194. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20195. return
  20196. }
  20197. var respJSON map[string]interface{}
  20198. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  20199. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  20200. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20201. return
  20202. }
  20203. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  20204. userJSONBytes, _ := json.Marshal(respJSON)
  20205. fmt.Println("log")
  20206. fmt.Println(string(userJSONBytes))
  20207. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20208. utils.ErrorLog("解析失败:%v", err)
  20209. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20210. return
  20211. }
  20212. } else {
  20213. if miConfig.Code == "H15049901371" {
  20214. 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)
  20215. var dat map[string]interface{}
  20216. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  20217. fmt.Println(dat)
  20218. } else {
  20219. fmt.Println(err)
  20220. }
  20221. saveLog(result, request_log, "2204", "上传费用明细")
  20222. userJSONBytes, _ := json.Marshal(dat)
  20223. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  20224. utils.ErrorLog("解析失败:%v", err)
  20225. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20226. return
  20227. }
  20228. res.InfRefmsgid = resFour10265.InfRefmsgid
  20229. res.Output = resFour10265.Output
  20230. res.ErrMsg = resFour10265.ErrMsg
  20231. res.Cainfo = resFour10265.Cainfo
  20232. res.WarnMsg = resFour10265.WarnMsg
  20233. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  20234. res.Infcode = infocode
  20235. } else {
  20236. 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)
  20237. var dat map[string]interface{}
  20238. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  20239. fmt.Println(dat)
  20240. } else {
  20241. fmt.Println(err)
  20242. }
  20243. saveLog(result, request_log, "2204", "上传费用明细")
  20244. userJSONBytes, _ := json.Marshal(dat)
  20245. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20246. utils.ErrorLog("解析失败:%v", err)
  20247. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20248. return
  20249. }
  20250. }
  20251. }
  20252. if res.Infcode == 0 {
  20253. order := &models.HisOrder{
  20254. UserOrgId: adminUser.CurrentOrgId,
  20255. HisPatientId: his.ID,
  20256. PatientId: his.PatientId,
  20257. SettleAccountsDate: recordDateTime,
  20258. MdtrtId: his.Number,
  20259. PsnNo: his.PsnNo,
  20260. MedType: strconv.FormatInt(reg_type, 10),
  20261. Ctime: time.Now().Unix(),
  20262. Mtime: time.Now().Unix(),
  20263. Status: 1,
  20264. Number: chrg_bchno,
  20265. Infcode: res.Infcode,
  20266. WarnMsg: res.WarnMsg,
  20267. Cainfo: res.Cainfo,
  20268. ErrMsg: res.ErrMsg,
  20269. RespondTime: res.RefmsgTime,
  20270. InfRefmsgid: res.InfRefmsgid,
  20271. OrderStatus: 1,
  20272. PayWay: pay_way,
  20273. PayWays: pay_ways,
  20274. OthDesc: oth_desc,
  20275. PayPrice: pay_price,
  20276. PayCardNo: pay_card_no,
  20277. DiscountPrice: discount_price,
  20278. PreferentialPrice: preferential_price,
  20279. RealityPrice: reality_price,
  20280. FoundPrice: found_price,
  20281. MedicalInsurancePrice: medical_insurance_price,
  20282. PrivatePrice: private_price,
  20283. IsMedicineInsurance: 1,
  20284. SettleType: settle_accounts_type,
  20285. SettleStartTime: start_time,
  20286. SettleEndTime: end_time,
  20287. Creator: roles.AdminUserId,
  20288. Modify: roles.AdminUserId,
  20289. FaPiaoNumber: fapiao_number,
  20290. FaPiaoCode: fapiao_code,
  20291. PType: 2,
  20292. Diagnosis: diagnosis_id,
  20293. CashPay: cash_pay,
  20294. WechatPay: wechat_pay,
  20295. AliPay: ali_pay,
  20296. JifenPay: jifen_pay,
  20297. BandCardPay: band_card_pay,
  20298. }
  20299. err = service.CreateOrder(order)
  20300. if err != nil {
  20301. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  20302. return
  20303. }
  20304. for _, item := range res.Output.Result {
  20305. temp := strings.Split(item.FeedetlSn, "-")
  20306. var advice_id int64 = 0
  20307. var project_id int64 = 0
  20308. var types int64 = 0
  20309. id, _ := strconv.ParseInt(temp[2], 10, 64)
  20310. types, _ = strconv.ParseInt(temp[1], 10, 64)
  20311. if temp[1] == "1" {
  20312. advice_id = id
  20313. project_id = 0
  20314. } else if temp[1] == "2" {
  20315. advice_id = 0
  20316. project_id = id
  20317. }
  20318. if item.MedChrgitmType == "9" {
  20319. item.MedChrgitmType = "09"
  20320. }
  20321. info := &models.HisOrderInfo{
  20322. OrderNumber: order.Number,
  20323. FeedetlSn: item.FeedetlSn,
  20324. UploadDate: time.Now().Unix(),
  20325. AdviceId: advice_id,
  20326. DetItemFeeSumamt: item.DetItemFeeSumamt,
  20327. Cnt: item.Cnt,
  20328. Pric: float64(item.Pric),
  20329. PatientId: his.PatientId,
  20330. PricUplmtAmt: item.PricUplmtAmt,
  20331. SelfpayProp: item.SelfpayProp,
  20332. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  20333. OverlmtAmt: item.OverlmtAmt,
  20334. PreselfpayAmt: item.PreselfpayAmt,
  20335. BasMednFlag: item.BasMednFlag,
  20336. MedChrgitmType: item.MedChrgitmType,
  20337. HiNegoDrugFlag: item.HiNegoDrugFlag,
  20338. Status: 1,
  20339. Memo: item.Memo,
  20340. Mtime: time.Now().Unix(),
  20341. InscpScpAmt: item.InscpScpAmt,
  20342. DrtReimFlag: item.DrtReimFlag,
  20343. Ctime: time.Now().Unix(),
  20344. ListSpItemFlag: item.ListSpItemFlag,
  20345. ChldMedcFlag: item.ChldMedcFlag,
  20346. LmtUsedFlag: item.LmtUsedFlag,
  20347. ChrgitmLv: item.ChrgitmLv,
  20348. UserOrgId: adminUser.CurrentOrgId,
  20349. HisPatientId: his.ID,
  20350. OrderId: order.ID,
  20351. ProjectId: project_id,
  20352. Type: types,
  20353. }
  20354. service.CreateOrderInfo(info)
  20355. }
  20356. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  20357. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  20358. var total float64
  20359. for _, item := range prescriptions {
  20360. if item.Type == 1 { //药品
  20361. for _, subItem := range item.HisDoctorAdviceInfo {
  20362. price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  20363. total_one := price * subItem.PrescribingNumber
  20364. total = total + total_one
  20365. }
  20366. }
  20367. if item.Type == 2 { //项目
  20368. for _, subItem := range item.HisPrescriptionProject {
  20369. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  20370. price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  20371. total_one := price * cnt
  20372. total = total + total_one
  20373. }
  20374. }
  20375. }
  20376. allTotal := fmt.Sprintf("%.2f", total)
  20377. //if adminUser.CurrentOrgId == 9919 {
  20378. //
  20379. // allTotal = fmt.Sprintf("%.2f", total)
  20380. //
  20381. //} else {
  20382. //
  20383. // allTotal = fmt.Sprintf("%.2f", total)
  20384. //
  20385. //}
  20386. if res.Infcode == 0 {
  20387. var rf []*ResultFive
  20388. json.Unmarshal([]byte(his.Iinfo), &rf)
  20389. chrg_bchno := chrg_bchno
  20390. cert_no := his.Certno
  20391. var insutypes []string
  20392. var insutype string
  20393. var is390 int = 0
  20394. var is310 int = 0
  20395. for _, item := range rf {
  20396. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  20397. insutypes = append(insutypes, item.Insutype)
  20398. }
  20399. }
  20400. if len(insutypes) == 1 {
  20401. insutype = insutypes[0]
  20402. } else {
  20403. for _, i := range insutypes {
  20404. if i == "390" {
  20405. is390 = 1
  20406. }
  20407. if i == "310" {
  20408. is310 = 1
  20409. }
  20410. }
  20411. }
  20412. if is390 == 1 {
  20413. insutype = "390"
  20414. }
  20415. if is310 == 1 {
  20416. insutype = "310"
  20417. }
  20418. if len(insutypes) == 0 {
  20419. insutype = "310"
  20420. }
  20421. if len(insutypes) == 2 {
  20422. insutype = strconv.FormatInt(his.SocialType, 10)
  20423. }
  20424. insutype = strconv.FormatInt(his.SocialType, 10)
  20425. //insutype = "390"
  20426. if his.IdCardType == 1 {
  20427. // cert_no = his.MedicalInsuranceNumber
  20428. cert_no = his.Certno
  20429. } else {
  20430. cert_no = his.Certno
  20431. }
  20432. var res ResultSeven
  20433. var resSeven10265 ResultSeven10265
  20434. var gzresSeven10265Two GZResultSeven10265Two
  20435. var src_resquest string
  20436. var result2 string
  20437. if miConfig.MdtrtareaAdmvs == "421300" {
  20438. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  20439. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  20440. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  20441. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  20442. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  20443. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  20444. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  20445. resp, requestErr := http.Get(api)
  20446. if requestErr != nil {
  20447. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20448. return
  20449. }
  20450. body, ioErr := ioutil.ReadAll(resp.Body)
  20451. if ioErr != nil {
  20452. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  20453. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20454. return
  20455. }
  20456. var respJSON map[string]interface{}
  20457. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  20458. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  20459. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20460. return
  20461. }
  20462. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  20463. result, _ := json.Marshal(respJSON)
  20464. if miConfig.Code == "H15049901371" {
  20465. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  20466. utils.ErrorLog("解析失败:%v", err)
  20467. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20468. return
  20469. }
  20470. res.InfRefmsgid = resSeven10265.InfRefmsgid
  20471. res.Output = resSeven10265.Output
  20472. res.ErrMsg = resSeven10265.ErrMsg
  20473. res.Cainfo = resSeven10265.Cainfo
  20474. res.WarnMsg = resSeven10265.WarnMsg
  20475. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  20476. res.Infcode = infocode
  20477. } else {
  20478. if err := json.Unmarshal([]byte(result), &res); err != nil {
  20479. utils.ErrorLog("解析失败:%v", err)
  20480. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20481. return
  20482. }
  20483. }
  20484. } else if miConfig.MdtrtareaAdmvs == "420200" {
  20485. if reg_type == 11 && his.Insutype == "390" {
  20486. reg_type = 110104
  20487. }
  20488. api := "http://192.168.0.197:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  20489. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  20490. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  20491. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  20492. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  20493. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  20494. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  20495. resp, requestErr := http.Get(api)
  20496. if requestErr != nil {
  20497. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20498. return
  20499. }
  20500. body, ioErr := ioutil.ReadAll(resp.Body)
  20501. if ioErr != nil {
  20502. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  20503. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20504. return
  20505. }
  20506. var respJSON map[string]interface{}
  20507. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  20508. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  20509. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20510. return
  20511. }
  20512. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  20513. result, _ := json.Marshal(respJSON)
  20514. if miConfig.Code == "H15049901371" {
  20515. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  20516. utils.ErrorLog("解析失败:%v", err)
  20517. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20518. return
  20519. }
  20520. res.InfRefmsgid = resSeven10265.InfRefmsgid
  20521. res.Output = resSeven10265.Output
  20522. res.ErrMsg = resSeven10265.ErrMsg
  20523. res.Cainfo = resSeven10265.Cainfo
  20524. res.WarnMsg = resSeven10265.WarnMsg
  20525. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  20526. res.Infcode = infocode
  20527. } else {
  20528. if err := json.Unmarshal([]byte(result), &res); err != nil {
  20529. utils.ErrorLog("解析失败:%v", err)
  20530. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20531. return
  20532. }
  20533. }
  20534. } else if miConfig.MdtrtareaAdmvs == "420902" {
  20535. if reg_type == 11 && his.Insutype == "390" {
  20536. reg_type = 110104
  20537. }
  20538. api := miConfig.Url + "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. if miConfig.Code == "H15049901371" {
  20565. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  20566. utils.ErrorLog("解析失败:%v", err)
  20567. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20568. return
  20569. }
  20570. res.InfRefmsgid = resSeven10265.InfRefmsgid
  20571. res.Output = resSeven10265.Output
  20572. res.ErrMsg = resSeven10265.ErrMsg
  20573. res.Cainfo = resSeven10265.Cainfo
  20574. res.WarnMsg = resSeven10265.WarnMsg
  20575. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  20576. res.Infcode = infocode
  20577. } else {
  20578. if err := json.Unmarshal([]byte(result), &res); err != nil {
  20579. utils.ErrorLog("解析失败:%v", err)
  20580. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20581. return
  20582. }
  20583. }
  20584. } else if miConfig.MdtrtareaAdmvs == "421182" {
  20585. if reg_type == 11 && his.Insutype == "390" {
  20586. reg_type = 110104
  20587. }
  20588. api := miConfig.Url + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  20589. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  20590. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  20591. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  20592. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  20593. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  20594. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  20595. resp, requestErr := http.Get(api)
  20596. if requestErr != nil {
  20597. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20598. return
  20599. }
  20600. body, ioErr := ioutil.ReadAll(resp.Body)
  20601. if ioErr != nil {
  20602. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  20603. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20604. return
  20605. }
  20606. var respJSON map[string]interface{}
  20607. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  20608. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  20609. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20610. return
  20611. }
  20612. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  20613. result, _ := json.Marshal(respJSON)
  20614. if miConfig.Code == "H15049901371" {
  20615. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  20616. utils.ErrorLog("解析失败:%v", err)
  20617. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20618. return
  20619. }
  20620. res.InfRefmsgid = resSeven10265.InfRefmsgid
  20621. res.Output = resSeven10265.Output
  20622. res.ErrMsg = resSeven10265.ErrMsg
  20623. res.Cainfo = resSeven10265.Cainfo
  20624. res.WarnMsg = resSeven10265.WarnMsg
  20625. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  20626. res.Infcode = infocode
  20627. } else {
  20628. if err := json.Unmarshal([]byte(result), &res); err != nil {
  20629. utils.ErrorLog("解析失败:%v", err)
  20630. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20631. return
  20632. }
  20633. }
  20634. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  20635. result3101 := Check3102(c, id, his_patient_id, admin_user_id, "7", order.ID)
  20636. if result3101.Infcode == "0" {
  20637. if len(result3101.Output.Result) > 0 {
  20638. var errMsgs []string
  20639. for _, item := range result3101.Output.Result {
  20640. errMsgs = append(errMsgs, item.VolaCont)
  20641. }
  20642. c.ServeSuccessJSON(map[string]interface{}{
  20643. "failed_code": -10,
  20644. "msg": errMsgs,
  20645. })
  20646. return
  20647. } else {
  20648. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  20649. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  20650. bas := strings.Split(psn_info.CardInfo, "|")
  20651. if his.IdCardType == 1 {
  20652. cert_no = bas[2]
  20653. } else if his.IdCardType == 3 {
  20654. cert_no = his.Certno
  20655. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  20656. } else if his.IdCardType == 4 {
  20657. cert_no = his.Certno
  20658. psn_info.VerifyNumber = psn_info.VerifyNumber
  20659. }
  20660. var api string
  20661. if miConfig.MdtrtareaAdmvs == "320921" {
  20662. api = "http://192.168.2.3:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  20663. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  20664. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  20665. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  20666. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  20667. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  20668. "&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
  20669. } else {
  20670. api = "http://192.168.5.251:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  20671. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  20672. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  20673. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  20674. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  20675. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  20676. "&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
  20677. }
  20678. resp, requestErr := http.Get(api)
  20679. if requestErr != nil {
  20680. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20681. return
  20682. }
  20683. body, ioErr := ioutil.ReadAll(resp.Body)
  20684. if ioErr != nil {
  20685. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  20686. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20687. return
  20688. }
  20689. var respJSON map[string]interface{}
  20690. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  20691. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  20692. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20693. return
  20694. }
  20695. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  20696. result, _ := json.Marshal(respJSON)
  20697. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  20698. utils.ErrorLog("解析失败:%v", err)
  20699. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20700. return
  20701. }
  20702. res.InfRefmsgid = resSeven10265.InfRefmsgid
  20703. res.Output = resSeven10265.Output
  20704. res.ErrMsg = resSeven10265.ErrMsg
  20705. res.Cainfo = resSeven10265.Cainfo
  20706. res.WarnMsg = resSeven10265.WarnMsg
  20707. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  20708. res.Infcode = infocode
  20709. }
  20710. }
  20711. } else if miConfig.MdtrtareaAdmvs == "150499" {
  20712. psn_info, _ := service.GetPsnByPatientId(id)
  20713. var verify_number string
  20714. if psn_info.IdCardType == 4 {
  20715. verify_number = psn_info.VerifyNumber
  20716. } else if psn_info.IdCardType == 1 {
  20717. bas := strings.Split(psn_info.CardInfo, "|")
  20718. cardNumber := bas[2]
  20719. verify_number = cardNumber
  20720. } else {
  20721. psn_info.IdCardType = 2
  20722. verify_number = psn_info.Certno
  20723. }
  20724. var api string
  20725. api = "http://172.16.13.254:9532/" + "nmyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  20726. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  20727. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  20728. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  20729. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  20730. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  20731. "&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
  20732. resp, requestErr := http.Get(api)
  20733. if requestErr != nil {
  20734. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20735. return
  20736. }
  20737. body, ioErr := ioutil.ReadAll(resp.Body)
  20738. if ioErr != nil {
  20739. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  20740. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20741. return
  20742. }
  20743. var respJSON map[string]interface{}
  20744. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  20745. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  20746. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20747. return
  20748. }
  20749. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  20750. result, _ := json.Marshal(respJSON)
  20751. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  20752. utils.ErrorLog("解析失败:%v", err)
  20753. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20754. return
  20755. }
  20756. res.InfRefmsgid = resSeven10265.InfRefmsgid
  20757. res.Output = resSeven10265.Output
  20758. res.ErrMsg = resSeven10265.ErrMsg
  20759. res.Cainfo = resSeven10265.Cainfo
  20760. res.WarnMsg = resSeven10265.WarnMsg
  20761. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  20762. res.Infcode = infocode
  20763. } else if miConfig.MdtrtareaAdmvs == "350500" {
  20764. var cert_no string
  20765. if his.IdCardType == 4 {
  20766. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  20767. cert_no = psn_info.VerifyNumber
  20768. 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)
  20769. } else if his.IdCardType == 1 {
  20770. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  20771. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  20772. 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)
  20773. }
  20774. //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)
  20775. var dat map[string]interface{}
  20776. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  20777. fmt.Println(dat)
  20778. } else {
  20779. fmt.Println(err)
  20780. }
  20781. saveLog(result2, src_resquest, "2207", "结算")
  20782. userJSONBytes, _ := json.Marshal(dat)
  20783. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  20784. utils.ErrorLog("解析失败:%v", err)
  20785. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20786. return
  20787. }
  20788. res.InfRefmsgid = resSeven10265.InfRefmsgid
  20789. res.Output = resSeven10265.Output
  20790. res.ErrMsg = resSeven10265.ErrMsg
  20791. res.Cainfo = resSeven10265.Cainfo
  20792. res.WarnMsg = resSeven10265.WarnMsg
  20793. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  20794. res.Infcode = infocode
  20795. } else if miConfig.MdtrtareaAdmvs == "450721" {
  20796. res2 := c.GetoleInfo()
  20797. if res2.Infcode == 0 {
  20798. var result string
  20799. var request_log string
  20800. var result_log string
  20801. if res2.Output.MdtrtCertType == "02" {
  20802. 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)
  20803. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  20804. } else if res2.Output.MdtrtCertType == "01" {
  20805. 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)
  20806. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  20807. } else {
  20808. 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)
  20809. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  20810. }
  20811. var dat map[string]interface{}
  20812. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  20813. fmt.Println(dat)
  20814. } else {
  20815. fmt.Println(err)
  20816. }
  20817. userJSONBytes, _ := json.Marshal(dat)
  20818. var res5 ResultTwo
  20819. //var resTwo10265 ResultTwo10265
  20820. if err := json.Unmarshal(userJSONBytes, &res5); err != nil {
  20821. utils.ErrorLog("解析失败:%v", err)
  20822. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20823. return
  20824. }
  20825. if res5.Infcode == -1 {
  20826. c.ServeSuccessJSON(map[string]interface{}{
  20827. "failed_code": -10,
  20828. "msg": res5.ErrMsg,
  20829. })
  20830. return
  20831. }
  20832. var insutypes []string
  20833. var insutype string
  20834. var is390 int = 0
  20835. var is310 int = 0
  20836. for _, item := range res5.Output.Iinfo {
  20837. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  20838. insutypes = append(insutypes, item.Insutype)
  20839. }
  20840. }
  20841. if len(insutypes) == 1 {
  20842. insutype = insutypes[0]
  20843. } else {
  20844. for _, i := range insutypes {
  20845. if i == "390" {
  20846. is390 = 1
  20847. }
  20848. if i == "310" {
  20849. is310 = 1
  20850. }
  20851. }
  20852. }
  20853. if is390 == 1 {
  20854. insutype = "390"
  20855. }
  20856. if is310 == 1 {
  20857. insutype = "310"
  20858. }
  20859. if len(insutypes) == 0 {
  20860. insutype = "310"
  20861. }
  20862. Iinfos, _ := json.Marshal(res5.Output.Iinfo)
  20863. Idetinfos, _ := json.Marshal(res5.Output.Idetinfo)
  20864. infoStr := string(Iinfos)
  20865. idetinfoStr := string(Idetinfos)
  20866. psn := &models.HisPsn{
  20867. PsnNo: res5.Output.Baseinfo.PsnNo,
  20868. PatientId: id,
  20869. Certno: res5.Output.Baseinfo.Certno,
  20870. Gend: res5.Output.Baseinfo.Gend,
  20871. Naty: res5.Output.Baseinfo.Naty,
  20872. PsnCertType: res5.Output.Baseinfo.PsnCertType,
  20873. PsnName: res5.Output.Baseinfo.PsnName,
  20874. Idetinfo: idetinfoStr,
  20875. Insuinfo: infoStr,
  20876. CardInfo: res2.Output.CardNo + "|" + res2.Output.CardSN,
  20877. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  20878. VerifyNumber: res2.Output.EcToken,
  20879. }
  20880. if res2.Output.MdtrtCertType == "01" {
  20881. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  20882. psn.VerifyNumber = res2.Output.EcToken
  20883. } else if res2.Output.MdtrtCertType == "02" {
  20884. psn.VerifyNumber = res2.Output.CardNo
  20885. } else {
  20886. psn.VerifyNumber = res2.Output.MdtrtCertNo
  20887. }
  20888. service.CreateHisPsn(psn)
  20889. if res2.Output.MdtrtCertType == "01" {
  20890. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  20891. token := res2.Output.EcToken
  20892. 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)
  20893. } else if res2.Output.MdtrtCertType == "02" {
  20894. 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)
  20895. } else {
  20896. 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)
  20897. }
  20898. var dat2 map[string]interface{}
  20899. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  20900. fmt.Println(dat2)
  20901. } else {
  20902. fmt.Println(err)
  20903. }
  20904. userJSONBytes3, _ := json.Marshal(dat2)
  20905. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  20906. utils.ErrorLog("解析失败:%v", err)
  20907. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20908. return
  20909. }
  20910. saveLog(result2, src_resquest, "2207", "结算")
  20911. } else {
  20912. c.ServeSuccessJSON(map[string]interface{}{
  20913. "failed_code": -10,
  20914. "msg": res2.ErrMsg,
  20915. })
  20916. return
  20917. }
  20918. } else {
  20919. if miConfig.Code == "H15049901371" {
  20920. //赤峰地区国家医保医疗类别
  20921. //职工透析:医疗类别选特殊情况门诊990502
  20922. //居民定额血透门慢: 医疗类别选门诊慢病140104
  20923. var med_type string
  20924. if his.Insutype == "390" {
  20925. if reg_type == 14 {
  20926. med_type = "9933"
  20927. } else if reg_type == 11 {
  20928. med_type = "11"
  20929. }
  20930. } else if his.Insutype == "310" {
  20931. if reg_type == 14 {
  20932. med_type = "990502"
  20933. } else if reg_type == 11 {
  20934. med_type = "11"
  20935. }
  20936. }
  20937. 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)
  20938. } else {
  20939. if his.IdCardType == 4 {
  20940. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  20941. var token string
  20942. token = psn_info.VerifyNumber
  20943. 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)
  20944. } else {
  20945. if his.IdCardType == 1 {
  20946. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  20947. bas := strings.Split(psn_info.CardInfo, "|")
  20948. basNumber := bas[2]
  20949. cert_no = basNumber
  20950. }
  20951. 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)
  20952. }
  20953. }
  20954. //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)
  20955. var dat map[string]interface{}
  20956. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  20957. fmt.Println(dat)
  20958. } else {
  20959. fmt.Println(err)
  20960. }
  20961. saveLog(result2, src_resquest, "2207", "结算")
  20962. userJSONBytes, _ := json.Marshal(dat)
  20963. if miConfig.Code == "H15049901371" {
  20964. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  20965. utils.ErrorLog("解析失败:%v", err)
  20966. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20967. return
  20968. }
  20969. res.InfRefmsgid = resSeven10265.InfRefmsgid
  20970. res.Output = resSeven10265.Output
  20971. res.ErrMsg = resSeven10265.ErrMsg
  20972. res.Cainfo = resSeven10265.Cainfo
  20973. res.WarnMsg = resSeven10265.WarnMsg
  20974. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  20975. res.Infcode = infocode
  20976. } else {
  20977. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  20978. if err := json.Unmarshal(userJSONBytes, &gzresSeven10265Two); err != nil {
  20979. utils.ErrorLog("解析失败:%v", err)
  20980. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20981. return
  20982. }
  20983. res.InfRefmsgid = gzresSeven10265Two.InfRefmsgid
  20984. res.Output.Setlinfo.AcctMulaidPay = gzresSeven10265Two.Output.Setlinfo.AcctMulaidPay
  20985. res.Output.Setlinfo.AcctPay = gzresSeven10265Two.Output.Setlinfo.AcctPay
  20986. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  20987. res.Output.Setlinfo.ActPayDedc = gzresSeven10265Two.Output.Setlinfo.ActPayDedc
  20988. res.Output.Setlinfo.Age = gzresSeven10265Two.Output.Setlinfo.Age
  20989. res.Output.Setlinfo.Balc = gzresSeven10265Two.Output.Setlinfo.Balc
  20990. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  20991. res.Output.Setlinfo.Certno = gzresSeven10265Two.Output.Setlinfo.Certno
  20992. res.Output.Setlinfo.ClrOptins = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  20993. res.Output.Setlinfo.ClrType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  20994. res.Output.Setlinfo.ClrWay = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  20995. res.Output.Setlinfo.CvlservFlag = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  20996. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  20997. res.Output.Setlinfo.FulamtOwnpayAmt = gzresSeven10265Two.Output.Setlinfo.FulamtOwnpayAmt
  20998. res.Output.Setlinfo.FundPaySumamt = gzresSeven10265Two.Output.Setlinfo.FundPaySumamt
  20999. res.Output.Setlinfo.Gend = gzresSeven10265Two.Output.Setlinfo.Gend
  21000. res.Output.Setlinfo.HifesPay = gzresSeven10265Two.Output.Setlinfo.HifesPay
  21001. res.Output.Setlinfo.HifmiPay = gzresSeven10265Two.Output.Setlinfo.HifmiPay
  21002. res.Output.Setlinfo.HifpPay = gzresSeven10265Two.Output.Setlinfo.HifpPay
  21003. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  21004. res.Output.Setlinfo.HospPartAmt = gzresSeven10265Two.Output.Setlinfo.HospPartAmt
  21005. res.Output.Setlinfo.InscpScpAmt = gzresSeven10265Two.Output.Setlinfo.InscpScpAmt
  21006. res.Output.Setlinfo.Insutype = gzresSeven10265Two.Output.Setlinfo.Insutype
  21007. res.Output.Setlinfo.MafPay = gzresSeven10265Two.Output.Setlinfo.MafPay
  21008. res.Output.Setlinfo.MdtrtCertType = gzresSeven10265Two.Output.Setlinfo.MdtrtCertType
  21009. res.Output.Setlinfo.HifobPay = gzresSeven10265Two.Output.Setlinfo.HifobPay
  21010. res.Output.Setlinfo.MdtrtID = gzresSeven10265Two.Output.Setlinfo.MdtrtID
  21011. res.Output.Setlinfo.MedType = gzresSeven10265Two.Output.Setlinfo.MedType
  21012. res.Output.Setlinfo.MedfeeSumamt = gzresSeven10265Two.Output.Setlinfo.MedfeeSumamt
  21013. res.Output.Setlinfo.MedinsSetlID = gzresSeven10265Two.Output.Setlinfo.MedinsSetlID
  21014. res.Output.Setlinfo.Naty = gzresSeven10265Two.Output.Setlinfo.Naty
  21015. res.Output.Setlinfo.OthPay = gzresSeven10265Two.Output.Setlinfo.OthPay
  21016. res.Output.Setlinfo.OverlmtSelfpay = gzresSeven10265Two.Output.Setlinfo.OverlmtSelfpay
  21017. PoolPropSelfpay, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.PoolPropSelfpay, 64)
  21018. res.Output.Setlinfo.PoolPropSelfpay = PoolPropSelfpay
  21019. res.Output.Setlinfo.PreselfpayAmt = gzresSeven10265Two.Output.Setlinfo.PreselfpayAmt
  21020. res.Output.Setlinfo.PsnCashPay = gzresSeven10265Two.Output.Setlinfo.PsnCashPay
  21021. res.Output.Setlinfo.PsnCertType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  21022. res.Output.Setlinfo.PsnName = gzresSeven10265Two.Output.Setlinfo.PsnName
  21023. res.Output.Setlinfo.PsnNo = gzresSeven10265Two.Output.Setlinfo.PsnNo
  21024. res.Output.Setlinfo.PsnPartAmt = gzresSeven10265Two.Output.Setlinfo.PsnPartAmt
  21025. res.Output.Setlinfo.PsnType = gzresSeven10265Two.Output.Setlinfo.PsnType
  21026. res.Output.Setlinfo.SetlID = gzresSeven10265Two.Output.Setlinfo.SetlID
  21027. res.Output.Setlinfo.SetlTime = gzresSeven10265Two.Output.Setlinfo.SetlTime
  21028. //res.Output.Setldetail = gzresSeven10265Two.Output.Setldetail
  21029. res.ErrMsg = gzresSeven10265Two.ErrMsg
  21030. res.Cainfo = gzresSeven10265Two.Cainfo
  21031. res.WarnMsg = gzresSeven10265Two.WarnMsg
  21032. //infocode, _ := strconv.ParseInt(resSeven10265Two.Infcode, 10, 64)
  21033. //res.Infcode = infocode
  21034. } else {
  21035. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  21036. utils.ErrorLog("解析失败:%v", err)
  21037. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21038. return
  21039. }
  21040. }
  21041. }
  21042. }
  21043. if res.Infcode == -1 {
  21044. errlog := &models.HisOrderError{
  21045. UserOrgId: adminUser.CurrentOrgId,
  21046. Ctime: time.Now().Unix(),
  21047. Mtime: time.Now().Unix(),
  21048. Number: chrg_bchno,
  21049. ErrMsg: res.ErrMsg,
  21050. Status: 1,
  21051. PatientId: id,
  21052. RecordTime: recordDateTime,
  21053. Stage: 6,
  21054. }
  21055. service.CreateErrMsgLog(errlog)
  21056. c.ServeSuccessJSON(map[string]interface{}{
  21057. "failed_code": -10,
  21058. "msg": res.ErrMsg,
  21059. })
  21060. return
  21061. } else {
  21062. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  21063. order.OrderStatus = 2
  21064. order.Status = 1
  21065. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  21066. order.SetlId = res.Output.Setlinfo.SetlID
  21067. order.PsnNo = res.Output.Setlinfo.PsnNo
  21068. order.PsnName = res.Output.Setlinfo.PsnName
  21069. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  21070. order.Certno = res.Output.Setlinfo.Certno
  21071. order.Gend = res.Output.Setlinfo.Gend
  21072. order.Naty = res.Output.Setlinfo.Naty
  21073. order.Age = res.Output.Setlinfo.Age
  21074. order.Insutype = res.Output.Setlinfo.Insutype
  21075. order.PsnType = res.Output.Setlinfo.PsnType
  21076. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  21077. order.SetlTime = res.Output.Setlinfo.SetlTime
  21078. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  21079. if res.Output.Setlinfo.MedType == "140101" {
  21080. order.MedType = "14"
  21081. } else {
  21082. if res.Output.Setlinfo.MedType == "110104" {
  21083. order.MedType = "11"
  21084. } else {
  21085. order.MedType = res.Output.Setlinfo.MedType
  21086. }
  21087. }
  21088. if reg_type == 1112 {
  21089. order.MedType = "1112"
  21090. }
  21091. if reg_type == 1111 {
  21092. order.MedType = "1111"
  21093. }
  21094. order.ClrType = res.Output.Setlinfo.ClrType
  21095. if adminUser.CurrentOrgId == 10480 {
  21096. if strings.Contains(his.InsuplcAdmdvs, "3412") {
  21097. order.ClrType = "11"
  21098. } else {
  21099. order.ClrType = "9903"
  21100. }
  21101. }
  21102. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  21103. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  21104. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  21105. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  21106. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  21107. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  21108. order.HifpPay = res.Output.Setlinfo.HifpPay
  21109. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  21110. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  21111. order.HifesPay = res.Output.Setlinfo.HifesPay
  21112. order.HifobPay = res.Output.Setlinfo.HifobPay
  21113. order.MafPay = res.Output.Setlinfo.MafPay
  21114. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  21115. order.OthPay = res.Output.Setlinfo.OthPay
  21116. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  21117. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  21118. order.AcctPay = res.Output.Setlinfo.AcctPay
  21119. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  21120. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  21121. order.Balc = res.Output.Setlinfo.Balc
  21122. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  21123. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  21124. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  21125. //order.ClrType = res.Output.Setlinfo.ClrType
  21126. order.ClrWay = res.Output.Setlinfo.ClrWay
  21127. order.Creator = order.Creator
  21128. order.Modify = roles.AdminUserId
  21129. order.RequestLog = src_resquest
  21130. order.FaPiaoNumber = fapiao_number
  21131. order.FaPiaoCode = fapiao_code
  21132. //setlDetail, _ := json.Marshal(res.Output.Setldetail)
  21133. //detailStr := string(setlDetail)
  21134. //order.SetlDetail = detailStr
  21135. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  21136. err = service.UpDateOrder(order)
  21137. if err == nil {
  21138. //判断是否使用了押金
  21139. if dec_way == "true" {
  21140. tmpstring := strconv.FormatInt(order.ID, 10)
  21141. order.Decimal = decimal
  21142. service.UpDateOrder(order)
  21143. //扣押金
  21144. errmsg = service.SpendDeposit(c.GetAdminUserInfo().CurrentOrgId, id, c.GetAdminUserInfo().AdminUser.Id, tmpstring, decimal)
  21145. if errmsg != nil {
  21146. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, errmsg.Error())
  21147. return
  21148. }
  21149. }
  21150. c.ServeSuccessJSON(map[string]interface{}{
  21151. "msg": "结算成功",
  21152. })
  21153. } else {
  21154. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  21155. return
  21156. }
  21157. }
  21158. } else {
  21159. adminUser := c.GetAdminUserInfo()
  21160. errlog := &models.HisOrderError{
  21161. UserOrgId: adminUser.CurrentOrgId,
  21162. Ctime: time.Now().Unix(),
  21163. Mtime: time.Now().Unix(),
  21164. ErrMsg: res.ErrMsg,
  21165. Status: 1,
  21166. PatientId: id,
  21167. RecordTime: recordDateTime,
  21168. Stage: 4,
  21169. }
  21170. service.CreateErrMsgLog(errlog)
  21171. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  21172. return
  21173. }
  21174. } else {
  21175. adminUser := c.GetAdminUserInfo()
  21176. errlog := &models.HisOrderError{
  21177. UserOrgId: adminUser.CurrentOrgId,
  21178. Ctime: time.Now().Unix(),
  21179. Mtime: time.Now().Unix(),
  21180. ErrMsg: res.ErrMsg,
  21181. Status: 1,
  21182. PatientId: id,
  21183. RecordTime: recordDateTime,
  21184. Stage: 4,
  21185. }
  21186. service.CreateErrMsgLog(errlog)
  21187. c.ServeSuccessJSON(map[string]interface{}{
  21188. "failed_code": -10,
  21189. "msg": res.ErrMsg,
  21190. })
  21191. return
  21192. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  21193. //return
  21194. }
  21195. }
  21196. }
  21197. } else if tempOrder.ID > 0 {
  21198. if tempOrder.IsPre == 1 {
  21199. allTotal := fmt.Sprintf("%.2f", tempOrder.MedfeeSumamt)
  21200. var rf []*ResultFive
  21201. json.Unmarshal([]byte(his.Iinfo), &rf)
  21202. chrg_bchno := tempOrder.Number
  21203. cert_no := his.Certno
  21204. var insutypes []string
  21205. var insutype string
  21206. var is390 int = 0
  21207. var is310 int = 0
  21208. for _, item := range rf {
  21209. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  21210. insutypes = append(insutypes, item.Insutype)
  21211. }
  21212. }
  21213. if len(insutypes) == 1 {
  21214. insutype = insutypes[0]
  21215. } else {
  21216. for _, i := range insutypes {
  21217. if i == "390" {
  21218. is390 = 1
  21219. }
  21220. if i == "310" {
  21221. is310 = 1
  21222. }
  21223. }
  21224. }
  21225. if is390 == 1 {
  21226. insutype = "390"
  21227. }
  21228. if is310 == 1 {
  21229. insutype = "310"
  21230. }
  21231. if len(insutypes) == 0 {
  21232. insutype = "310"
  21233. }
  21234. if len(insutypes) == 2 {
  21235. insutype = strconv.FormatInt(his.SocialType, 10)
  21236. }
  21237. //insutype = "390"
  21238. if his.IdCardType == 1 {
  21239. // cert_no = his.MedicalInsuranceNumber
  21240. cert_no = his.Certno
  21241. } else {
  21242. cert_no = his.Certno
  21243. }
  21244. var res ResultSeven
  21245. var ahres ResultSevenAH
  21246. var resSeven10265 ResultSeven10265
  21247. var gzresSeven10265Two GZResultSeven10265Two
  21248. var src_resquest string
  21249. var result2 string
  21250. if miConfig.MdtrtareaAdmvs == "450721" {
  21251. res2 := c.GetoleInfo()
  21252. if res2.Infcode == 0 {
  21253. var result string
  21254. var request_log string
  21255. var result_log string
  21256. if res2.Output.MdtrtCertType == "02" {
  21257. 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)
  21258. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  21259. } else if res2.Output.MdtrtCertType == "01" {
  21260. 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)
  21261. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  21262. } else {
  21263. 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)
  21264. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  21265. }
  21266. var dat map[string]interface{}
  21267. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  21268. fmt.Println(dat)
  21269. } else {
  21270. fmt.Println(err)
  21271. }
  21272. userJSONBytes, _ := json.Marshal(dat)
  21273. var res5 ResultTwo
  21274. //var resTwo10265 ResultTwo10265
  21275. if err := json.Unmarshal(userJSONBytes, &res5); err != nil {
  21276. utils.ErrorLog("解析失败:%v", err)
  21277. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21278. return
  21279. }
  21280. //utils.ErrorLog("解析失败:%v", res5.Infcode)
  21281. if res5.Infcode == -1 {
  21282. c.ServeSuccessJSON(map[string]interface{}{
  21283. "failed_code": -10,
  21284. "msg": res5.ErrMsg,
  21285. })
  21286. return
  21287. }
  21288. var insutypes []string
  21289. var insutype string
  21290. var is390 int = 0
  21291. var is310 int = 0
  21292. for _, item := range res5.Output.Iinfo {
  21293. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  21294. insutypes = append(insutypes, item.Insutype)
  21295. }
  21296. }
  21297. if len(insutypes) == 1 {
  21298. insutype = insutypes[0]
  21299. } else {
  21300. for _, i := range insutypes {
  21301. if i == "390" {
  21302. is390 = 1
  21303. }
  21304. if i == "310" {
  21305. is310 = 1
  21306. }
  21307. }
  21308. }
  21309. if is390 == 1 {
  21310. insutype = "390"
  21311. }
  21312. if is310 == 1 {
  21313. insutype = "310"
  21314. }
  21315. if len(insutypes) == 0 {
  21316. insutype = "310"
  21317. }
  21318. Iinfos, _ := json.Marshal(res5.Output.Iinfo)
  21319. Idetinfos, _ := json.Marshal(res5.Output.Idetinfo)
  21320. infoStr := string(Iinfos)
  21321. idetinfoStr := string(Idetinfos)
  21322. psn := &models.HisPsn{
  21323. PsnNo: res5.Output.Baseinfo.PsnNo,
  21324. PatientId: id,
  21325. Certno: res5.Output.Baseinfo.Certno,
  21326. Gend: res5.Output.Baseinfo.Gend,
  21327. Naty: res5.Output.Baseinfo.Naty,
  21328. PsnCertType: res5.Output.Baseinfo.PsnCertType,
  21329. PsnName: res5.Output.Baseinfo.PsnName,
  21330. Idetinfo: idetinfoStr,
  21331. Insuinfo: infoStr,
  21332. CardInfo: res2.Output.CardNo + "|" + res2.Output.CardSN,
  21333. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  21334. VerifyNumber: res2.Output.EcToken,
  21335. }
  21336. service.CreateHisPsn(psn)
  21337. if res2.Output.MdtrtCertType == "01" {
  21338. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  21339. token := res2.Output.EcToken
  21340. 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)
  21341. } else if res2.Output.MdtrtCertType == "02" {
  21342. 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)
  21343. } else {
  21344. 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)
  21345. }
  21346. var dat2 map[string]interface{}
  21347. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  21348. fmt.Println(dat2)
  21349. } else {
  21350. fmt.Println(err)
  21351. }
  21352. userJSONBytes3, _ := json.Marshal(dat2)
  21353. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  21354. utils.ErrorLog("解析失败:%v", err)
  21355. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21356. return
  21357. }
  21358. saveLog(result2, src_resquest, "2207", "结算")
  21359. } else {
  21360. c.ServeSuccessJSON(map[string]interface{}{
  21361. "failed_code": -10,
  21362. "msg": res2.ErrMsg,
  21363. })
  21364. return
  21365. }
  21366. } else if miConfig.MdtrtareaAdmvs == "421300" {
  21367. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  21368. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  21369. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  21370. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  21371. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  21372. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  21373. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  21374. resp, requestErr := http.Get(api)
  21375. if requestErr != nil {
  21376. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21377. return
  21378. }
  21379. body, ioErr := ioutil.ReadAll(resp.Body)
  21380. if ioErr != nil {
  21381. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  21382. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21383. return
  21384. }
  21385. var respJSON map[string]interface{}
  21386. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  21387. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21388. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21389. return
  21390. }
  21391. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  21392. result, _ := json.Marshal(respJSON)
  21393. fmt.Println("log")
  21394. fmt.Println(string(result))
  21395. if err := json.Unmarshal([]byte(result), &res); err != nil {
  21396. utils.ErrorLog("解析失败:%v", err)
  21397. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21398. return
  21399. }
  21400. } else if miConfig.MdtrtareaAdmvs == "420200" {
  21401. if reg_type == 11 && his.Insutype == "390" {
  21402. reg_type = 110104
  21403. }
  21404. api := "http://192.168.0.197:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  21405. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  21406. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  21407. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  21408. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  21409. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  21410. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  21411. resp, requestErr := http.Get(api)
  21412. if requestErr != nil {
  21413. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21414. return
  21415. }
  21416. body, ioErr := ioutil.ReadAll(resp.Body)
  21417. if ioErr != nil {
  21418. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  21419. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21420. return
  21421. }
  21422. var respJSON map[string]interface{}
  21423. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  21424. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21425. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21426. return
  21427. }
  21428. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  21429. result, _ := json.Marshal(respJSON)
  21430. fmt.Println("log")
  21431. fmt.Println(string(result))
  21432. if err := json.Unmarshal([]byte(result), &res); err != nil {
  21433. utils.ErrorLog("解析失败:%v", err)
  21434. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21435. return
  21436. }
  21437. } else if miConfig.MdtrtareaAdmvs == "420902" {
  21438. if reg_type == 11 && his.Insutype == "390" {
  21439. reg_type = 110104
  21440. }
  21441. api := miConfig.Url + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  21442. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  21443. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  21444. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  21445. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  21446. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  21447. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  21448. resp, requestErr := http.Get(api)
  21449. if requestErr != nil {
  21450. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21451. return
  21452. }
  21453. body, ioErr := ioutil.ReadAll(resp.Body)
  21454. if ioErr != nil {
  21455. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  21456. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21457. return
  21458. }
  21459. var respJSON map[string]interface{}
  21460. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  21461. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21462. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21463. return
  21464. }
  21465. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  21466. result, _ := json.Marshal(respJSON)
  21467. fmt.Println("log")
  21468. fmt.Println(string(result))
  21469. if err := json.Unmarshal([]byte(result), &res); err != nil {
  21470. utils.ErrorLog("解析失败:%v", err)
  21471. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21472. return
  21473. }
  21474. } else if miConfig.MdtrtareaAdmvs == "421182" {
  21475. if reg_type == 11 && his.Insutype == "390" {
  21476. reg_type = 110104
  21477. }
  21478. api := miConfig.Url + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  21479. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  21480. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  21481. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  21482. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  21483. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  21484. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  21485. resp, requestErr := http.Get(api)
  21486. if requestErr != nil {
  21487. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21488. return
  21489. }
  21490. body, ioErr := ioutil.ReadAll(resp.Body)
  21491. if ioErr != nil {
  21492. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  21493. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21494. return
  21495. }
  21496. var respJSON map[string]interface{}
  21497. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  21498. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21499. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21500. return
  21501. }
  21502. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  21503. result, _ := json.Marshal(respJSON)
  21504. fmt.Println("log")
  21505. fmt.Println(string(result))
  21506. if err := json.Unmarshal([]byte(result), &res); err != nil {
  21507. utils.ErrorLog("解析失败:%v", err)
  21508. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21509. return
  21510. }
  21511. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  21512. result3101 := Check3102(c, id, his_patient_id, admin_user_id, "7", tempOrder.ID)
  21513. if result3101.Infcode == "0" {
  21514. if len(result3101.Output.Result) > 0 {
  21515. var errMsgs []string
  21516. for _, item := range result3101.Output.Result {
  21517. errMsgs = append(errMsgs, item.VolaCont)
  21518. }
  21519. c.ServeSuccessJSON(map[string]interface{}{
  21520. "failed_code": -10,
  21521. "msg": errMsgs,
  21522. })
  21523. return
  21524. } else {
  21525. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  21526. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  21527. bas := strings.Split(psn_info.CardInfo, "|")
  21528. if his.IdCardType == 1 {
  21529. cert_no = bas[2]
  21530. } else if his.IdCardType == 3 {
  21531. cert_no = his.Certno
  21532. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  21533. } else if his.IdCardType == 4 {
  21534. cert_no = his.Certno
  21535. psn_info.VerifyNumber = psn_info.VerifyNumber
  21536. }
  21537. //江苏地区国家医保医疗类别
  21538. //职工透析:医疗类别选特殊情况门诊9933
  21539. //居民血透门慢: 医疗类别选门诊慢病1402
  21540. //var med_type string
  21541. //if his.Insutype == "310" {
  21542. // if reg_type == 14 {
  21543. // med_type = "9933"
  21544. // } else if reg_type == 11 {
  21545. // med_type = "11"
  21546. //
  21547. // }
  21548. //} else if his.Insutype == "390" {
  21549. // if reg_type == 14 {
  21550. // med_type = "1402"
  21551. // } else if reg_type == 11 {
  21552. // med_type = "11"
  21553. // }
  21554. //}
  21555. var api string
  21556. if miConfig.MdtrtareaAdmvs == "320921" {
  21557. api = "http://192.168.2.3:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  21558. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  21559. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  21560. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  21561. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  21562. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  21563. "&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
  21564. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  21565. } else {
  21566. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  21567. api = "http://192.168.5.251:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  21568. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  21569. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  21570. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  21571. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  21572. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  21573. "&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
  21574. }
  21575. resp, requestErr := http.Get(api)
  21576. if requestErr != nil {
  21577. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21578. return
  21579. }
  21580. body, ioErr := ioutil.ReadAll(resp.Body)
  21581. if ioErr != nil {
  21582. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  21583. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21584. return
  21585. }
  21586. var respJSON map[string]interface{}
  21587. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  21588. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21589. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21590. return
  21591. }
  21592. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  21593. result, _ := json.Marshal(respJSON)
  21594. fmt.Println("log")
  21595. fmt.Println(string(result))
  21596. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  21597. utils.ErrorLog("解析失败:%v", err)
  21598. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21599. return
  21600. }
  21601. res.InfRefmsgid = resSeven10265.InfRefmsgid
  21602. res.Output = resSeven10265.Output
  21603. res.InfRefmsgid = resSeven10265.InfRefmsgid
  21604. res.ErrMsg = resSeven10265.ErrMsg
  21605. res.Cainfo = resSeven10265.Cainfo
  21606. res.WarnMsg = resSeven10265.WarnMsg
  21607. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  21608. res.Infcode = infocode
  21609. }
  21610. }
  21611. } else if miConfig.MdtrtareaAdmvs == "150499" {
  21612. psn_info, _ := service.GetPsnByPatientId(id)
  21613. var verify_number string
  21614. if psn_info.IdCardType == 4 {
  21615. verify_number = psn_info.VerifyNumber
  21616. } else if psn_info.IdCardType == 1 {
  21617. bas := strings.Split(psn_info.CardInfo, "|")
  21618. cardNumber := bas[2]
  21619. verify_number = cardNumber
  21620. } else {
  21621. verify_number = psn_info.Certno
  21622. psn_info.IdCardType = 2
  21623. }
  21624. var api string
  21625. api = "http://172.16.13.254:9532/" + "nmyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  21626. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  21627. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  21628. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  21629. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(psn_info.IdCardType, 10) +
  21630. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  21631. "&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
  21632. resp, requestErr := http.Get(api)
  21633. if requestErr != nil {
  21634. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21635. return
  21636. }
  21637. body, ioErr := ioutil.ReadAll(resp.Body)
  21638. if ioErr != nil {
  21639. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  21640. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21641. return
  21642. }
  21643. var respJSON map[string]interface{}
  21644. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  21645. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21646. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21647. return
  21648. }
  21649. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  21650. result, _ := json.Marshal(respJSON)
  21651. fmt.Println("log")
  21652. fmt.Println(string(result))
  21653. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  21654. utils.ErrorLog("解析失败:%v", err)
  21655. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21656. return
  21657. }
  21658. res.InfRefmsgid = resSeven10265.InfRefmsgid
  21659. res.Output = resSeven10265.Output
  21660. res.InfRefmsgid = resSeven10265.InfRefmsgid
  21661. res.ErrMsg = resSeven10265.ErrMsg
  21662. res.Cainfo = resSeven10265.Cainfo
  21663. res.WarnMsg = resSeven10265.WarnMsg
  21664. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  21665. res.Infcode = infocode
  21666. } else if miConfig.MdtrtareaAdmvs == "350500" {
  21667. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  21668. var cert_no string
  21669. if his.IdCardType == 1 {
  21670. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  21671. } else {
  21672. cert_no = psn_info.VerifyNumber
  21673. }
  21674. 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)
  21675. var dat map[string]interface{}
  21676. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  21677. fmt.Println(dat)
  21678. } else {
  21679. fmt.Println(err)
  21680. }
  21681. saveLog(result2, src_resquest, "2207", "结算")
  21682. userJSONBytes, _ := json.Marshal(dat)
  21683. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  21684. utils.ErrorLog("解析失败:%v", err)
  21685. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21686. return
  21687. }
  21688. } else if miConfig.MdtrtareaAdmvs == "360302" {
  21689. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  21690. var cert_no string
  21691. var card_sn string
  21692. if his.IdCardType == 1 {
  21693. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  21694. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  21695. bas := strings.Split(psn_info.CardInfo, "|")
  21696. card_sn = bas[3]
  21697. } else if his.IdCardType == 2 {
  21698. cert_no = his.IdCardNo
  21699. } else {
  21700. cert_no = psn_info.VerifyNumber
  21701. }
  21702. var rf []*ResultFive
  21703. json.Unmarshal([]byte(his.Iinfo), &rf)
  21704. var psn_type string
  21705. for _, item := range rf {
  21706. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  21707. psn_type = item.PsnType
  21708. }
  21709. }
  21710. 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)
  21711. var dat map[string]interface{}
  21712. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  21713. fmt.Println(dat)
  21714. } else {
  21715. fmt.Println(err)
  21716. }
  21717. saveLog(result2, src_resquest, "2207", "结算")
  21718. userJSONBytes, _ := json.Marshal(dat)
  21719. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  21720. utils.ErrorLog("解析失败:%v", err)
  21721. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21722. return
  21723. }
  21724. } else if miConfig.MdtrtareaAdmvs == "341203" {
  21725. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  21726. if his.IdCardType == 1 {
  21727. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  21728. bas := strings.Split(psn_info.CardInfo, "|")
  21729. cert_no = bas[2]
  21730. } else if his.IdCardType == 3 {
  21731. cert_no = his.Certno
  21732. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  21733. } else if his.IdCardType == 4 {
  21734. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  21735. cert_no = his.Certno
  21736. psn_info.VerifyNumber = psn_info.VerifyNumber
  21737. } else {
  21738. cert_no = his.Certno
  21739. psn_info.VerifyNumber = his.Certno
  21740. }
  21741. var api string
  21742. var med_type string
  21743. if his.Insutype == "390" {
  21744. if reg_type == 992102 {
  21745. med_type = "992102"
  21746. }
  21747. if reg_type == 140104 {
  21748. med_type = "140104"
  21749. }
  21750. if reg_type == 14 {
  21751. med_type = "14"
  21752. }
  21753. } else if his.Insutype == "310" {
  21754. if reg_type == 992102 {
  21755. med_type = "992102"
  21756. }
  21757. if reg_type == 14 {
  21758. med_type = "14"
  21759. }
  21760. }
  21761. api = miConfig.SecretKey + "ahyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  21762. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  21763. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  21764. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  21765. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  21766. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  21767. "&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
  21768. resp, requestErr := http.Get(api)
  21769. if requestErr != nil {
  21770. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21771. return
  21772. }
  21773. body, ioErr := ioutil.ReadAll(resp.Body)
  21774. if ioErr != nil {
  21775. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  21776. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21777. return
  21778. }
  21779. var respJSON map[string]interface{}
  21780. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  21781. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21782. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21783. return
  21784. }
  21785. status := respJSON["data"].(map[string]interface{})["status"].(string)
  21786. if status == "0" {
  21787. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  21788. c.ServeSuccessJSON(map[string]interface{}{
  21789. "failed_code": -10,
  21790. "msg": err_msg,
  21791. })
  21792. return
  21793. }
  21794. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  21795. result, _ := json.Marshal(respJSON)
  21796. fmt.Println("log")
  21797. fmt.Println(string(result))
  21798. if err := json.Unmarshal(result, &ahres); err != nil {
  21799. utils.ErrorLog("解析失败:%v", err)
  21800. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21801. return
  21802. }
  21803. res.InfRefmsgid = ahres.InfRefmsgid
  21804. timestamp := int64(ahres.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  21805. // 创建对应的Time类型
  21806. t := time.UnixMilli(timestamp)
  21807. // 格式化成指定的日期字符串
  21808. str := t.Format("2006-01-02 15:04:05")
  21809. res.Output.Setlinfo.SetlTime = str
  21810. res.Output.Setlinfo.AcctMulaidPay = ahres.Output.Setlinfo.AcctMulaidPay
  21811. res.Output.Setlinfo.AcctPay = ahres.Output.Setlinfo.AcctPay
  21812. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  21813. res.Output.Setlinfo.ActPayDedc = ahres.Output.Setlinfo.ActPayDedc
  21814. res.Output.Setlinfo.Age = ahres.Output.Setlinfo.Age
  21815. res.Output.Setlinfo.Balc = ahres.Output.Setlinfo.Balc
  21816. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  21817. res.Output.Setlinfo.Certno = ahres.Output.Setlinfo.Certno
  21818. res.Output.Setlinfo.ClrOptins = ahres.Output.Setlinfo.ClrOptins
  21819. if strings.Contains(his.InsuplcAdmdvs, "3412") {
  21820. res.Output.Setlinfo.ClrType = "11"
  21821. } else {
  21822. res.Output.Setlinfo.ClrType = "9903"
  21823. }
  21824. res.Output.Setlinfo.ClrWay = ahres.Output.Setlinfo.ClrOptins
  21825. res.Output.Setlinfo.CvlservFlag = ahres.Output.Setlinfo.ClrOptins
  21826. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  21827. res.Output.Setlinfo.FulamtOwnpayAmt = ahres.Output.Setlinfo.FulamtOwnpayAmt
  21828. res.Output.Setlinfo.FundPaySumamt = ahres.Output.Setlinfo.FundPaySumamt
  21829. res.Output.Setlinfo.Gend = ahres.Output.Setlinfo.Gend
  21830. res.Output.Setlinfo.HifesPay = ahres.Output.Setlinfo.HifesPay
  21831. res.Output.Setlinfo.HifmiPay = ahres.Output.Setlinfo.HifmiPay
  21832. res.Output.Setlinfo.HifpPay = ahres.Output.Setlinfo.HifpPay
  21833. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  21834. res.Output.Setlinfo.HospPartAmt = ahres.Output.Setlinfo.HospPartAmt
  21835. res.Output.Setlinfo.InscpScpAmt = ahres.Output.Setlinfo.InscpScpAmt
  21836. res.Output.Setlinfo.Insutype = ahres.Output.Setlinfo.Insutype
  21837. res.Output.Setlinfo.MafPay = ahres.Output.Setlinfo.MafPay
  21838. res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  21839. res.Output.Setlinfo.HifobPay = ahres.Output.Setlinfo.HifobPay
  21840. res.Output.Setlinfo.MdtrtID = ahres.Output.Setlinfo.MdtrtID
  21841. res.Output.Setlinfo.MedType = ahres.Output.Setlinfo.MedType
  21842. res.Output.Setlinfo.MedfeeSumamt = ahres.Output.Setlinfo.MedfeeSumamt
  21843. res.Output.Setlinfo.MedinsSetlID = ahres.Output.Setlinfo.MedinsSetlID
  21844. res.Output.Setlinfo.Naty = ahres.Output.Setlinfo.Naty
  21845. res.Output.Setlinfo.OthPay = ahres.Output.Setlinfo.OthPay
  21846. res.Output.Setlinfo.OverlmtSelfpay = ahres.Output.Setlinfo.OverlmtSelfpay
  21847. res.Output.Setlinfo.PoolPropSelfpay = ahres.Output.Setlinfo.PoolPropSelfpay
  21848. res.Output.Setlinfo.PreselfpayAmt = ahres.Output.Setlinfo.PreselfpayAmt
  21849. res.Output.Setlinfo.PsnCashPay = ahres.Output.Setlinfo.PsnCashPay
  21850. res.Output.Setlinfo.PsnCertType = ahres.Output.Setlinfo.ClrOptins
  21851. res.Output.Setlinfo.ClrType = ahres.Output.Setlinfo.ClrType
  21852. res.Output.Setlinfo.PsnName = ahres.Output.Setlinfo.PsnName
  21853. res.Output.Setlinfo.PsnNo = ahres.Output.Setlinfo.PsnNo
  21854. res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  21855. res.Output.Setlinfo.PsnType = ahres.Output.Setlinfo.PsnType
  21856. res.Output.Setlinfo.SetlID = ahres.Output.Setlinfo.SetlID
  21857. res.Output.Setldetail = ahres.Output.Setldetail
  21858. res.ErrMsg = ahres.ErrMsg
  21859. res.Cainfo = ahres.Cainfo
  21860. res.WarnMsg = ahres.WarnMsg
  21861. res.Infcode = ahres.Infcode
  21862. } else if miConfig.MdtrtareaAdmvs == "430800" {
  21863. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  21864. var cert_no string
  21865. if his.IdCardType == 1 {
  21866. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  21867. } else if his.IdCardType == 2 {
  21868. cert_no = his.IdCardNo
  21869. } else {
  21870. cert_no = psn_info.VerifyNumber
  21871. }
  21872. 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, "")
  21873. var dat map[string]interface{}
  21874. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  21875. fmt.Println(dat)
  21876. } else {
  21877. fmt.Println(err)
  21878. }
  21879. saveLog(result2, src_resquest, "2207", "结算")
  21880. userJSONBytes, _ := json.Marshal(dat)
  21881. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  21882. utils.ErrorLog("解析失败:%v", err)
  21883. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21884. return
  21885. }
  21886. } else if miConfig.MdtrtareaAdmvs == "441799" {
  21887. psn_info, _ := service.GetPsnByPatientId(id)
  21888. var verify_number string
  21889. if psn_info.IdCardType == 4 {
  21890. verify_number = psn_info.VerifyNumber
  21891. } else if psn_info.IdCardType == 1 {
  21892. bas := strings.Split(psn_info.CardInfo, "|")
  21893. cardNumber := bas[2]
  21894. verify_number = cardNumber
  21895. } else {
  21896. verify_number = psn_info.Certno
  21897. psn_info.IdCardType = 2
  21898. }
  21899. var api string
  21900. api = miConfig.Url + "gdyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  21901. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  21902. "&operator=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  21903. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  21904. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(psn_info.IdCardType, 10) +
  21905. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  21906. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + tempOrder.MedType + "&acct_used_flag=" + acct_used_flag + "&verify_number=" + verify_number
  21907. resp, requestErr := http.Get(api)
  21908. if requestErr != nil {
  21909. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21910. return
  21911. }
  21912. body, ioErr := ioutil.ReadAll(resp.Body)
  21913. if ioErr != nil {
  21914. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  21915. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21916. return
  21917. }
  21918. var respJSON map[string]interface{}
  21919. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  21920. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21921. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21922. return
  21923. }
  21924. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  21925. result, _ := json.Marshal(respJSON)
  21926. if err := json.Unmarshal([]byte(result), &res); err != nil {
  21927. utils.ErrorLog("解析失败:%v", err)
  21928. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21929. return
  21930. }
  21931. } else {
  21932. var src_resquest string
  21933. if miConfig.Code == "H15049901371" {
  21934. //赤峰地区国家医保医疗类别
  21935. //职工透析:医疗类别选特殊情况门诊990502
  21936. //居民定额血透门慢: 医疗类别选门诊慢病140104
  21937. var med_type string
  21938. if his.Insutype == "390" {
  21939. if reg_type == 14 {
  21940. med_type = "9933"
  21941. } else if reg_type == 11 {
  21942. med_type = "11"
  21943. }
  21944. } else if his.Insutype == "310" {
  21945. if reg_type == 14 {
  21946. med_type = "990502"
  21947. } else if reg_type == 11 {
  21948. med_type = "11"
  21949. }
  21950. }
  21951. 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)
  21952. } else {
  21953. if his.IdCardType == 4 {
  21954. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  21955. token := psn_info.VerifyNumber
  21956. 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)
  21957. } else {
  21958. 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)
  21959. }
  21960. }
  21961. var dat map[string]interface{}
  21962. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  21963. fmt.Println(dat)
  21964. } else {
  21965. fmt.Println(err)
  21966. }
  21967. saveLog(result2, src_resquest, "2207", "结算")
  21968. userJSONBytes, _ := json.Marshal(dat)
  21969. if miConfig.Code == "H15049901371" {
  21970. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  21971. utils.ErrorLog("解析失败:%v", err)
  21972. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21973. return
  21974. }
  21975. res.InfRefmsgid = resSeven10265.InfRefmsgid
  21976. res.Output = resSeven10265.Output
  21977. res.ErrMsg = resSeven10265.ErrMsg
  21978. res.Cainfo = resSeven10265.Cainfo
  21979. res.WarnMsg = resSeven10265.WarnMsg
  21980. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  21981. res.Infcode = infocode
  21982. } else {
  21983. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  21984. if err := json.Unmarshal(userJSONBytes, &gzresSeven10265Two); err != nil {
  21985. utils.ErrorLog("解析失败:%v", err)
  21986. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21987. return
  21988. }
  21989. res.InfRefmsgid = gzresSeven10265Two.InfRefmsgid
  21990. res.Output.Setlinfo.AcctMulaidPay = gzresSeven10265Two.Output.Setlinfo.AcctMulaidPay
  21991. res.Output.Setlinfo.AcctPay = gzresSeven10265Two.Output.Setlinfo.AcctPay
  21992. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  21993. res.Output.Setlinfo.ActPayDedc = gzresSeven10265Two.Output.Setlinfo.ActPayDedc
  21994. res.Output.Setlinfo.Age = gzresSeven10265Two.Output.Setlinfo.Age
  21995. res.Output.Setlinfo.Balc = gzresSeven10265Two.Output.Setlinfo.Balc
  21996. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  21997. res.Output.Setlinfo.Certno = gzresSeven10265Two.Output.Setlinfo.Certno
  21998. res.Output.Setlinfo.ClrOptins = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  21999. res.Output.Setlinfo.ClrType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  22000. res.Output.Setlinfo.ClrWay = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  22001. res.Output.Setlinfo.CvlservFlag = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  22002. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  22003. res.Output.Setlinfo.FulamtOwnpayAmt = gzresSeven10265Two.Output.Setlinfo.FulamtOwnpayAmt
  22004. res.Output.Setlinfo.FundPaySumamt = gzresSeven10265Two.Output.Setlinfo.FundPaySumamt
  22005. res.Output.Setlinfo.Gend = gzresSeven10265Two.Output.Setlinfo.Gend
  22006. res.Output.Setlinfo.HifesPay = gzresSeven10265Two.Output.Setlinfo.HifesPay
  22007. res.Output.Setlinfo.HifmiPay = gzresSeven10265Two.Output.Setlinfo.HifmiPay
  22008. res.Output.Setlinfo.HifpPay = gzresSeven10265Two.Output.Setlinfo.HifpPay
  22009. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  22010. res.Output.Setlinfo.HospPartAmt = gzresSeven10265Two.Output.Setlinfo.HospPartAmt
  22011. res.Output.Setlinfo.InscpScpAmt = gzresSeven10265Two.Output.Setlinfo.InscpScpAmt
  22012. res.Output.Setlinfo.Insutype = gzresSeven10265Two.Output.Setlinfo.Insutype
  22013. res.Output.Setlinfo.MafPay = gzresSeven10265Two.Output.Setlinfo.MafPay
  22014. res.Output.Setlinfo.MdtrtCertType = gzresSeven10265Two.Output.Setlinfo.MdtrtCertType
  22015. res.Output.Setlinfo.HifobPay = gzresSeven10265Two.Output.Setlinfo.HifobPay
  22016. res.Output.Setlinfo.MdtrtID = gzresSeven10265Two.Output.Setlinfo.MdtrtID
  22017. res.Output.Setlinfo.MedType = gzresSeven10265Two.Output.Setlinfo.MedType
  22018. res.Output.Setlinfo.MedfeeSumamt = gzresSeven10265Two.Output.Setlinfo.MedfeeSumamt
  22019. res.Output.Setlinfo.MedinsSetlID = gzresSeven10265Two.Output.Setlinfo.MedinsSetlID
  22020. res.Output.Setlinfo.Naty = gzresSeven10265Two.Output.Setlinfo.Naty
  22021. res.Output.Setlinfo.OthPay = gzresSeven10265Two.Output.Setlinfo.OthPay
  22022. res.Output.Setlinfo.OverlmtSelfpay = gzresSeven10265Two.Output.Setlinfo.OverlmtSelfpay
  22023. PoolPropSelfpay, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.PoolPropSelfpay, 64)
  22024. res.Output.Setlinfo.PoolPropSelfpay = PoolPropSelfpay
  22025. res.Output.Setlinfo.PreselfpayAmt = gzresSeven10265Two.Output.Setlinfo.PreselfpayAmt
  22026. res.Output.Setlinfo.PsnCashPay = gzresSeven10265Two.Output.Setlinfo.PsnCashPay
  22027. res.Output.Setlinfo.PsnCertType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  22028. res.Output.Setlinfo.PsnName = gzresSeven10265Two.Output.Setlinfo.PsnName
  22029. res.Output.Setlinfo.PsnNo = gzresSeven10265Two.Output.Setlinfo.PsnNo
  22030. res.Output.Setlinfo.PsnPartAmt = gzresSeven10265Two.Output.Setlinfo.PsnPartAmt
  22031. res.Output.Setlinfo.PsnType = gzresSeven10265Two.Output.Setlinfo.PsnType
  22032. res.Output.Setlinfo.SetlID = gzresSeven10265Two.Output.Setlinfo.SetlID
  22033. res.Output.Setlinfo.SetlTime = gzresSeven10265Two.Output.Setlinfo.SetlTime
  22034. //res.Output.Setldetail = gzresSeven10265Two.Output.Setldetail
  22035. res.ErrMsg = gzresSeven10265Two.ErrMsg
  22036. res.Cainfo = gzresSeven10265Two.Cainfo
  22037. res.WarnMsg = gzresSeven10265Two.WarnMsg
  22038. //infocode, _ := strconv.ParseInt(resSeven10265Two.Infcode, 10, 64)
  22039. //res.Infcode = infocode
  22040. } else {
  22041. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  22042. utils.ErrorLog("解析失败:%v", err)
  22043. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22044. return
  22045. }
  22046. }
  22047. }
  22048. }
  22049. if res.Infcode != 0 {
  22050. errlog := &models.HisOrderError{
  22051. UserOrgId: adminUser.CurrentOrgId,
  22052. Ctime: time.Now().Unix(),
  22053. Mtime: time.Now().Unix(),
  22054. Number: chrg_bchno,
  22055. ErrMsg: res.ErrMsg,
  22056. Status: 1,
  22057. PatientId: id,
  22058. RecordTime: recordDateTime,
  22059. Stage: 6,
  22060. }
  22061. service.CreateErrMsgLog(errlog)
  22062. c.ServeSuccessJSON(map[string]interface{}{
  22063. "failed_code": -10,
  22064. "msg": res.ErrMsg,
  22065. })
  22066. return
  22067. } else {
  22068. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  22069. order.OrderStatus = 2
  22070. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  22071. order.SetlId = res.Output.Setlinfo.SetlID
  22072. order.PsnNo = res.Output.Setlinfo.PsnNo
  22073. order.PsnName = res.Output.Setlinfo.PsnName
  22074. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  22075. order.Certno = res.Output.Setlinfo.Certno
  22076. order.Gend = res.Output.Setlinfo.Gend
  22077. order.Naty = res.Output.Setlinfo.Naty
  22078. order.Age = res.Output.Setlinfo.Age
  22079. order.Insutype = res.Output.Setlinfo.Insutype
  22080. order.PsnType = res.Output.Setlinfo.PsnType
  22081. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  22082. order.SetlTime = res.Output.Setlinfo.SetlTime
  22083. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  22084. order.PayWays = pay_ways
  22085. order.AcctUsedFlag = acct_used_flag
  22086. order.WechatPay = wechat_pay
  22087. order.AliPay = ali_pay
  22088. order.JifenPay = jifen_pay
  22089. order.BandCardPay = band_card_pay
  22090. order.CashPay = cash_pay
  22091. order.OthDesc = oth_desc
  22092. //order.MedType = res.Output.Setlinfo.MedType
  22093. if reg_type == 1112 {
  22094. order.MedType = "1112"
  22095. }
  22096. if reg_type == 1111 {
  22097. order.MedType = "1111"
  22098. }
  22099. order.ClrType = res.Output.Setlinfo.ClrType
  22100. if adminUser.CurrentOrgId == 10480 {
  22101. if strings.Contains(his.InsuplcAdmdvs, "3412") {
  22102. order.ClrType = "11"
  22103. } else {
  22104. order.ClrType = "9903"
  22105. }
  22106. }
  22107. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  22108. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  22109. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  22110. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  22111. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  22112. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  22113. order.HifpPay = res.Output.Setlinfo.HifpPay
  22114. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  22115. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  22116. order.HifesPay = res.Output.Setlinfo.HifesPay
  22117. order.HifobPay = res.Output.Setlinfo.HifobPay
  22118. order.MafPay = res.Output.Setlinfo.MafPay
  22119. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  22120. order.OthPay = res.Output.Setlinfo.OthPay
  22121. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  22122. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  22123. order.AcctPay = res.Output.Setlinfo.AcctPay
  22124. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  22125. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  22126. order.Balc = res.Output.Setlinfo.Balc
  22127. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  22128. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  22129. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  22130. order.ClrWay = res.Output.Setlinfo.ClrWay
  22131. order.Creator = order.Creator
  22132. order.Modify = roles.AdminUserId
  22133. order.RequestLog = src_resquest
  22134. order.Diagnosis = diagnosis_id
  22135. order.FaPiaoNumber = fapiao_number
  22136. order.FaPiaoCode = fapiao_code
  22137. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  22138. detailStr := string(setlDetail)
  22139. order.SetlDetail = detailStr
  22140. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  22141. err = service.UpDateOrder(order)
  22142. if err == nil {
  22143. //判断是否使用了押金
  22144. if dec_way == "true" {
  22145. tmpstring := strconv.FormatInt(order.ID, 10)
  22146. //扣押金
  22147. order.Decimal = decimal
  22148. service.UpDateOrder(order)
  22149. errmsg = service.SpendDeposit(c.GetAdminUserInfo().CurrentOrgId, id, c.GetAdminUserInfo().AdminUser.Id, tmpstring, decimal)
  22150. if errmsg != nil {
  22151. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, errmsg.Error())
  22152. return
  22153. }
  22154. }
  22155. c.ServeSuccessJSON(map[string]interface{}{
  22156. "msg": "结算成功",
  22157. })
  22158. } else {
  22159. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  22160. return
  22161. }
  22162. }
  22163. }
  22164. }
  22165. }
  22166. // 上传明细-预结算-
  22167. func (c *HisApiController) GetPreUploadInfo() {
  22168. id, _ := c.GetInt64("id")
  22169. record_time := c.GetString("record_time")
  22170. his_patient_id, _ := c.GetInt64("his_patient_id")
  22171. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  22172. admin_user_id, _ := c.GetInt64("admin_user_id")
  22173. diagnosis_id := c.GetString("diagnosis")
  22174. sick_type, _ := c.GetInt64("sick_type")
  22175. reg_type, _ := c.GetInt64("p_type")
  22176. begin_time := c.GetString("begin_time")
  22177. acct_used_flag := c.GetString("acct_used_flag")
  22178. id_str := c.GetString("ids")
  22179. ids_arr := strings.Split(id_str, ",")
  22180. timeLayout := "2006-01-02"
  22181. loc, _ := time.LoadLocation("Local")
  22182. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  22183. if err != nil {
  22184. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  22185. return
  22186. }
  22187. recordDateTime := theTime.Unix()
  22188. adminUser := c.GetAdminUserInfo()
  22189. diagnosis_ids := strings.Split(diagnosis_id, ",")
  22190. var config []*models.HisXtDiagnoseConfig
  22191. for _, item := range diagnosis_ids {
  22192. id, _ := strconv.ParseInt(item, 10, 64)
  22193. diagnosisConfig, _ := service.FindDiagnoseById(id)
  22194. config = append(config, &diagnosisConfig)
  22195. }
  22196. //diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  22197. sickConfig, _ := service.FindSickById(sick_type)
  22198. var prescriptions []*models.HisPrescription
  22199. var start_time int64
  22200. var end_time int64
  22201. var isSuccess bool = true
  22202. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  22203. fmt.Println(his_patient_id)
  22204. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  22205. timestamp := time.Now().Unix()
  22206. tempTime := time.Unix(timestamp, 0)
  22207. timeFormat := tempTime.Format("20060102150405")
  22208. chrgBchno := rand.Intn(100000) + 10000
  22209. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10)
  22210. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  22211. var patientPrescription models.HisPrescriptionInfo
  22212. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  22213. if patientPrescription.ID == 0 {
  22214. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  22215. }
  22216. //miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  22217. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  22218. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  22219. strconv.FormatInt(his.PatientId, 10)
  22220. var res2406 Result2406
  22221. //安徽单病种处理
  22222. if miConfig.MdtrtareaAdmvs == "341203" && reg_type == 992102 {
  22223. data := make(map[string]interface{})
  22224. client := &http.Client{}
  22225. data["psn_no"] = his.PsnNo
  22226. data["mdtrt_id"] = his.Number
  22227. data["operator"] = roles.UserName
  22228. data["cert_no"] = his.IdCardNo
  22229. data["org_name"] = miConfig.OrgName
  22230. data["psn_name"] = his.Name
  22231. data["ipt_otp_no"] = his.IptOtpNo
  22232. data["ipt_psn_sp_flag_type"] = "0901"
  22233. data["ipt_psn_sp_flag"] = "1"
  22234. data["fixmedins_code"] = miConfig.Code
  22235. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  22236. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  22237. data["url"] = miConfig.Url
  22238. utils.ErrorLog("接口返回数据解析JSON失败: %v", data)
  22239. bytesData, _ := json.Marshal(data)
  22240. var req *http.Request
  22241. utils.ErrorLog("接口返回数据解析JSON失败: %v", miConfig.SecretKey)
  22242. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2406", bytes.NewReader(bytesData))
  22243. resp, _ := client.Do(req)
  22244. defer resp.Body.Close()
  22245. body, ioErr := ioutil.ReadAll(resp.Body)
  22246. if ioErr != nil {
  22247. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  22248. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22249. return
  22250. }
  22251. var respJSON map[string]interface{}
  22252. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  22253. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22254. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22255. return
  22256. }
  22257. status := respJSON["data"].(map[string]interface{})["status"].(string)
  22258. if status == "0" {
  22259. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  22260. c.ServeSuccessJSON(map[string]interface{}{
  22261. "failed_code": -10,
  22262. "msg": err_msg,
  22263. })
  22264. return
  22265. }
  22266. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22267. userJSONBytes, _ := json.Marshal(respJSON)
  22268. fmt.Println("log")
  22269. fmt.Println(string(userJSONBytes))
  22270. if err := json.Unmarshal(userJSONBytes, &res2406); err != nil {
  22271. utils.ErrorLog("解析失败:%v", err)
  22272. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22273. return
  22274. }
  22275. }
  22276. if res2406.Infcode != 0 {
  22277. adminUser := c.GetAdminUserInfo()
  22278. errlog := &models.HisOrderError{
  22279. UserOrgId: adminUser.CurrentOrgId,
  22280. Ctime: time.Now().Unix(),
  22281. Mtime: time.Now().Unix(),
  22282. ErrMsg: res2406.ErrMsg,
  22283. Status: 1,
  22284. PatientId: id,
  22285. RecordTime: recordDateTime,
  22286. Stage: 3,
  22287. }
  22288. service.CreateErrMsgLog(errlog)
  22289. c.ServeSuccessJSON(map[string]interface{}{
  22290. "failed_code": -10,
  22291. "msg": res2406.ErrMsg,
  22292. })
  22293. return
  22294. }
  22295. var res2 ResultSix
  22296. var res3 GZResultSix
  22297. var resSix10265 ResultSix10265
  22298. //var time_stamp string
  22299. if miConfig.MdtrtareaAdmvs == "421300" {
  22300. data := make(map[string]interface{})
  22301. client := &http.Client{}
  22302. data["psn_no"] = his.PsnNo
  22303. data["mdtrt_id"] = his.Number
  22304. data["department"] = department.Name
  22305. data["org_name"] = miConfig.OrgName
  22306. data["med_type"] = strconv.FormatInt(reg_type, 10)
  22307. data["doctor_id"] = doctor_info.DoctorNumber
  22308. data["doctor_name"] = roles.UserName
  22309. data["fixmedins_code"] = miConfig.Code
  22310. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  22311. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  22312. data["secret_key"] = miConfig.SecretKey
  22313. data["sick_code"] = sickConfig.CountryCode
  22314. data["sick_name"] = sickConfig.ClassName
  22315. data["begin_time"] = begin_time
  22316. data["dept"] = strconv.FormatInt(department.ID, 10)
  22317. data["config"] = config
  22318. data["opter"] = roles.UserName
  22319. fmt.Println(data)
  22320. bytesData, _ := json.Marshal(data)
  22321. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  22322. resp, _ := client.Do(req)
  22323. defer resp.Body.Close()
  22324. body, ioErr := ioutil.ReadAll(resp.Body)
  22325. if ioErr != nil {
  22326. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  22327. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22328. return
  22329. }
  22330. var respJSON map[string]interface{}
  22331. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  22332. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22333. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22334. return
  22335. }
  22336. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22337. userJSONBytes, _ := json.Marshal(respJSON)
  22338. fmt.Println("log")
  22339. fmt.Println(string(userJSONBytes))
  22340. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  22341. utils.ErrorLog("解析失败:%v", err)
  22342. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22343. return
  22344. }
  22345. } else if miConfig.MdtrtareaAdmvs == "420200" {
  22346. data := make(map[string]interface{})
  22347. client := &http.Client{}
  22348. data["psn_no"] = his.PsnNo
  22349. data["mdtrt_id"] = his.Number
  22350. data["department"] = department.Name
  22351. data["org_name"] = miConfig.OrgName
  22352. if reg_type == 11 && his.Insutype == "390" {
  22353. data["med_type"] = "110104"
  22354. } else {
  22355. data["med_type"] = strconv.FormatInt(reg_type, 10)
  22356. }
  22357. data["doctor_id"] = doctor_info.DoctorNumber
  22358. data["doctor_name"] = roles.UserName
  22359. data["fixmedins_code"] = miConfig.Code
  22360. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  22361. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  22362. data["secret_key"] = miConfig.SecretKey
  22363. data["sick_code"] = sickConfig.CountryCode
  22364. data["sick_name"] = sickConfig.ClassName
  22365. data["begin_time"] = begin_time
  22366. data["dept"] = strconv.FormatInt(department.ID, 10)
  22367. data["config"] = config
  22368. data["opter"] = roles.UserName
  22369. fmt.Println(data)
  22370. bytesData, _ := json.Marshal(data)
  22371. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  22372. resp, _ := client.Do(req)
  22373. defer resp.Body.Close()
  22374. body, ioErr := ioutil.ReadAll(resp.Body)
  22375. if ioErr != nil {
  22376. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  22377. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22378. return
  22379. }
  22380. var respJSON map[string]interface{}
  22381. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  22382. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22383. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22384. return
  22385. }
  22386. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22387. userJSONBytes, _ := json.Marshal(respJSON)
  22388. fmt.Println("log")
  22389. fmt.Println(string(userJSONBytes))
  22390. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  22391. utils.ErrorLog("解析失败:%v", err)
  22392. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22393. return
  22394. }
  22395. } else if miConfig.MdtrtareaAdmvs == "420902" {
  22396. data := make(map[string]interface{})
  22397. client := &http.Client{}
  22398. data["psn_no"] = his.PsnNo
  22399. data["mdtrt_id"] = his.Number
  22400. data["department"] = department.Name
  22401. data["org_name"] = miConfig.OrgName
  22402. if reg_type == 11 && his.Insutype == "390" {
  22403. data["med_type"] = "110104"
  22404. } else {
  22405. data["med_type"] = strconv.FormatInt(reg_type, 10)
  22406. }
  22407. data["doctor_id"] = doctor_info.DoctorNumber
  22408. data["doctor_name"] = roles.UserName
  22409. data["fixmedins_code"] = miConfig.Code
  22410. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  22411. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  22412. data["secret_key"] = miConfig.SecretKey
  22413. data["sick_code"] = sickConfig.CountryCode
  22414. data["sick_name"] = sickConfig.ClassName
  22415. data["begin_time"] = begin_time
  22416. data["dept"] = strconv.FormatInt(department.ID, 10)
  22417. data["config"] = config
  22418. data["opter"] = roles.UserName
  22419. fmt.Println(data)
  22420. bytesData, _ := json.Marshal(data)
  22421. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2203", bytes.NewReader(bytesData))
  22422. resp, _ := client.Do(req)
  22423. defer resp.Body.Close()
  22424. body, ioErr := ioutil.ReadAll(resp.Body)
  22425. if ioErr != nil {
  22426. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  22427. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22428. return
  22429. }
  22430. var respJSON map[string]interface{}
  22431. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  22432. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22433. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22434. return
  22435. }
  22436. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22437. userJSONBytes, _ := json.Marshal(respJSON)
  22438. fmt.Println("log")
  22439. fmt.Println(string(userJSONBytes))
  22440. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  22441. utils.ErrorLog("解析失败:%v", err)
  22442. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22443. return
  22444. }
  22445. } else if miConfig.MdtrtareaAdmvs == "421182" {
  22446. data := make(map[string]interface{})
  22447. client := &http.Client{}
  22448. data["psn_no"] = his.PsnNo
  22449. data["mdtrt_id"] = his.Number
  22450. data["department"] = department.Name
  22451. data["org_name"] = miConfig.OrgName
  22452. if reg_type == 11 && his.Insutype == "390" {
  22453. data["med_type"] = "110104"
  22454. } else {
  22455. data["med_type"] = strconv.FormatInt(reg_type, 10)
  22456. }
  22457. data["doctor_id"] = doctor_info.DoctorNumber
  22458. data["doctor_name"] = roles.UserName
  22459. data["fixmedins_code"] = miConfig.Code
  22460. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  22461. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  22462. data["secret_key"] = miConfig.SecretKey
  22463. data["sick_code"] = sickConfig.CountryCode
  22464. data["sick_name"] = sickConfig.ClassName
  22465. data["begin_time"] = begin_time
  22466. data["dept"] = strconv.FormatInt(department.ID, 10)
  22467. data["config"] = config
  22468. data["opter"] = roles.UserName
  22469. fmt.Println(data)
  22470. bytesData, _ := json.Marshal(data)
  22471. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2203", bytes.NewReader(bytesData))
  22472. resp, _ := client.Do(req)
  22473. defer resp.Body.Close()
  22474. body, ioErr := ioutil.ReadAll(resp.Body)
  22475. if ioErr != nil {
  22476. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  22477. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22478. return
  22479. }
  22480. var respJSON map[string]interface{}
  22481. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  22482. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22483. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22484. return
  22485. }
  22486. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22487. userJSONBytes, _ := json.Marshal(respJSON)
  22488. fmt.Println("log")
  22489. fmt.Println(string(userJSONBytes))
  22490. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  22491. utils.ErrorLog("解析失败:%v", err)
  22492. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22493. return
  22494. }
  22495. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  22496. data := make(map[string]interface{})
  22497. client := &http.Client{}
  22498. data["psn_no"] = his.PsnNo
  22499. data["mdtrt_id"] = his.Number
  22500. data["doctor"] = roles.UserName
  22501. data["department"] = department.Name
  22502. data["org_name"] = miConfig.OrgName
  22503. data["med_type"] = strconv.FormatInt(reg_type, 10)
  22504. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  22505. data["fixmedins_code"] = miConfig.Code
  22506. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  22507. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  22508. data["secret_key"] = miConfig.SecretKey
  22509. data["sick_code"] = sickConfig.CountryCode
  22510. data["sick_name"] = sickConfig.ClassName
  22511. data["begin_time"] = begin_time
  22512. data["dept"] = strconv.FormatInt(department.ID, 10)
  22513. data["config"] = config
  22514. data["url"] = miConfig.Url
  22515. data["ak"] = miConfig.AccessKey
  22516. data["cainfo"] = miConfig.Cainfo
  22517. bytesData, _ := json.Marshal(data)
  22518. var req *http.Request
  22519. if miConfig.MdtrtareaAdmvs == "320921" {
  22520. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  22521. } else {
  22522. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  22523. }
  22524. resp, _ := client.Do(req)
  22525. defer resp.Body.Close()
  22526. body, ioErr := ioutil.ReadAll(resp.Body)
  22527. if ioErr != nil {
  22528. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  22529. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22530. return
  22531. }
  22532. var respJSON map[string]interface{}
  22533. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  22534. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22535. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22536. return
  22537. }
  22538. //time_stamp := strconv.FormatInt(int64(respJSON["data"].(map[string]interface{})["time_stamp"].(float64)), 10)
  22539. //fmt.Println(respJSON["data"].(map[string]interface{})["time_stamp"].(string))
  22540. //time_stamp = respJSON["data"].(map[string]interface{})["time_stamp"].(string)
  22541. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22542. userJSONBytes, _ := json.Marshal(respJSON)
  22543. fmt.Println("log")
  22544. fmt.Println(string(userJSONBytes))
  22545. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  22546. utils.ErrorLog("解析失败:%v", err)
  22547. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22548. return
  22549. }
  22550. res2.InfRefmsgid = resSix10265.InfRefmsgid
  22551. res2.Output = resSix10265.Output
  22552. res2.ErrMsg = resSix10265.ErrMsg
  22553. res2.Cainfo = resSix10265.Cainfo
  22554. res2.WarnMsg = resSix10265.WarnMsg
  22555. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  22556. res2.Infcode = infocode
  22557. } else if miConfig.MdtrtareaAdmvs == "150499" {
  22558. data := make(map[string]interface{})
  22559. client := &http.Client{}
  22560. data["psn_no"] = his.PsnNo
  22561. data["mdtrt_id"] = his.Number
  22562. data["doctor"] = roles.UserName
  22563. data["department"] = department.Name
  22564. data["org_name"] = miConfig.OrgName
  22565. data["med_type"] = strconv.FormatInt(reg_type, 10)
  22566. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  22567. data["fixmedins_code"] = miConfig.Code
  22568. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  22569. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  22570. data["secret_key"] = miConfig.SecretKey
  22571. data["sick_code"] = sickConfig.CountryCode
  22572. data["sick_name"] = sickConfig.ClassName
  22573. data["begin_time"] = begin_time
  22574. data["dept"] = strconv.FormatInt(department.ID, 10)
  22575. data["config"] = config
  22576. //data["url"] = miConfig.Url
  22577. //data["ak"] = miConfig.AccessKey
  22578. data["cainfo"] = miConfig.Cainfo
  22579. fmt.Println(data)
  22580. bytesData, _ := json.Marshal(data)
  22581. var req *http.Request
  22582. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2203", bytes.NewReader(bytesData))
  22583. resp, _ := client.Do(req)
  22584. defer resp.Body.Close()
  22585. body, ioErr := ioutil.ReadAll(resp.Body)
  22586. if ioErr != nil {
  22587. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  22588. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22589. return
  22590. }
  22591. var respJSON map[string]interface{}
  22592. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  22593. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22594. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22595. return
  22596. }
  22597. //time_stamp := strconv.FormatInt(int64(respJSON["data"].(map[string]interface{})["time_stamp"].(float64)), 10)
  22598. //fmt.Println(respJSON["data"].(map[string]interface{})["time_stamp"].(string))
  22599. //time_stamp = respJSON["data"].(map[string]interface{})["time_stamp"].(string)
  22600. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22601. userJSONBytes, _ := json.Marshal(respJSON)
  22602. fmt.Println("log")
  22603. fmt.Println(string(userJSONBytes))
  22604. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  22605. utils.ErrorLog("解析失败:%v", err)
  22606. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22607. return
  22608. }
  22609. res2.InfRefmsgid = resSix10265.InfRefmsgid
  22610. res2.Output = resSix10265.Output
  22611. res2.ErrMsg = resSix10265.ErrMsg
  22612. res2.Cainfo = resSix10265.Cainfo
  22613. res2.WarnMsg = resSix10265.WarnMsg
  22614. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  22615. res2.Infcode = infocode
  22616. } else if miConfig.MdtrtareaAdmvs == "350500" {
  22617. 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)
  22618. saveLog(result, requestLog, "2203", "上传就诊信息")
  22619. var respJSON2 map[string]interface{}
  22620. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  22621. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22622. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22623. return
  22624. }
  22625. userJSONBytes2, _ := json.Marshal(respJSON2)
  22626. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  22627. utils.ErrorLog("解析失败:%v", err)
  22628. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22629. return
  22630. }
  22631. } else if miConfig.MdtrtareaAdmvs == "360302" {
  22632. var result string
  22633. var requestLog string
  22634. 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, "")
  22635. saveLog(result, requestLog, "2203", "上传就诊信息")
  22636. var respJSON2 map[string]interface{}
  22637. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  22638. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22639. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22640. return
  22641. }
  22642. userJSONBytes2, _ := json.Marshal(respJSON2)
  22643. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  22644. utils.ErrorLog("解析失败:%v", err)
  22645. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22646. return
  22647. }
  22648. } else if miConfig.MdtrtareaAdmvs == "341203" {
  22649. data := make(map[string]interface{})
  22650. client := &http.Client{}
  22651. data["psn_no"] = his.PsnNo
  22652. data["mdtrt_id"] = his.Number
  22653. data["operator"] = roles.UserName
  22654. data["department"] = department.Name
  22655. data["org_name"] = miConfig.OrgName
  22656. var med_type string
  22657. if his.Insutype == "390" {
  22658. if reg_type == 992102 {
  22659. med_type = "992102"
  22660. data["sick_code"] = "ZDZ940"
  22661. data["sick_name"] = "慢性肾衰竭"
  22662. }
  22663. if reg_type == 140104 {
  22664. med_type = "140104"
  22665. data["sick_code"] = sickConfig.CountryCode
  22666. data["sick_name"] = sickConfig.ClassName
  22667. }
  22668. if reg_type == 14 {
  22669. med_type = "140104"
  22670. data["sick_code"] = sickConfig.CountryCode
  22671. data["sick_name"] = sickConfig.ClassName
  22672. }
  22673. } else if his.Insutype == "310" {
  22674. if reg_type == 992102 {
  22675. med_type = "992102"
  22676. data["sick_code"] = "ZDZ940"
  22677. data["sick_name"] = "慢性肾衰竭"
  22678. }
  22679. if reg_type == 140104 {
  22680. med_type = "140104"
  22681. data["sick_code"] = sickConfig.CountryCode
  22682. data["sick_name"] = sickConfig.ClassName
  22683. }
  22684. if reg_type == 14 {
  22685. med_type = "14"
  22686. data["sick_code"] = sickConfig.CountryCode
  22687. data["sick_name"] = sickConfig.ClassName
  22688. }
  22689. }
  22690. data["med_type"] = med_type
  22691. data["doctor_number"] = doctor_info.DoctorNumber
  22692. data["doctor_name"] = doctor_info.UserName
  22693. data["fixmedins_code"] = miConfig.Code
  22694. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  22695. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  22696. data["secret_key"] = miConfig.SecretKey
  22697. data["begin_time"] = begin_time
  22698. data["dept"] = strconv.FormatInt(department.ID, 10)
  22699. data["config"] = config
  22700. data["url"] = miConfig.Url
  22701. data["ak"] = miConfig.AccessKey
  22702. data["cainfo"] = miConfig.Cainfo
  22703. bytesData, _ := json.Marshal(data)
  22704. var req *http.Request
  22705. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2203", bytes.NewReader(bytesData))
  22706. resp, _ := client.Do(req)
  22707. defer resp.Body.Close()
  22708. body, ioErr := ioutil.ReadAll(resp.Body)
  22709. if ioErr != nil {
  22710. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  22711. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22712. return
  22713. }
  22714. var respJSON map[string]interface{}
  22715. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  22716. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22717. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22718. return
  22719. }
  22720. status := respJSON["data"].(map[string]interface{})["status"].(string)
  22721. if status == "0" {
  22722. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  22723. c.ServeSuccessJSON(map[string]interface{}{
  22724. "failed_code": -10,
  22725. "msg": err_msg,
  22726. })
  22727. return
  22728. }
  22729. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22730. userJSONBytes, _ := json.Marshal(respJSON)
  22731. fmt.Println("log")
  22732. fmt.Println(string(userJSONBytes))
  22733. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  22734. utils.ErrorLog("解析失败:%v", err)
  22735. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22736. return
  22737. }
  22738. } else if miConfig.MdtrtareaAdmvs == "430800" {
  22739. var result string
  22740. var requestLog string
  22741. 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, "")
  22742. saveLog(result, requestLog, "2203", "上传就诊信息")
  22743. var respJSON2 map[string]interface{}
  22744. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  22745. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22746. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22747. return
  22748. }
  22749. userJSONBytes2, _ := json.Marshal(respJSON2)
  22750. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  22751. utils.ErrorLog("解析失败:%v", err)
  22752. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22753. return
  22754. }
  22755. } else if miConfig.MdtrtareaAdmvs == "441799" {
  22756. data := make(map[string]interface{})
  22757. client := &http.Client{}
  22758. data["psn_no"] = his.PsnNo
  22759. data["mdtrt_id"] = his.Number
  22760. data["doctor"] = roles.UserName
  22761. data["department"] = department.Name
  22762. data["org_name"] = miConfig.OrgName
  22763. data["med_type"] = strconv.FormatInt(reg_type, 10)
  22764. data["doctor_id"] = doctor_info.DoctorNumber
  22765. data["fixmedins_code"] = miConfig.Code
  22766. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  22767. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  22768. data["secret_key"] = miConfig.SecretKey
  22769. data["sick_code"] = sickConfig.CountryCode
  22770. data["sick_name"] = sickConfig.ClassName
  22771. data["begin_time"] = begin_time
  22772. data["new_doctor_name"] = doctor_info.UserName
  22773. data["dept"] = strconv.FormatInt(department.ID, 10)
  22774. data["config"] = config
  22775. bytesData, _ := json.Marshal(data)
  22776. var req *http.Request
  22777. req, _ = http.NewRequest("POST", miConfig.Url+"gdyb/2203", bytes.NewReader(bytesData))
  22778. resp, _ := client.Do(req)
  22779. defer resp.Body.Close()
  22780. body, ioErr := ioutil.ReadAll(resp.Body)
  22781. if ioErr != nil {
  22782. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  22783. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22784. return
  22785. }
  22786. var respJSON map[string]interface{}
  22787. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  22788. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22789. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22790. return
  22791. }
  22792. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22793. userJSONBytes, _ := json.Marshal(respJSON)
  22794. fmt.Println("log")
  22795. fmt.Println(string(userJSONBytes))
  22796. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  22797. utils.ErrorLog("解析失败:%v", err)
  22798. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22799. return
  22800. }
  22801. } else {
  22802. var result string
  22803. var requestLog string
  22804. if miConfig.MdtrtareaAdmvs == "440781" { //
  22805. 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)
  22806. } else {
  22807. if miConfig.Code == "H15049901371" {
  22808. //赤峰地区国家医保医疗类别
  22809. //职工透析:医疗类别选特殊情况门诊990502
  22810. //居民定额血透门慢: 医疗类别选门诊慢病140104
  22811. var med_type string
  22812. if his.Insutype == "390" {
  22813. if reg_type == 14 {
  22814. med_type = "9933"
  22815. } else if reg_type == 11 {
  22816. med_type = "11"
  22817. }
  22818. } else if his.Insutype == "310" {
  22819. if reg_type == 14 {
  22820. med_type = "990502"
  22821. } else if reg_type == 11 {
  22822. med_type = "11"
  22823. }
  22824. }
  22825. 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)
  22826. } else {
  22827. 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)
  22828. }
  22829. saveLog(result, requestLog, "2203", "上传就诊信息")
  22830. var respJSON2 map[string]interface{}
  22831. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  22832. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22833. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22834. return
  22835. }
  22836. userJSONBytes2, _ := json.Marshal(respJSON2)
  22837. if miConfig.Code == "H15049901371" {
  22838. if err := json.Unmarshal(userJSONBytes2, &resSix10265); err != nil {
  22839. utils.ErrorLog("解析失败:%v", err)
  22840. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22841. return
  22842. }
  22843. res2.InfRefmsgid = resSix10265.InfRefmsgid
  22844. res2.Output = resSix10265.Output
  22845. res2.ErrMsg = resSix10265.ErrMsg
  22846. res2.Cainfo = resSix10265.Cainfo
  22847. res2.WarnMsg = resSix10265.WarnMsg
  22848. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  22849. res2.Infcode = infocode
  22850. } else {
  22851. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  22852. if err := json.Unmarshal(userJSONBytes2, &res3); err != nil {
  22853. utils.ErrorLog("解析失败:%v", err)
  22854. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22855. return
  22856. }
  22857. res2.Infcode = res3.Infcode
  22858. } else {
  22859. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  22860. utils.ErrorLog("解析失败:%v", err)
  22861. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22862. return
  22863. }
  22864. }
  22865. }
  22866. }
  22867. }
  22868. if res2.Infcode == -1 {
  22869. adminUser := c.GetAdminUserInfo()
  22870. errlog := &models.HisOrderError{
  22871. UserOrgId: adminUser.CurrentOrgId,
  22872. Ctime: time.Now().Unix(),
  22873. Mtime: time.Now().Unix(),
  22874. ErrMsg: res2.ErrMsg,
  22875. Status: 1,
  22876. PatientId: id,
  22877. RecordTime: recordDateTime,
  22878. Stage: 3,
  22879. }
  22880. service.CreateErrMsgLog(errlog)
  22881. c.ServeSuccessJSON(map[string]interface{}{
  22882. "failed_code": -10,
  22883. "msg": res2.ErrMsg,
  22884. })
  22885. return
  22886. }
  22887. if res2.Infcode != 0 {
  22888. adminUser := c.GetAdminUserInfo()
  22889. errlog := &models.HisOrderError{
  22890. UserOrgId: adminUser.CurrentOrgId,
  22891. Ctime: time.Now().Unix(),
  22892. Mtime: time.Now().Unix(),
  22893. ErrMsg: res2.ErrMsg,
  22894. Status: 1,
  22895. PatientId: id,
  22896. RecordTime: recordDateTime,
  22897. Stage: 3,
  22898. }
  22899. service.CreateErrMsgLog(errlog)
  22900. c.ServeSuccessJSON(map[string]interface{}{
  22901. "failed_code": -10,
  22902. "msg": res2.ErrMsg,
  22903. })
  22904. return
  22905. } else {
  22906. his.Diagnosis = diagnosis_id
  22907. his.SickType = sickConfig.ID
  22908. his.PType = fmt.Sprintf("%d", reg_type)
  22909. service.UpdateHisPatientThree(&his)
  22910. data := make(map[string]interface{})
  22911. if settle_accounts_type == 1 { //日结
  22912. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  22913. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  22914. } else {
  22915. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  22916. }
  22917. data["pre"] = prescriptions
  22918. } else { //月结
  22919. start_time_str := c.GetString("start_time")
  22920. end_time_str := c.GetString("end_time")
  22921. timeLayout := "2006-01-02"
  22922. loc, _ := time.LoadLocation("Local")
  22923. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  22924. if err != nil {
  22925. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  22926. return
  22927. }
  22928. recordStartTime := theStartTime.Unix()
  22929. start_time = recordStartTime
  22930. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  22931. if err != nil {
  22932. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  22933. return
  22934. }
  22935. recordEndTime := theEndTime.Unix()
  22936. end_time = recordEndTime
  22937. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  22938. data["pre"] = prescriptions
  22939. }
  22940. client := &http.Client{}
  22941. data["psn_no"] = his.PsnNo
  22942. data["mdtrt_id"] = his.Number
  22943. data["chrg_bchno"] = chrg_bchno
  22944. data["org_name"] = miConfig.OrgName
  22945. data["doctor"] = doctor_info.UserName
  22946. data["doctor_id"] = doctor_info.DoctorNumber
  22947. data["dept"] = department.Name
  22948. data["fixmedins_code"] = miConfig.Code
  22949. data["opter"] = roles.UserName
  22950. data["dept_code"] = department.Number
  22951. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  22952. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  22953. data["secret_key"] = miConfig.SecretKey
  22954. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  22955. data["url"] = miConfig.Url
  22956. data["ak"] = miConfig.AccessKey
  22957. data["new_doctor_name"] = patientPrescription.Doctor
  22958. if his.Insutype == "390" {
  22959. if reg_type == 992102 {
  22960. data["diag_code"] = "ZDZ940"
  22961. }
  22962. if reg_type == 140104 {
  22963. data["diag_code"] = sickConfig.CountryCode
  22964. }
  22965. if reg_type == 14 {
  22966. data["diag_code"] = sickConfig.CountryCode
  22967. }
  22968. } else if his.Insutype == "310" {
  22969. if reg_type == 992102 {
  22970. data["diag_code"] = "ZDZ940"
  22971. }
  22972. if reg_type == 14 {
  22973. data["diag_code"] = sickConfig.CountryCode
  22974. }
  22975. }
  22976. data["cainfo"] = miConfig.Cainfo
  22977. data["opter"] = roles.UserName
  22978. var ids []int64
  22979. for _, item := range prescriptions {
  22980. ids = append(ids, item.ID)
  22981. }
  22982. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  22983. if config.IsOpen == 1 { //对接了医保,走医保流程
  22984. var res ResultFour
  22985. var resFour10265 ResultFour10265
  22986. if miConfig.MdtrtareaAdmvs == "421300" {
  22987. bytesData, _ := json.Marshal(data)
  22988. req, _ := http.NewRequest("POST", "http://192.168.124.13:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  22989. resp, _ := client.Do(req)
  22990. defer resp.Body.Close()
  22991. body, ioErr := ioutil.ReadAll(resp.Body)
  22992. if ioErr != nil {
  22993. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  22994. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22995. return
  22996. }
  22997. var respJSON map[string]interface{}
  22998. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  22999. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23000. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23001. return
  23002. }
  23003. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23004. userJSONBytes, _ := json.Marshal(respJSON)
  23005. fmt.Println("log")
  23006. fmt.Println(string(userJSONBytes))
  23007. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  23008. utils.ErrorLog("解析失败:%v", err)
  23009. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23010. return
  23011. }
  23012. } else if miConfig.MdtrtareaAdmvs == "420200" {
  23013. bytesData, _ := json.Marshal(data)
  23014. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  23015. resp, _ := client.Do(req)
  23016. defer resp.Body.Close()
  23017. body, ioErr := ioutil.ReadAll(resp.Body)
  23018. if ioErr != nil {
  23019. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  23020. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23021. return
  23022. }
  23023. var respJSON map[string]interface{}
  23024. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  23025. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23026. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23027. return
  23028. }
  23029. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23030. userJSONBytes, _ := json.Marshal(respJSON)
  23031. fmt.Println("log")
  23032. fmt.Println(string(userJSONBytes))
  23033. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  23034. utils.ErrorLog("解析失败:%v", err)
  23035. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23036. return
  23037. }
  23038. } else if miConfig.MdtrtareaAdmvs == "420902" {
  23039. bytesData, _ := json.Marshal(data)
  23040. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2204", bytes.NewReader(bytesData))
  23041. resp, _ := client.Do(req)
  23042. defer resp.Body.Close()
  23043. body, ioErr := ioutil.ReadAll(resp.Body)
  23044. if ioErr != nil {
  23045. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  23046. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23047. return
  23048. }
  23049. var respJSON map[string]interface{}
  23050. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  23051. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23052. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23053. return
  23054. }
  23055. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23056. userJSONBytes, _ := json.Marshal(respJSON)
  23057. fmt.Println("log")
  23058. fmt.Println(string(userJSONBytes))
  23059. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  23060. utils.ErrorLog("解析失败:%v", err)
  23061. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23062. return
  23063. }
  23064. } else if miConfig.MdtrtareaAdmvs == "421182" {
  23065. bytesData, _ := json.Marshal(data)
  23066. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2204", bytes.NewReader(bytesData))
  23067. resp, _ := client.Do(req)
  23068. defer resp.Body.Close()
  23069. body, ioErr := ioutil.ReadAll(resp.Body)
  23070. if ioErr != nil {
  23071. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  23072. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23073. return
  23074. }
  23075. var respJSON map[string]interface{}
  23076. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  23077. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23078. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23079. return
  23080. }
  23081. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23082. userJSONBytes, _ := json.Marshal(respJSON)
  23083. fmt.Println("log")
  23084. fmt.Println(string(userJSONBytes))
  23085. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  23086. utils.ErrorLog("解析失败:%v", err)
  23087. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23088. return
  23089. }
  23090. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  23091. result3101 := Check3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  23092. if result3101.Infcode == "0" {
  23093. if len(result3101.Output.Result) > 0 {
  23094. var errMsgs []string
  23095. for _, item := range result3101.Output.Result {
  23096. errMsgs = append(errMsgs, item.VolaCont)
  23097. }
  23098. c.ServeSuccessJSON(map[string]interface{}{
  23099. "failed_code": -10,
  23100. "msg": errMsgs,
  23101. })
  23102. return
  23103. } else {
  23104. if miConfig.MdtrtareaAdmvs == "320921" {
  23105. data["doctor_id"] = "D320923012139"
  23106. } else {
  23107. data["doctor_id"] = "D371621008686"
  23108. }
  23109. bytesData, _ := json.Marshal(data)
  23110. var req *http.Request
  23111. if miConfig.MdtrtareaAdmvs == "320921" {
  23112. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  23113. } else {
  23114. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  23115. }
  23116. resp, _ := client.Do(req)
  23117. defer resp.Body.Close()
  23118. body, ioErr := ioutil.ReadAll(resp.Body)
  23119. if ioErr != nil {
  23120. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  23121. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23122. return
  23123. }
  23124. var respJSON map[string]interface{}
  23125. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  23126. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23127. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23128. return
  23129. }
  23130. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23131. userJSONBytes, _ := json.Marshal(respJSON)
  23132. fmt.Println("log")
  23133. fmt.Println(string(userJSONBytes))
  23134. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  23135. utils.ErrorLog("解析失败:%v", err)
  23136. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23137. return
  23138. }
  23139. res.InfRefmsgid = resFour10265.InfRefmsgid
  23140. res.Output = resFour10265.Output
  23141. res.ErrMsg = resFour10265.ErrMsg
  23142. res.Cainfo = resFour10265.Cainfo
  23143. res.WarnMsg = resFour10265.WarnMsg
  23144. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  23145. res.Infcode = infocode
  23146. }
  23147. }
  23148. } else if miConfig.MdtrtareaAdmvs == "150499" {
  23149. var pagesize int = 5
  23150. var start int = 1
  23151. var stop int
  23152. var pagecount int
  23153. var curpage int
  23154. data["doctor_id"] = doctor_info.DoctorNumber
  23155. var res2 ResultFour
  23156. //var result res.
  23157. //总页数,向上取整,注意除之前要先转换类型为float64
  23158. pagecount = int(math.Ceil(float64(len(prescriptions)) / float64(pagesize)))
  23159. for curpage = 1; curpage <= pagecount; curpage++ {
  23160. if curpage == 1 {
  23161. start = 1
  23162. } else {
  23163. start = (curpage-1)*pagesize + 1
  23164. }
  23165. stop = curpage * pagesize
  23166. if stop > len(prescriptions) {
  23167. stop = len(prescriptions)
  23168. }
  23169. //var requestLog string
  23170. data["pre"] = prescriptions[start-1 : stop]
  23171. fmt.Println(data["pre"])
  23172. bytesData, _ := json.Marshal(data)
  23173. var req *http.Request
  23174. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2204", bytes.NewReader(bytesData))
  23175. resp, _ := client.Do(req)
  23176. defer resp.Body.Close()
  23177. body, ioErr := ioutil.ReadAll(resp.Body)
  23178. if ioErr != nil {
  23179. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  23180. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23181. return
  23182. }
  23183. var respJSON map[string]interface{}
  23184. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  23185. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23186. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23187. return
  23188. }
  23189. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23190. userJSONBytes, _ := json.Marshal(respJSON)
  23191. fmt.Println("log")
  23192. fmt.Println(string(userJSONBytes))
  23193. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  23194. utils.ErrorLog("解析失败:%v", err)
  23195. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23196. return
  23197. }
  23198. res.InfRefmsgid = resFour10265.InfRefmsgid
  23199. res.Output = resFour10265.Output
  23200. res.ErrMsg = resFour10265.ErrMsg
  23201. res.Cainfo = resFour10265.Cainfo
  23202. res.WarnMsg = resFour10265.WarnMsg
  23203. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  23204. res.Infcode = infocode
  23205. if infocode == 0 {
  23206. res2.Output.Result = append(res2.Output.Result, res.Output.Result...)
  23207. } else {
  23208. isSuccess = false
  23209. res2.ErrMsg = res2.ErrMsg + "," + res.ErrMsg
  23210. res.Infcode = -1
  23211. res.ErrMsg = resFour10265.ErrMsg
  23212. errlog := &models.HisOrderError{
  23213. UserOrgId: adminUser.CurrentOrgId,
  23214. Ctime: time.Now().Unix(),
  23215. Mtime: time.Now().Unix(),
  23216. Number: chrg_bchno,
  23217. ErrMsg: "",
  23218. Status: 1,
  23219. PatientId: id,
  23220. RecordTime: recordDateTime,
  23221. Stage: 4,
  23222. }
  23223. service.CreateErrMsgLog(errlog)
  23224. }
  23225. }
  23226. if isSuccess {
  23227. res.Infcode = 0
  23228. res.Output.Result = res2.Output.Result
  23229. } else {
  23230. order := &models.HisOrder{
  23231. UserOrgId: adminUser.CurrentOrgId,
  23232. HisPatientId: his.ID,
  23233. PatientId: his.PatientId,
  23234. SettleAccountsDate: recordDateTime,
  23235. Ctime: time.Now().Unix(),
  23236. Mtime: time.Now().Unix(),
  23237. MdtrtId: his.Number,
  23238. PsnNo: his.PsnNo,
  23239. MedType: strconv.FormatInt(reg_type, 10),
  23240. Status: 1,
  23241. Number: chrg_bchno,
  23242. Infcode: res.Infcode,
  23243. WarnMsg: res.WarnMsg,
  23244. Cainfo: res.Cainfo,
  23245. ErrMsg: res.ErrMsg,
  23246. RespondTime: res.RefmsgTime,
  23247. InfRefmsgid: res.InfRefmsgid,
  23248. OrderStatus: 1,
  23249. IsMedicineInsurance: 1,
  23250. SettleType: settle_accounts_type,
  23251. SettleStartTime: start_time,
  23252. SettleEndTime: end_time,
  23253. Creator: roles.AdminUserId,
  23254. Modify: roles.AdminUserId,
  23255. PType: 2,
  23256. Diagnosis: diagnosis_id,
  23257. }
  23258. err = service.CreateOrder(order)
  23259. if err != nil {
  23260. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  23261. return
  23262. }
  23263. c.ServeSuccessJSON(map[string]interface{}{
  23264. "failed_code": -10,
  23265. "msg": res2.ErrMsg,
  23266. })
  23267. return
  23268. }
  23269. } else if miConfig.MdtrtareaAdmvs == "350500" {
  23270. 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)
  23271. var dat map[string]interface{}
  23272. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  23273. fmt.Println(dat)
  23274. } else {
  23275. fmt.Println(err)
  23276. }
  23277. saveLog(result, request_log, "2204", "上传费用明细")
  23278. userJSONBytes, _ := json.Marshal(dat)
  23279. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  23280. utils.ErrorLog("解析失败:%v", err)
  23281. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23282. return
  23283. }
  23284. } else if miConfig.MdtrtareaAdmvs == "360302" {
  23285. 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, "", "")
  23286. var dat map[string]interface{}
  23287. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  23288. fmt.Println(dat)
  23289. } else {
  23290. fmt.Println(err)
  23291. }
  23292. saveLog(result, request_log, "2204", "上传费用明细")
  23293. userJSONBytes, _ := json.Marshal(dat)
  23294. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  23295. utils.ErrorLog("解析失败:%v", err)
  23296. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23297. return
  23298. }
  23299. } else if miConfig.MdtrtareaAdmvs == "341203" {
  23300. bytesData, _ := json.Marshal(data)
  23301. var req *http.Request
  23302. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2204", bytes.NewReader(bytesData))
  23303. resp, _ := client.Do(req)
  23304. defer resp.Body.Close()
  23305. body, ioErr := ioutil.ReadAll(resp.Body)
  23306. if ioErr != nil {
  23307. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  23308. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23309. return
  23310. }
  23311. var respJSON map[string]interface{}
  23312. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  23313. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23314. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23315. return
  23316. }
  23317. status := respJSON["data"].(map[string]interface{})["status"].(string)
  23318. if status == "0" {
  23319. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  23320. c.ServeSuccessJSON(map[string]interface{}{
  23321. "failed_code": -10,
  23322. "msg": err_msg,
  23323. })
  23324. return
  23325. }
  23326. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23327. userJSONBytes, _ := json.Marshal(respJSON)
  23328. fmt.Println("log")
  23329. fmt.Println(string(userJSONBytes))
  23330. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  23331. utils.ErrorLog("解析失败:%v", err)
  23332. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23333. return
  23334. }
  23335. } else if miConfig.MdtrtareaAdmvs == "430800" {
  23336. 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, "", "")
  23337. var dat map[string]interface{}
  23338. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  23339. fmt.Println(dat)
  23340. } else {
  23341. fmt.Println(err)
  23342. }
  23343. saveLog(result, request_log, "2204", "上传费用明细")
  23344. userJSONBytes, _ := json.Marshal(dat)
  23345. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  23346. utils.ErrorLog("解析失败:%v", err)
  23347. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23348. return
  23349. }
  23350. } else if miConfig.MdtrtareaAdmvs == "441799" {
  23351. bytesData, _ := json.Marshal(data)
  23352. req, _ := http.NewRequest("POST", miConfig.Url+"gdyb/2204", bytes.NewReader(bytesData))
  23353. resp, _ := client.Do(req)
  23354. defer resp.Body.Close()
  23355. body, ioErr := ioutil.ReadAll(resp.Body)
  23356. if ioErr != nil {
  23357. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  23358. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23359. return
  23360. }
  23361. var respJSON map[string]interface{}
  23362. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  23363. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23364. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23365. return
  23366. }
  23367. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23368. userJSONBytes, _ := json.Marshal(respJSON)
  23369. fmt.Println("log")
  23370. fmt.Println(string(userJSONBytes))
  23371. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  23372. utils.ErrorLog("解析失败:%v", err)
  23373. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23374. return
  23375. }
  23376. } else {
  23377. if miConfig.MdtrtareaAdmvs == "441202" {
  23378. result3101 := Checkgd3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  23379. if result3101.Infcode == 0 {
  23380. if len(result3101.Output.Result) > 0 {
  23381. var errMsgs []string
  23382. for _, item := range result3101.Output.Result {
  23383. errMsgs = append(errMsgs, item.VolaCont)
  23384. }
  23385. c.ServeSuccessJSON(map[string]interface{}{
  23386. "failed_code": -10,
  23387. "msg": errMsgs,
  23388. })
  23389. return
  23390. } else {
  23391. 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)
  23392. var dat map[string]interface{}
  23393. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  23394. fmt.Println(dat)
  23395. } else {
  23396. fmt.Println(err)
  23397. }
  23398. saveLog(result, request_log, "2204", "上传费用明细")
  23399. userJSONBytes, _ := json.Marshal(dat)
  23400. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  23401. utils.ErrorLog("解析失败:%v", err)
  23402. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23403. return
  23404. }
  23405. }
  23406. } else {
  23407. c.ServeSuccessJSON(map[string]interface{}{
  23408. "failed_code": -10,
  23409. "msg": result3101.ErrMsg,
  23410. })
  23411. return
  23412. }
  23413. } else {
  23414. if miConfig.Code == "H15049901371" {
  23415. 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)
  23416. var dat map[string]interface{}
  23417. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  23418. fmt.Println(dat)
  23419. } else {
  23420. fmt.Println(err)
  23421. }
  23422. saveLog(result, request_log, "2204", "上传费用明细")
  23423. userJSONBytes, _ := json.Marshal(dat)
  23424. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  23425. utils.ErrorLog("解析失败:%v", err)
  23426. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23427. return
  23428. }
  23429. res.InfRefmsgid = resFour10265.InfRefmsgid
  23430. res.Output = resFour10265.Output
  23431. res.ErrMsg = resFour10265.ErrMsg
  23432. res.Cainfo = resFour10265.Cainfo
  23433. res.WarnMsg = resFour10265.WarnMsg
  23434. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  23435. res.Infcode = infocode
  23436. } else {
  23437. 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)
  23438. var dat map[string]interface{}
  23439. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  23440. fmt.Println(dat)
  23441. } else {
  23442. fmt.Println(err)
  23443. }
  23444. saveLog(result, request_log, "2204", "上传费用明细")
  23445. userJSONBytes, _ := json.Marshal(dat)
  23446. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  23447. utils.ErrorLog("解析失败:%v", err)
  23448. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23449. return
  23450. }
  23451. }
  23452. }
  23453. }
  23454. var total_two float64
  23455. if res.Infcode == 0 {
  23456. order := &models.HisOrder{
  23457. UserOrgId: adminUser.CurrentOrgId,
  23458. HisPatientId: his.ID,
  23459. PatientId: his.PatientId,
  23460. SettleAccountsDate: recordDateTime,
  23461. Ctime: time.Now().Unix(),
  23462. Mtime: time.Now().Unix(),
  23463. MdtrtId: his.Number,
  23464. PsnNo: his.PsnNo,
  23465. MedType: strconv.FormatInt(reg_type, 10),
  23466. Status: 1,
  23467. Number: chrg_bchno,
  23468. Infcode: res.Infcode,
  23469. WarnMsg: res.WarnMsg,
  23470. Cainfo: res.Cainfo,
  23471. ErrMsg: res.ErrMsg,
  23472. RespondTime: res.RefmsgTime,
  23473. InfRefmsgid: res.InfRefmsgid,
  23474. OrderStatus: 1,
  23475. IsMedicineInsurance: 1,
  23476. SettleType: settle_accounts_type,
  23477. SettleStartTime: start_time,
  23478. SettleEndTime: end_time,
  23479. Creator: roles.AdminUserId,
  23480. Modify: roles.AdminUserId,
  23481. PType: 2,
  23482. Diagnosis: diagnosis_id,
  23483. }
  23484. err = service.CreateOrder(order)
  23485. if err != nil {
  23486. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  23487. return
  23488. }
  23489. for _, item := range res.Output.Result {
  23490. temp := strings.Split(item.FeedetlSn, "-")
  23491. var advice_id int64 = 0
  23492. var project_id int64 = 0
  23493. var types int64 = 0
  23494. id, _ := strconv.ParseInt(temp[2], 10, 64)
  23495. types, _ = strconv.ParseInt(temp[1], 10, 64)
  23496. if temp[1] == "1" {
  23497. advice_id = id
  23498. project_id = 0
  23499. } else if temp[1] == "2" {
  23500. advice_id = 0
  23501. project_id = id
  23502. }
  23503. total_two = total_two + item.DetItemFeeSumamt
  23504. info := &models.HisOrderInfo{
  23505. OrderNumber: order.Number,
  23506. FeedetlSn: item.FeedetlSn,
  23507. UploadDate: time.Now().Unix(),
  23508. AdviceId: advice_id,
  23509. DetItemFeeSumamt: item.DetItemFeeSumamt,
  23510. Cnt: item.Cnt,
  23511. Pric: float64(item.Pric),
  23512. PatientId: his.PatientId,
  23513. PricUplmtAmt: item.PricUplmtAmt,
  23514. SelfpayProp: item.SelfpayProp,
  23515. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  23516. OverlmtAmt: item.OverlmtAmt,
  23517. PreselfpayAmt: item.PreselfpayAmt,
  23518. BasMednFlag: item.BasMednFlag,
  23519. MedChrgitmType: item.MedChrgitmType,
  23520. HiNegoDrugFlag: item.HiNegoDrugFlag,
  23521. Status: 1,
  23522. Memo: item.Memo,
  23523. Mtime: time.Now().Unix(),
  23524. InscpScpAmt: item.InscpScpAmt,
  23525. DrtReimFlag: item.DrtReimFlag,
  23526. Ctime: time.Now().Unix(),
  23527. ListSpItemFlag: item.ListSpItemFlag,
  23528. ChldMedcFlag: item.ChldMedcFlag,
  23529. LmtUsedFlag: item.LmtUsedFlag,
  23530. ChrgitmLv: item.ChrgitmLv,
  23531. UserOrgId: adminUser.CurrentOrgId,
  23532. HisPatientId: his.ID,
  23533. OrderId: order.ID,
  23534. ProjectId: project_id,
  23535. Type: types,
  23536. }
  23537. service.CreateOrderInfo(info)
  23538. }
  23539. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  23540. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  23541. var total float64
  23542. for _, item := range prescriptions {
  23543. if item.Type == 1 { //药品
  23544. for _, subItem := range item.HisDoctorAdviceInfo {
  23545. price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  23546. total_one := price * subItem.PrescribingNumber
  23547. fmt.Println("subItem")
  23548. fmt.Println(subItem.Price)
  23549. fmt.Println("price")
  23550. fmt.Println(price)
  23551. fmt.Println("total_one")
  23552. fmt.Println(total_one)
  23553. total = total + total_one
  23554. fmt.Println(total)
  23555. }
  23556. }
  23557. if item.Type == 2 { //项目
  23558. for _, subItem := range item.HisPrescriptionProject {
  23559. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  23560. price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  23561. total_one := price * cnt
  23562. total = total + total_one
  23563. }
  23564. }
  23565. }
  23566. allTotal := fmt.Sprintf("%.2f", total)
  23567. if res.Infcode == 0 {
  23568. var rf []*ResultFive
  23569. json.Unmarshal([]byte(his.Iinfo), &rf)
  23570. chrg_bchno := chrg_bchno
  23571. cert_no := his.Certno
  23572. var insutypes []string
  23573. var insutype string
  23574. var is390 int = 0
  23575. var is310 int = 0
  23576. for _, item := range rf {
  23577. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  23578. insutypes = append(insutypes, item.Insutype)
  23579. }
  23580. }
  23581. if len(insutypes) == 1 {
  23582. insutype = insutypes[0]
  23583. } else {
  23584. for _, i := range insutypes {
  23585. if i == "390" {
  23586. is390 = 1
  23587. }
  23588. if i == "310" {
  23589. is310 = 1
  23590. }
  23591. }
  23592. }
  23593. if is390 == 1 {
  23594. insutype = "390"
  23595. }
  23596. if is310 == 1 {
  23597. insutype = "310"
  23598. }
  23599. if len(insutypes) == 0 {
  23600. insutype = "390"
  23601. }
  23602. if len(insutypes) == 2 {
  23603. insutype = strconv.FormatInt(his.SocialType, 10)
  23604. }
  23605. //insutype = "390"
  23606. if his.IdCardType == 1 {
  23607. cert_no = his.MedicalInsuranceNumber
  23608. } else {
  23609. cert_no = his.Certno
  23610. }
  23611. var res ResultSeven
  23612. var ahres ResultSevenAH
  23613. var resSeven10265 ResultSeven10265
  23614. var resSeven10265Two ResultSeven10265Two
  23615. var gzresSeven10265Two GZResultSeven10265Two
  23616. if miConfig.MdtrtareaAdmvs == "421300" {
  23617. formattedString := strconv.FormatFloat(total, 'f', 2, 64)
  23618. api := "http://192.168.124.4:9532/" + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  23619. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  23620. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  23621. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  23622. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  23623. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  23624. "&insutype=" + insutype + "&total=" + formattedString + "&med_type=" + strconv.FormatInt(reg_type, 10)
  23625. resp, requestErr := http.Get(api)
  23626. if requestErr != nil {
  23627. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23628. return
  23629. }
  23630. body, ioErr := ioutil.ReadAll(resp.Body)
  23631. if ioErr != nil {
  23632. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  23633. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23634. return
  23635. }
  23636. var respJSON map[string]interface{}
  23637. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  23638. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23639. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23640. return
  23641. }
  23642. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23643. result, _ := json.Marshal(respJSON)
  23644. fmt.Println("log")
  23645. fmt.Println(string(result))
  23646. if err := json.Unmarshal([]byte(result), &res); err != nil {
  23647. utils.ErrorLog("解析失败:%v", err)
  23648. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23649. return
  23650. }
  23651. } else if miConfig.MdtrtareaAdmvs == "420200" {
  23652. if reg_type == 11 && his.Insutype == "390" {
  23653. reg_type = 110104
  23654. }
  23655. api := "http://192.168.0.197:9532/" + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  23656. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  23657. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  23658. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  23659. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  23660. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  23661. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  23662. resp, requestErr := http.Get(api)
  23663. if requestErr != nil {
  23664. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23665. return
  23666. }
  23667. body, ioErr := ioutil.ReadAll(resp.Body)
  23668. if ioErr != nil {
  23669. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  23670. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23671. return
  23672. }
  23673. var respJSON map[string]interface{}
  23674. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  23675. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23676. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23677. return
  23678. }
  23679. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23680. result, _ := json.Marshal(respJSON)
  23681. fmt.Println("log")
  23682. fmt.Println(string(result))
  23683. if err := json.Unmarshal([]byte(result), &res); err != nil {
  23684. utils.ErrorLog("解析失败:%v", err)
  23685. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23686. return
  23687. }
  23688. } else if miConfig.MdtrtareaAdmvs == "420902" {
  23689. if reg_type == 11 && his.Insutype == "390" {
  23690. reg_type = 110104
  23691. }
  23692. api := miConfig.Url + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  23693. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  23694. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  23695. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  23696. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  23697. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  23698. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  23699. resp, requestErr := http.Get(api)
  23700. if requestErr != nil {
  23701. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23702. return
  23703. }
  23704. body, ioErr := ioutil.ReadAll(resp.Body)
  23705. if ioErr != nil {
  23706. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  23707. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23708. return
  23709. }
  23710. var respJSON map[string]interface{}
  23711. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  23712. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23713. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23714. return
  23715. }
  23716. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23717. result, _ := json.Marshal(respJSON)
  23718. fmt.Println("log")
  23719. fmt.Println(string(result))
  23720. if err := json.Unmarshal([]byte(result), &res); err != nil {
  23721. utils.ErrorLog("解析失败:%v", err)
  23722. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23723. return
  23724. }
  23725. } else if miConfig.MdtrtareaAdmvs == "421182" {
  23726. if reg_type == 11 && his.Insutype == "390" {
  23727. reg_type = 110104
  23728. }
  23729. api := miConfig.Url + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  23730. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  23731. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  23732. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  23733. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  23734. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  23735. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  23736. resp, requestErr := http.Get(api)
  23737. if requestErr != nil {
  23738. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23739. return
  23740. }
  23741. body, ioErr := ioutil.ReadAll(resp.Body)
  23742. if ioErr != nil {
  23743. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  23744. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23745. return
  23746. }
  23747. var respJSON map[string]interface{}
  23748. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  23749. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23750. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23751. return
  23752. }
  23753. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23754. result, _ := json.Marshal(respJSON)
  23755. fmt.Println("log")
  23756. fmt.Println(string(result))
  23757. if err := json.Unmarshal([]byte(result), &res); err != nil {
  23758. utils.ErrorLog("解析失败:%v", err)
  23759. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23760. return
  23761. }
  23762. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  23763. result3101 := Check3102(c, id, his_patient_id, admin_user_id, "6", order.ID)
  23764. if result3101.Infcode == "0" {
  23765. if len(result3101.Output.Result) > 0 {
  23766. var errMsgs []string
  23767. for _, item := range result3101.Output.Result {
  23768. errMsgs = append(errMsgs, item.VolaCont)
  23769. }
  23770. c.ServeSuccessJSON(map[string]interface{}{
  23771. "failed_code": -10,
  23772. "msg": errMsgs,
  23773. })
  23774. return
  23775. } else {
  23776. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  23777. if his.IdCardType != 4 {
  23778. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  23779. bas := strings.Split(psn_info.CardInfo, "|")
  23780. if his.IdCardType == 1 {
  23781. cert_no = bas[2]
  23782. } else {
  23783. cert_no = bas[1]
  23784. }
  23785. } else {
  23786. cert_no = his.Certno
  23787. }
  23788. //江苏地区国家医保医疗类别
  23789. //职工透析:医疗类别选特殊情况门诊9933
  23790. //居民血透门慢: 医疗类别选门诊慢病1402
  23791. //var med_type string
  23792. //if his.Insutype == "310" {
  23793. // if reg_type == 14 {
  23794. // med_type = "9933"
  23795. // } else if reg_type == 11 {
  23796. // med_type = "11"
  23797. //
  23798. // }
  23799. //} else if his.Insutype == "390" {
  23800. // if reg_type == 14 {
  23801. // med_type = "1402"
  23802. // } else if reg_type == 11 {
  23803. // med_type = "11"
  23804. // }
  23805. //}
  23806. var api string
  23807. if miConfig.MdtrtareaAdmvs == "320921" {
  23808. api = "http://192.168.2.3:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  23809. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  23810. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  23811. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  23812. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  23813. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  23814. "&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
  23815. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  23816. } else {
  23817. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  23818. api = "http://192.168.5.251:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  23819. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  23820. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  23821. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  23822. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  23823. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  23824. "&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
  23825. }
  23826. resp, requestErr := http.Get(api)
  23827. if requestErr != nil {
  23828. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23829. return
  23830. }
  23831. body, ioErr := ioutil.ReadAll(resp.Body)
  23832. if ioErr != nil {
  23833. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  23834. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23835. return
  23836. }
  23837. var respJSON map[string]interface{}
  23838. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  23839. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23840. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23841. return
  23842. }
  23843. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23844. result, _ := json.Marshal(respJSON)
  23845. fmt.Println("log")
  23846. fmt.Println(string(result))
  23847. if strings.Contains(miConfig.MdtrtareaAdmvs, "3209") {
  23848. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  23849. utils.ErrorLog("解析失败:%v", err)
  23850. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23851. return
  23852. }
  23853. res.InfRefmsgid = resSeven10265.InfRefmsgid
  23854. res.Output = resSeven10265.Output
  23855. res.ErrMsg = resSeven10265.ErrMsg
  23856. res.Cainfo = resSeven10265.Cainfo
  23857. res.WarnMsg = resSeven10265.WarnMsg
  23858. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  23859. res.Infcode = infocode
  23860. } else {
  23861. if err := json.Unmarshal([]byte(result), &resSeven10265Two); err != nil {
  23862. utils.ErrorLog("解析失败:%v", err)
  23863. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23864. return
  23865. }
  23866. res.InfRefmsgid = resSeven10265Two.InfRefmsgid
  23867. //AcctMulaidPay, _ := strconv.ParseFloat(resSeven10265Two.Output.Setlinfo.AcctMulaidPay, 64)
  23868. //res.Output.Setlinfo.AcctMulaidPay = AcctMulaidPay
  23869. res.Output.Setlinfo.AcctPay = resSeven10265Two.Output.Setlinfo.AcctPay
  23870. res.Output.Setlinfo.CvlservPay = resSeven10265Two.Output.Setlinfo.CvlservPay
  23871. res.Output.Setlinfo.ActPayDedc = resSeven10265Two.Output.Setlinfo.ActPayDedc
  23872. res.Output.Setlinfo.Age = resSeven10265Two.Output.Setlinfo.Age
  23873. res.Output.Setlinfo.Balc = resSeven10265Two.Output.Setlinfo.Balc
  23874. //res.Output.Setlinfo.Brdy = resSeven10265Two.Output.Setlinfo.Brdy
  23875. res.Output.Setlinfo.Certno = resSeven10265Two.Output.Setlinfo.Certno
  23876. res.Output.Setlinfo.ClrOptins = resSeven10265Two.Output.Setlinfo.ClrOptins
  23877. res.Output.Setlinfo.ClrType = resSeven10265Two.Output.Setlinfo.ClrOptins
  23878. res.Output.Setlinfo.ClrWay = resSeven10265Two.Output.Setlinfo.ClrOptins
  23879. res.Output.Setlinfo.CvlservFlag = resSeven10265Two.Output.Setlinfo.ClrOptins
  23880. res.Output.Setlinfo.CvlservPay = resSeven10265Two.Output.Setlinfo.CvlservPay
  23881. res.Output.Setlinfo.FulamtOwnpayAmt = resSeven10265Two.Output.Setlinfo.FulamtOwnpayAmt
  23882. res.Output.Setlinfo.FundPaySumamt = resSeven10265Two.Output.Setlinfo.FundPaySumamt
  23883. res.Output.Setlinfo.Gend = resSeven10265Two.Output.Setlinfo.Gend
  23884. res.Output.Setlinfo.HifesPay = resSeven10265Two.Output.Setlinfo.HifesPay
  23885. res.Output.Setlinfo.HifmiPay = resSeven10265Two.Output.Setlinfo.HifmiPay
  23886. res.Output.Setlinfo.HifpPay = resSeven10265Two.Output.Setlinfo.HifpPay
  23887. HospPartAmt, _ := strconv.ParseFloat(resSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  23888. res.Output.Setlinfo.HospPartAmt = HospPartAmt
  23889. res.Output.Setlinfo.InscpScpAmt = resSeven10265Two.Output.Setlinfo.InscpScpAmt
  23890. res.Output.Setlinfo.Insutype = resSeven10265Two.Output.Setlinfo.Insutype
  23891. res.Output.Setlinfo.MafPay = resSeven10265Two.Output.Setlinfo.MafPay
  23892. res.Output.Setlinfo.MdtrtCertType = resSeven10265Two.Output.Setlinfo.MdtrtCertType
  23893. res.Output.Setlinfo.HifobPay = resSeven10265Two.Output.Setlinfo.HifobPay
  23894. res.Output.Setlinfo.MdtrtID = resSeven10265Two.Output.Setlinfo.MdtrtID
  23895. res.Output.Setlinfo.MedType = resSeven10265Two.Output.Setlinfo.MedType
  23896. res.Output.Setlinfo.MedfeeSumamt = resSeven10265Two.Output.Setlinfo.MedfeeSumamt
  23897. res.Output.Setlinfo.MedinsSetlID = resSeven10265Two.Output.Setlinfo.MedinsSetlID
  23898. res.Output.Setlinfo.Naty = resSeven10265Two.Output.Setlinfo.Naty
  23899. res.Output.Setlinfo.OthPay = resSeven10265Two.Output.Setlinfo.OthPay
  23900. res.Output.Setlinfo.OverlmtSelfpay = resSeven10265Two.Output.Setlinfo.OverlmtSelfpay
  23901. PoolPropSelfpay, _ := strconv.ParseFloat(resSeven10265Two.Output.Setlinfo.PoolPropSelfpay, 64)
  23902. res.Output.Setlinfo.PoolPropSelfpay = PoolPropSelfpay
  23903. res.Output.Setlinfo.PreselfpayAmt = resSeven10265Two.Output.Setlinfo.PreselfpayAmt
  23904. res.Output.Setlinfo.PsnCashPay = resSeven10265Two.Output.Setlinfo.PsnCashPay
  23905. res.Output.Setlinfo.PsnCertType = resSeven10265Two.Output.Setlinfo.ClrOptins
  23906. res.Output.Setlinfo.PsnName = resSeven10265Two.Output.Setlinfo.PsnName
  23907. res.Output.Setlinfo.PsnNo = resSeven10265Two.Output.Setlinfo.PsnNo
  23908. res.Output.Setlinfo.PsnPartAmt = resSeven10265Two.Output.Setlinfo.PsnPartAmt
  23909. res.Output.Setlinfo.PsnType = resSeven10265Two.Output.Setlinfo.PsnType
  23910. res.Output.Setlinfo.SetlID = resSeven10265Two.Output.Setlinfo.SetlID
  23911. res.Output.Setlinfo.SetlTime = resSeven10265Two.Output.Setlinfo.SetlTime
  23912. //res.Output.Setldetail = resSeven10265Two.Output.Setldetail
  23913. res.ErrMsg = resSeven10265Two.ErrMsg
  23914. res.Cainfo = resSeven10265Two.Cainfo
  23915. res.WarnMsg = resSeven10265Two.WarnMsg
  23916. infocode, _ := strconv.ParseInt(resSeven10265Two.Infcode, 10, 64)
  23917. res.Infcode = infocode
  23918. }
  23919. }
  23920. }
  23921. } else if miConfig.MdtrtareaAdmvs == "150499" {
  23922. psn_info, _ := service.GetPsnByPatientId(id)
  23923. var verify_number string
  23924. if psn_info.IdCardType == 4 {
  23925. verify_number = psn_info.VerifyNumber
  23926. } else if psn_info.IdCardType == 1 {
  23927. bas := strings.Split(psn_info.CardInfo, "|")
  23928. cardNumber := bas[2]
  23929. verify_number = cardNumber
  23930. } else {
  23931. psn_info.IdCardType = 2
  23932. verify_number = psn_info.Certno
  23933. }
  23934. var api string
  23935. api = "http://172.16.13.254:9532/" + "nmyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  23936. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  23937. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  23938. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  23939. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(psn_info.IdCardType, 10) +
  23940. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  23941. "&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
  23942. resp, requestErr := http.Get(api)
  23943. if requestErr != nil {
  23944. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23945. return
  23946. }
  23947. body, ioErr := ioutil.ReadAll(resp.Body)
  23948. if ioErr != nil {
  23949. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  23950. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23951. return
  23952. }
  23953. var respJSON map[string]interface{}
  23954. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  23955. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23956. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23957. return
  23958. }
  23959. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23960. result, _ := json.Marshal(respJSON)
  23961. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  23962. utils.ErrorLog("解析失败:%v", err)
  23963. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23964. return
  23965. }
  23966. res.InfRefmsgid = resSeven10265.InfRefmsgid
  23967. res.Output.Setlinfo.AcctMulaidPay = resSeven10265.Output.Setlinfo.AcctMulaidPay
  23968. res.Output.Setlinfo.AcctPay = resSeven10265.Output.Setlinfo.AcctPay
  23969. res.Output.Setlinfo.CvlservPay = resSeven10265.Output.Setlinfo.CvlservPay
  23970. res.Output.Setlinfo.ActPayDedc = resSeven10265.Output.Setlinfo.ActPayDedc
  23971. res.Output.Setlinfo.Age = resSeven10265.Output.Setlinfo.Age
  23972. res.Output.Setlinfo.Balc = resSeven10265.Output.Setlinfo.Balc
  23973. //res.Output.Setlinfo.Brdy = resSeven10265.Output.Setlinfo.Brdy
  23974. res.Output.Setlinfo.Certno = resSeven10265.Output.Setlinfo.Certno
  23975. res.Output.Setlinfo.ClrOptins = resSeven10265.Output.Setlinfo.ClrOptins
  23976. res.Output.Setlinfo.ClrType = resSeven10265.Output.Setlinfo.ClrOptins
  23977. res.Output.Setlinfo.ClrWay = resSeven10265.Output.Setlinfo.ClrOptins
  23978. res.Output.Setlinfo.CvlservFlag = resSeven10265.Output.Setlinfo.ClrOptins
  23979. res.Output.Setlinfo.CvlservPay = resSeven10265.Output.Setlinfo.CvlservPay
  23980. res.Output.Setlinfo.FulamtOwnpayAmt = resSeven10265.Output.Setlinfo.FulamtOwnpayAmt
  23981. res.Output.Setlinfo.FundPaySumamt = resSeven10265.Output.Setlinfo.FundPaySumamt
  23982. res.Output.Setlinfo.Gend = resSeven10265.Output.Setlinfo.Gend
  23983. res.Output.Setlinfo.HifesPay = resSeven10265.Output.Setlinfo.HifesPay
  23984. res.Output.Setlinfo.HifmiPay = resSeven10265.Output.Setlinfo.HifmiPay
  23985. res.Output.Setlinfo.HifpPay = resSeven10265.Output.Setlinfo.HifpPay
  23986. //HospPartAmt, _ := strconv.ParseFloat(resSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  23987. res.Output.Setlinfo.HospPartAmt = resSeven10265.Output.Setlinfo.HospPartAmt
  23988. res.Output.Setlinfo.InscpScpAmt = resSeven10265.Output.Setlinfo.InscpScpAmt
  23989. res.Output.Setlinfo.Insutype = resSeven10265.Output.Setlinfo.Insutype
  23990. res.Output.Setlinfo.MafPay = resSeven10265.Output.Setlinfo.MafPay
  23991. res.Output.Setlinfo.MdtrtCertType = resSeven10265.Output.Setlinfo.MdtrtCertType
  23992. res.Output.Setlinfo.HifobPay = resSeven10265.Output.Setlinfo.HifobPay
  23993. res.Output.Setlinfo.MdtrtID = resSeven10265.Output.Setlinfo.MdtrtID
  23994. res.Output.Setlinfo.MedType = resSeven10265.Output.Setlinfo.MedType
  23995. res.Output.Setlinfo.MedfeeSumamt = resSeven10265.Output.Setlinfo.MedfeeSumamt
  23996. res.Output.Setlinfo.MedinsSetlID = resSeven10265.Output.Setlinfo.MedinsSetlID
  23997. res.Output.Setlinfo.Naty = resSeven10265.Output.Setlinfo.Naty
  23998. res.Output.Setlinfo.OthPay = resSeven10265.Output.Setlinfo.OthPay
  23999. res.Output.Setlinfo.OverlmtSelfpay = resSeven10265.Output.Setlinfo.OverlmtSelfpay
  24000. //PoolPropSelfpay, _ := strconv.ParseFloat(resSeven10265Two.Output.Setlinfo.PoolPropSelfpay, 64)
  24001. res.Output.Setlinfo.PoolPropSelfpay = resSeven10265.Output.Setlinfo.PoolPropSelfpay
  24002. res.Output.Setlinfo.PreselfpayAmt = resSeven10265.Output.Setlinfo.PreselfpayAmt
  24003. res.Output.Setlinfo.PsnCashPay = resSeven10265.Output.Setlinfo.PsnCashPay
  24004. res.Output.Setlinfo.PsnCertType = resSeven10265.Output.Setlinfo.ClrOptins
  24005. res.Output.Setlinfo.PsnName = resSeven10265.Output.Setlinfo.PsnName
  24006. res.Output.Setlinfo.PsnNo = resSeven10265.Output.Setlinfo.PsnNo
  24007. res.Output.Setlinfo.PsnPartAmt = resSeven10265.Output.Setlinfo.PsnPartAmt
  24008. res.Output.Setlinfo.PsnType = resSeven10265.Output.Setlinfo.PsnType
  24009. res.Output.Setlinfo.SetlID = resSeven10265.Output.Setlinfo.SetlID
  24010. res.Output.Setlinfo.SetlTime = resSeven10265.Output.Setlinfo.SetlTime
  24011. //res.Output.Setldetail = resSeven10265.Output.Setldetail
  24012. res.ErrMsg = resSeven10265.ErrMsg
  24013. res.Cainfo = resSeven10265.Cainfo
  24014. res.WarnMsg = resSeven10265.WarnMsg
  24015. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  24016. res.Infcode = infocode
  24017. } else if miConfig.MdtrtareaAdmvs == "350500" {
  24018. acct_used_flag := "1"
  24019. psn_info, _ := service.GetPsnByPatientIdTwo(his.PatientId)
  24020. var result string
  24021. var request_log string
  24022. if his.IdCardType == 4 && len(psn_info.VerifyNumber) > 0 {
  24023. 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)
  24024. } else {
  24025. 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)
  24026. }
  24027. var dat map[string]interface{}
  24028. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  24029. fmt.Println(dat)
  24030. } else {
  24031. fmt.Println(err)
  24032. }
  24033. saveLog(result, request_log, "2206", "预结算")
  24034. userJSONBytes, _ := json.Marshal(dat)
  24035. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  24036. utils.ErrorLog("解析失败:%v", err)
  24037. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24038. return
  24039. }
  24040. } else if miConfig.MdtrtareaAdmvs == "360302" {
  24041. var result string
  24042. var request_log string
  24043. if his.IdCardType == 2 {
  24044. 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, "")
  24045. } else if his.IdCardType == 1 {
  24046. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  24047. bas := strings.Split(psn_info.CardInfo, "|")
  24048. basNumber := bas[2]
  24049. card_sn := bas[3]
  24050. var rf []*ResultFive
  24051. json.Unmarshal([]byte(his.Iinfo), &rf)
  24052. var psn_type string
  24053. for _, item := range rf {
  24054. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  24055. psn_type = item.PsnType
  24056. }
  24057. }
  24058. 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)
  24059. } else {
  24060. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  24061. 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, "")
  24062. }
  24063. var dat map[string]interface{}
  24064. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  24065. fmt.Println(dat)
  24066. } else {
  24067. fmt.Println(err)
  24068. }
  24069. saveLog(result, request_log, "2206", "预结算")
  24070. userJSONBytes, _ := json.Marshal(dat)
  24071. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  24072. utils.ErrorLog("解析失败:%v", err)
  24073. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24074. return
  24075. }
  24076. } else if miConfig.MdtrtareaAdmvs == "341203" {
  24077. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  24078. if his.IdCardType == 4 {
  24079. psn_info.VerifyNumber = psn_info.VerifyNumber
  24080. cert_no = psn_info.Certno
  24081. } else if his.IdCardType == 2 {
  24082. cert_no = psn_info.Certno
  24083. psn_info.VerifyNumber = psn_info.Certno
  24084. } else {
  24085. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  24086. bas := strings.Split(psn_info.CardInfo, "|")
  24087. if his.IdCardType == 1 {
  24088. cert_no = bas[2]
  24089. } else {
  24090. cert_no = bas[1]
  24091. }
  24092. }
  24093. var api string
  24094. var med_type string
  24095. if his.Insutype == "390" {
  24096. if reg_type == 992102 {
  24097. med_type = "992102"
  24098. }
  24099. if reg_type == 140104 {
  24100. med_type = "140104"
  24101. }
  24102. if reg_type == 14 {
  24103. med_type = "140104"
  24104. }
  24105. } else if his.Insutype == "310" {
  24106. if reg_type == 992102 {
  24107. med_type = "992102"
  24108. }
  24109. if reg_type == 14 {
  24110. med_type = "14"
  24111. }
  24112. }
  24113. api = miConfig.SecretKey + "ahyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  24114. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  24115. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  24116. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  24117. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  24118. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  24119. "&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
  24120. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  24121. resp, requestErr := http.Get(api)
  24122. if requestErr != nil {
  24123. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24124. return
  24125. }
  24126. body, ioErr := ioutil.ReadAll(resp.Body)
  24127. if ioErr != nil {
  24128. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  24129. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24130. return
  24131. }
  24132. var respJSON map[string]interface{}
  24133. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  24134. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24135. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24136. return
  24137. }
  24138. status := respJSON["data"].(map[string]interface{})["status"].(string)
  24139. if status == "0" {
  24140. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  24141. c.ServeSuccessJSON(map[string]interface{}{
  24142. "failed_code": -10,
  24143. "msg": err_msg,
  24144. })
  24145. return
  24146. }
  24147. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24148. result, _ := json.Marshal(respJSON)
  24149. fmt.Println("log")
  24150. fmt.Println(string(result))
  24151. if err := json.Unmarshal([]byte(result), &ahres); err != nil {
  24152. utils.ErrorLog("解析失败:%v", err)
  24153. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24154. return
  24155. }
  24156. res.InfRefmsgid = ahres.InfRefmsgid
  24157. timestamp := int64(ahres.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  24158. // 创建对应的Time类型
  24159. t := time.UnixMilli(timestamp)
  24160. // 格式化成指定的日期字符串
  24161. str := t.Format("2006-01-02 15:04:05")
  24162. res.Output.Setlinfo.SetlTime = str
  24163. res.Output.Setlinfo.AcctMulaidPay = ahres.Output.Setlinfo.AcctMulaidPay
  24164. res.Output.Setlinfo.AcctPay = ahres.Output.Setlinfo.AcctPay
  24165. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  24166. res.Output.Setlinfo.ActPayDedc = ahres.Output.Setlinfo.ActPayDedc
  24167. res.Output.Setlinfo.Age = ahres.Output.Setlinfo.Age
  24168. res.Output.Setlinfo.Balc = ahres.Output.Setlinfo.Balc
  24169. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  24170. res.Output.Setlinfo.Certno = ahres.Output.Setlinfo.Certno
  24171. res.Output.Setlinfo.ClrOptins = ahres.Output.Setlinfo.ClrOptins
  24172. res.Output.Setlinfo.ClrType = ahres.Output.Setlinfo.ClrOptins
  24173. res.Output.Setlinfo.ClrWay = ahres.Output.Setlinfo.ClrOptins
  24174. res.Output.Setlinfo.CvlservFlag = ahres.Output.Setlinfo.ClrOptins
  24175. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  24176. res.Output.Setlinfo.FulamtOwnpayAmt = ahres.Output.Setlinfo.FulamtOwnpayAmt
  24177. res.Output.Setlinfo.FundPaySumamt = ahres.Output.Setlinfo.FundPaySumamt
  24178. res.Output.Setlinfo.Gend = ahres.Output.Setlinfo.Gend
  24179. res.Output.Setlinfo.HifesPay = ahres.Output.Setlinfo.HifesPay
  24180. res.Output.Setlinfo.HifmiPay = ahres.Output.Setlinfo.HifmiPay
  24181. res.Output.Setlinfo.HifpPay = ahres.Output.Setlinfo.HifpPay
  24182. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  24183. res.Output.Setlinfo.HospPartAmt = ahres.Output.Setlinfo.HospPartAmt
  24184. res.Output.Setlinfo.InscpScpAmt = ahres.Output.Setlinfo.InscpScpAmt
  24185. res.Output.Setlinfo.Insutype = ahres.Output.Setlinfo.Insutype
  24186. res.Output.Setlinfo.MafPay = ahres.Output.Setlinfo.MafPay
  24187. res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  24188. res.Output.Setlinfo.HifobPay = ahres.Output.Setlinfo.HifobPay
  24189. res.Output.Setlinfo.MdtrtID = ahres.Output.Setlinfo.MdtrtID
  24190. res.Output.Setlinfo.MedType = ahres.Output.Setlinfo.MedType
  24191. res.Output.Setlinfo.MedfeeSumamt = ahres.Output.Setlinfo.MedfeeSumamt
  24192. res.Output.Setlinfo.MedinsSetlID = ahres.Output.Setlinfo.MedinsSetlID
  24193. res.Output.Setlinfo.Naty = ahres.Output.Setlinfo.Naty
  24194. res.Output.Setlinfo.OthPay = ahres.Output.Setlinfo.OthPay
  24195. res.Output.Setlinfo.OverlmtSelfpay = ahres.Output.Setlinfo.OverlmtSelfpay
  24196. res.Output.Setlinfo.PoolPropSelfpay = ahres.Output.Setlinfo.PoolPropSelfpay
  24197. res.Output.Setlinfo.PreselfpayAmt = ahres.Output.Setlinfo.PreselfpayAmt
  24198. res.Output.Setlinfo.PsnCashPay = ahres.Output.Setlinfo.PsnCashPay
  24199. res.Output.Setlinfo.PsnCertType = ahres.Output.Setlinfo.ClrOptins
  24200. res.Output.Setlinfo.PsnName = ahres.Output.Setlinfo.PsnName
  24201. res.Output.Setlinfo.PsnNo = ahres.Output.Setlinfo.PsnNo
  24202. res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  24203. res.Output.Setlinfo.PsnType = ahres.Output.Setlinfo.PsnType
  24204. res.Output.Setlinfo.SetlID = ahres.Output.Setlinfo.SetlID
  24205. //res.Output.Setldetail = ahres.Output.Setldetail
  24206. res.ErrMsg = ahres.ErrMsg
  24207. res.Cainfo = ahres.Cainfo
  24208. res.WarnMsg = ahres.WarnMsg
  24209. res.Infcode = ahres.Infcode
  24210. } else if miConfig.MdtrtareaAdmvs == "430800" {
  24211. var result string
  24212. var request_log string
  24213. if his.IdCardType == 2 {
  24214. 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")
  24215. } else if his.IdCardType == 1 {
  24216. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  24217. bas := strings.Split(psn_info.CardInfo, "|")
  24218. basNumber := bas[2]
  24219. card_sn := bas[3]
  24220. 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")
  24221. } else {
  24222. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  24223. 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")
  24224. }
  24225. var dat map[string]interface{}
  24226. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  24227. fmt.Println(dat)
  24228. } else {
  24229. fmt.Println(err)
  24230. }
  24231. saveLog(result, request_log, "2206", "预结算")
  24232. userJSONBytes, _ := json.Marshal(dat)
  24233. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  24234. utils.ErrorLog("解析失败:%v", err)
  24235. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24236. return
  24237. }
  24238. } else if miConfig.MdtrtareaAdmvs == "441799" {
  24239. api := miConfig.Url + "gdyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  24240. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  24241. "&operator=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  24242. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  24243. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  24244. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  24245. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  24246. resp, requestErr := http.Get(api)
  24247. if requestErr != nil {
  24248. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24249. return
  24250. }
  24251. body, ioErr := ioutil.ReadAll(resp.Body)
  24252. if ioErr != nil {
  24253. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  24254. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24255. return
  24256. }
  24257. var respJSON map[string]interface{}
  24258. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  24259. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24260. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24261. return
  24262. }
  24263. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24264. result, _ := json.Marshal(respJSON)
  24265. fmt.Println("log")
  24266. fmt.Println(string(result))
  24267. if err := json.Unmarshal([]byte(result), &res); err != nil {
  24268. utils.ErrorLog("解析失败:%v", err)
  24269. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24270. return
  24271. }
  24272. } else {
  24273. if miConfig.MdtrtareaAdmvs == "441202" {
  24274. result3101 := Checkgd3102(c, id, his_patient_id, admin_user_id, "6", order.ID)
  24275. if result3101.Infcode == 0 {
  24276. if len(result3101.Output.Result) > 0 {
  24277. var errMsgs []string
  24278. for _, item := range result3101.Output.Result {
  24279. errMsgs = append(errMsgs, item.VolaCont)
  24280. }
  24281. c.ServeSuccessJSON(map[string]interface{}{
  24282. "failed_code": -10,
  24283. "msg": errMsgs,
  24284. })
  24285. return
  24286. } else {
  24287. var result string
  24288. var request_log string
  24289. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  24290. allTotal = fmt.Sprintf("%.2f", total_two)
  24291. if his.IdCardType == 4 {
  24292. 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)
  24293. } else {
  24294. 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)
  24295. }
  24296. var dat map[string]interface{}
  24297. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  24298. fmt.Println(dat)
  24299. } else {
  24300. fmt.Println(err)
  24301. }
  24302. saveLog(result, request_log, "2206", "预结算")
  24303. //userJSONBytes, _ := json.Marshal(dat)
  24304. //
  24305. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  24306. // utils.ErrorLog("解析失败:%v", err)
  24307. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24308. // return
  24309. //}
  24310. userJSONBytes, _ := json.Marshal(dat)
  24311. if miConfig.Code == "H15049901371" {
  24312. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  24313. utils.ErrorLog("解析失败:%v", err)
  24314. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24315. return
  24316. }
  24317. res.InfRefmsgid = resSeven10265.InfRefmsgid
  24318. res.Output = resSeven10265.Output
  24319. res.ErrMsg = resSeven10265.ErrMsg
  24320. res.Cainfo = resSeven10265.Cainfo
  24321. res.WarnMsg = resSeven10265.WarnMsg
  24322. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  24323. res.Infcode = infocode
  24324. } else {
  24325. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  24326. utils.ErrorLog("解析失败:%v", err)
  24327. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24328. return
  24329. }
  24330. }
  24331. }
  24332. } else {
  24333. c.ServeSuccessJSON(map[string]interface{}{
  24334. "failed_code": -10,
  24335. "msg": result3101.ErrMsg,
  24336. })
  24337. return
  24338. }
  24339. } else {
  24340. var result string
  24341. var request_log string
  24342. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  24343. allTotal = fmt.Sprintf("%.2f", total_two)
  24344. if his.IdCardType == 4 {
  24345. 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)
  24346. } else {
  24347. 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)
  24348. }
  24349. var dat map[string]interface{}
  24350. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  24351. fmt.Println(dat)
  24352. } else {
  24353. fmt.Println(err)
  24354. }
  24355. saveLog(result, request_log, "2206", "预结算")
  24356. //userJSONBytes, _ := json.Marshal(dat)
  24357. //
  24358. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  24359. // utils.ErrorLog("解析失败:%v", err)
  24360. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24361. // return
  24362. //}
  24363. userJSONBytes, _ := json.Marshal(dat)
  24364. if miConfig.Code == "H15049901371" {
  24365. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  24366. utils.ErrorLog("解析失败:%v", err)
  24367. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24368. return
  24369. }
  24370. res.InfRefmsgid = resSeven10265.InfRefmsgid
  24371. res.Output = resSeven10265.Output
  24372. res.ErrMsg = resSeven10265.ErrMsg
  24373. res.Cainfo = resSeven10265.Cainfo
  24374. res.WarnMsg = resSeven10265.WarnMsg
  24375. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  24376. res.Infcode = infocode
  24377. } else {
  24378. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  24379. if err := json.Unmarshal(userJSONBytes, &gzresSeven10265Two); err != nil {
  24380. utils.ErrorLog("解析失败:%v", err)
  24381. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24382. return
  24383. }
  24384. res.InfRefmsgid = gzresSeven10265Two.InfRefmsgid
  24385. res.Output.Setlinfo.AcctMulaidPay = gzresSeven10265Two.Output.Setlinfo.AcctMulaidPay
  24386. res.Output.Setlinfo.AcctPay = gzresSeven10265Two.Output.Setlinfo.AcctPay
  24387. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  24388. res.Output.Setlinfo.ActPayDedc = gzresSeven10265Two.Output.Setlinfo.ActPayDedc
  24389. res.Output.Setlinfo.Age = gzresSeven10265Two.Output.Setlinfo.Age
  24390. res.Output.Setlinfo.Balc = gzresSeven10265Two.Output.Setlinfo.Balc
  24391. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  24392. res.Output.Setlinfo.Certno = gzresSeven10265Two.Output.Setlinfo.Certno
  24393. res.Output.Setlinfo.ClrOptins = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  24394. res.Output.Setlinfo.ClrType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  24395. res.Output.Setlinfo.ClrWay = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  24396. res.Output.Setlinfo.CvlservFlag = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  24397. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  24398. res.Output.Setlinfo.FulamtOwnpayAmt = gzresSeven10265Two.Output.Setlinfo.FulamtOwnpayAmt
  24399. res.Output.Setlinfo.FundPaySumamt = gzresSeven10265Two.Output.Setlinfo.FundPaySumamt
  24400. res.Output.Setlinfo.Gend = gzresSeven10265Two.Output.Setlinfo.Gend
  24401. res.Output.Setlinfo.HifesPay = gzresSeven10265Two.Output.Setlinfo.HifesPay
  24402. res.Output.Setlinfo.HifmiPay = gzresSeven10265Two.Output.Setlinfo.HifmiPay
  24403. res.Output.Setlinfo.HifpPay = gzresSeven10265Two.Output.Setlinfo.HifpPay
  24404. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  24405. res.Output.Setlinfo.HospPartAmt = gzresSeven10265Two.Output.Setlinfo.HospPartAmt
  24406. res.Output.Setlinfo.InscpScpAmt = gzresSeven10265Two.Output.Setlinfo.InscpScpAmt
  24407. res.Output.Setlinfo.Insutype = gzresSeven10265Two.Output.Setlinfo.Insutype
  24408. res.Output.Setlinfo.MafPay = gzresSeven10265Two.Output.Setlinfo.MafPay
  24409. res.Output.Setlinfo.MdtrtCertType = gzresSeven10265Two.Output.Setlinfo.MdtrtCertType
  24410. res.Output.Setlinfo.HifobPay = gzresSeven10265Two.Output.Setlinfo.HifobPay
  24411. res.Output.Setlinfo.MdtrtID = gzresSeven10265Two.Output.Setlinfo.MdtrtID
  24412. res.Output.Setlinfo.MedType = gzresSeven10265Two.Output.Setlinfo.MedType
  24413. res.Output.Setlinfo.MedfeeSumamt = gzresSeven10265Two.Output.Setlinfo.MedfeeSumamt
  24414. res.Output.Setlinfo.MedinsSetlID = gzresSeven10265Two.Output.Setlinfo.MedinsSetlID
  24415. res.Output.Setlinfo.Naty = gzresSeven10265Two.Output.Setlinfo.Naty
  24416. res.Output.Setlinfo.OthPay = gzresSeven10265Two.Output.Setlinfo.OthPay
  24417. res.Output.Setlinfo.OverlmtSelfpay = gzresSeven10265Two.Output.Setlinfo.OverlmtSelfpay
  24418. PoolPropSelfpay, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.PoolPropSelfpay, 64)
  24419. res.Output.Setlinfo.PoolPropSelfpay = PoolPropSelfpay
  24420. res.Output.Setlinfo.PreselfpayAmt = gzresSeven10265Two.Output.Setlinfo.PreselfpayAmt
  24421. res.Output.Setlinfo.PsnCashPay = gzresSeven10265Two.Output.Setlinfo.PsnCashPay
  24422. res.Output.Setlinfo.PsnCertType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  24423. res.Output.Setlinfo.PsnName = gzresSeven10265Two.Output.Setlinfo.PsnName
  24424. res.Output.Setlinfo.PsnNo = gzresSeven10265Two.Output.Setlinfo.PsnNo
  24425. res.Output.Setlinfo.PsnPartAmt = gzresSeven10265Two.Output.Setlinfo.PsnPartAmt
  24426. res.Output.Setlinfo.PsnType = gzresSeven10265Two.Output.Setlinfo.PsnType
  24427. res.Output.Setlinfo.SetlID = gzresSeven10265Two.Output.Setlinfo.SetlID
  24428. res.Output.Setlinfo.SetlTime = gzresSeven10265Two.Output.Setlinfo.SetlTime
  24429. //res.Output.Setldetail = gzresSeven10265Two.Output.Setldetail
  24430. res.ErrMsg = gzresSeven10265Two.ErrMsg
  24431. res.Cainfo = gzresSeven10265Two.Cainfo
  24432. res.WarnMsg = gzresSeven10265Two.WarnMsg
  24433. //infocode, _ := strconv.ParseInt(resSeven10265Two.Infcode, 10, 64)
  24434. //res.Infcode = infocode
  24435. } else {
  24436. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  24437. utils.ErrorLog("解析失败:%v", err)
  24438. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24439. return
  24440. }
  24441. }
  24442. }
  24443. }
  24444. }
  24445. utils.ErrorLog("解析失败:%v", res.Infcode)
  24446. if res.Infcode == -1 {
  24447. errlog := &models.HisOrderError{
  24448. UserOrgId: adminUser.CurrentOrgId,
  24449. Ctime: time.Now().Unix(),
  24450. Mtime: time.Now().Unix(),
  24451. Number: chrg_bchno,
  24452. ErrMsg: res.ErrMsg,
  24453. Status: 1,
  24454. PatientId: id,
  24455. RecordTime: recordDateTime,
  24456. Stage: 20,
  24457. }
  24458. service.CreateErrMsgLog(errlog)
  24459. c.ServeSuccessJSON(map[string]interface{}{
  24460. "failed_code": -10,
  24461. "msg": res.ErrMsg,
  24462. })
  24463. return
  24464. }
  24465. if res.Infcode != 0 {
  24466. errlog := &models.HisOrderError{
  24467. UserOrgId: adminUser.CurrentOrgId,
  24468. Ctime: time.Now().Unix(),
  24469. Mtime: time.Now().Unix(),
  24470. Number: chrg_bchno,
  24471. ErrMsg: res.ErrMsg,
  24472. Status: 1,
  24473. PatientId: id,
  24474. RecordTime: recordDateTime,
  24475. Stage: 20,
  24476. }
  24477. service.CreateErrMsgLog(errlog)
  24478. c.ServeSuccessJSON(map[string]interface{}{
  24479. "failed_code": -10,
  24480. "msg": res.ErrMsg,
  24481. })
  24482. return
  24483. } else {
  24484. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  24485. order.OrderStatus = 1
  24486. order.IsPre = 1
  24487. order.Status = 1
  24488. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  24489. order.SetlId = res.Output.Setlinfo.SetlID
  24490. order.PsnNo = res.Output.Setlinfo.PsnNo
  24491. order.PsnName = res.Output.Setlinfo.PsnName
  24492. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  24493. order.Certno = res.Output.Setlinfo.Certno
  24494. order.Gend = res.Output.Setlinfo.Gend
  24495. order.Naty = res.Output.Setlinfo.Naty
  24496. order.Age = res.Output.Setlinfo.Age
  24497. order.Insutype = res.Output.Setlinfo.Insutype
  24498. order.PsnType = res.Output.Setlinfo.PsnType
  24499. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  24500. order.SetlTime = res.Output.Setlinfo.SetlTime
  24501. order.AcctUsedFlag = acct_used_flag
  24502. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  24503. if res.Output.Setlinfo.MedType == "140101" {
  24504. order.MedType = "14"
  24505. } else {
  24506. if res.Output.Setlinfo.MedType == "110104" {
  24507. order.MedType = "11"
  24508. } else {
  24509. order.MedType = res.Output.Setlinfo.MedType
  24510. }
  24511. }
  24512. if res.Output.Setlinfo.MedType == "992102" {
  24513. order.MedType = "992102"
  24514. }
  24515. if res.Output.Setlinfo.MedType == "140104" {
  24516. order.MedType = "140104"
  24517. }
  24518. if res.Output.Setlinfo.MedType == "14" {
  24519. order.MedType = "14"
  24520. }
  24521. if reg_type == 1112 {
  24522. order.MedType = "1112"
  24523. }
  24524. if reg_type == 1111 {
  24525. order.MedType = "1111"
  24526. }
  24527. order.ClrType = res.Output.Setlinfo.ClrType
  24528. if adminUser.CurrentOrgId == 10480 {
  24529. if strings.Contains(his.InsuplcAdmdvs, "3412") {
  24530. order.ClrType = "11"
  24531. } else {
  24532. order.ClrType = "9903"
  24533. }
  24534. }
  24535. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  24536. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  24537. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  24538. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  24539. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  24540. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  24541. order.HifpPay = res.Output.Setlinfo.HifpPay
  24542. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  24543. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  24544. order.HifesPay = res.Output.Setlinfo.HifesPay
  24545. order.HifobPay = res.Output.Setlinfo.HifobPay
  24546. order.MafPay = res.Output.Setlinfo.MafPay
  24547. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  24548. order.OthPay = res.Output.Setlinfo.OthPay
  24549. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  24550. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  24551. order.AcctPay = res.Output.Setlinfo.AcctPay
  24552. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  24553. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  24554. order.Balc = res.Output.Setlinfo.Balc
  24555. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  24556. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  24557. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  24558. order.ClrWay = res.Output.Setlinfo.ClrWay
  24559. order.Creator = order.Creator
  24560. order.Modify = roles.AdminUserId
  24561. //setlDetail, _ := json.Marshal(res.Output.Setldetail)
  24562. //detailStr := string(setlDetail)
  24563. //order.SetlDetail = detailStr
  24564. //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  24565. err = service.UpDateOrder(order)
  24566. if err == nil {
  24567. c.ServeSuccessJSON(map[string]interface{}{
  24568. "msg": "预结算成功",
  24569. })
  24570. } else {
  24571. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  24572. return
  24573. }
  24574. }
  24575. } else {
  24576. adminUser := c.GetAdminUserInfo()
  24577. errlog := &models.HisOrderError{
  24578. UserOrgId: adminUser.CurrentOrgId,
  24579. Ctime: time.Now().Unix(),
  24580. Mtime: time.Now().Unix(),
  24581. ErrMsg: res.ErrMsg,
  24582. Status: 1,
  24583. PatientId: id,
  24584. RecordTime: recordDateTime,
  24585. Stage: 4,
  24586. }
  24587. service.CreateErrMsgLog(errlog)
  24588. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  24589. return
  24590. }
  24591. } else {
  24592. if miConfig.MdtrtareaAdmvs == "150499" {
  24593. order := &models.HisOrder{
  24594. UserOrgId: adminUser.CurrentOrgId,
  24595. HisPatientId: his.ID,
  24596. PatientId: his.PatientId,
  24597. SettleAccountsDate: recordDateTime,
  24598. Ctime: time.Now().Unix(),
  24599. Mtime: time.Now().Unix(),
  24600. MdtrtId: his.Number,
  24601. PsnNo: his.PsnNo,
  24602. MedType: strconv.FormatInt(reg_type, 10),
  24603. Status: 1,
  24604. Number: chrg_bchno,
  24605. Infcode: res.Infcode,
  24606. WarnMsg: res.WarnMsg,
  24607. Cainfo: res.Cainfo,
  24608. ErrMsg: res.ErrMsg,
  24609. RespondTime: res.RefmsgTime,
  24610. InfRefmsgid: res.InfRefmsgid,
  24611. OrderStatus: 1,
  24612. IsMedicineInsurance: 1,
  24613. SettleType: settle_accounts_type,
  24614. SettleStartTime: start_time,
  24615. SettleEndTime: end_time,
  24616. Creator: roles.AdminUserId,
  24617. Modify: roles.AdminUserId,
  24618. PType: 2,
  24619. Diagnosis: diagnosis_id,
  24620. }
  24621. err = service.CreateOrder(order)
  24622. if err != nil {
  24623. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  24624. return
  24625. }
  24626. }
  24627. adminUser := c.GetAdminUserInfo()
  24628. errlog := &models.HisOrderError{
  24629. UserOrgId: adminUser.CurrentOrgId,
  24630. Ctime: time.Now().Unix(),
  24631. Mtime: time.Now().Unix(),
  24632. ErrMsg: res.ErrMsg,
  24633. Status: 1,
  24634. PatientId: id,
  24635. RecordTime: recordDateTime,
  24636. Stage: 4,
  24637. }
  24638. service.CreateErrMsgLog(errlog)
  24639. c.ServeSuccessJSON(map[string]interface{}{
  24640. "failed_code": -10,
  24641. "msg": res.ErrMsg,
  24642. })
  24643. return
  24644. }
  24645. }
  24646. }
  24647. }
  24648. // 退款
  24649. func (c *HisApiController) Refund() {
  24650. order_id, _ := c.GetInt64("order_id")
  24651. admin_user_id, _ := c.GetInt64("admin_user_id")
  24652. adminUser := c.GetAdminUserInfo()
  24653. var order models.HisOrder
  24654. order, _ = service.GetHisOrderByID(order_id)
  24655. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  24656. if order.ID == 0 {
  24657. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  24658. return
  24659. }
  24660. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  24661. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  24662. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  24663. if config.IsOpen == 1 { //对接了医保,走医保流程
  24664. var res ResultSixteen
  24665. var ahres ResultSevenAH
  24666. var resSixteen10265 ResultSixteen10265
  24667. var resSixteen10265Two ResultSixteen10265Two
  24668. var gz ResultgzSixteen10265Two
  24669. var src_resquest string
  24670. var result string
  24671. if miConfig.MdtrtareaAdmvs == "421300" {
  24672. api3 := "http://192.168.124.4:9532/" + "hbyb/2208?psn_no=" + order.PsnNo +
  24673. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  24674. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  24675. resp3, requestErr3 := http.Get(api3)
  24676. if requestErr3 != nil {
  24677. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24678. return
  24679. }
  24680. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  24681. if ioErr3 != nil {
  24682. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  24683. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24684. return
  24685. }
  24686. var respJSON3 map[string]interface{}
  24687. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  24688. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24689. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24690. return
  24691. }
  24692. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24693. userJSONBytes3, _ := json.Marshal(respJSON3)
  24694. fmt.Println("log")
  24695. fmt.Println(string(userJSONBytes3))
  24696. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  24697. utils.ErrorLog("解析失败:%v", err)
  24698. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24699. return
  24700. }
  24701. } else if miConfig.MdtrtareaAdmvs == "420200" {
  24702. api3 := "http://192.168.0.197:9532/" + "hbyb/2208?psn_no=" + order.PsnNo +
  24703. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  24704. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  24705. resp3, requestErr3 := http.Get(api3)
  24706. if requestErr3 != nil {
  24707. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24708. return
  24709. }
  24710. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  24711. if ioErr3 != nil {
  24712. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  24713. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24714. return
  24715. }
  24716. var respJSON3 map[string]interface{}
  24717. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  24718. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24719. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24720. return
  24721. }
  24722. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24723. userJSONBytes3, _ := json.Marshal(respJSON3)
  24724. fmt.Println("log")
  24725. fmt.Println(string(userJSONBytes3))
  24726. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  24727. utils.ErrorLog("解析失败:%v", err)
  24728. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24729. return
  24730. }
  24731. } else if miConfig.MdtrtareaAdmvs == "420902" {
  24732. api3 := miConfig.Url + "hbyb/2208?psn_no=" + order.PsnNo +
  24733. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  24734. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  24735. resp3, requestErr3 := http.Get(api3)
  24736. if requestErr3 != nil {
  24737. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24738. return
  24739. }
  24740. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  24741. if ioErr3 != nil {
  24742. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  24743. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24744. return
  24745. }
  24746. var respJSON3 map[string]interface{}
  24747. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  24748. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24749. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24750. return
  24751. }
  24752. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24753. userJSONBytes3, _ := json.Marshal(respJSON3)
  24754. fmt.Println("log")
  24755. fmt.Println(string(userJSONBytes3))
  24756. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  24757. utils.ErrorLog("解析失败:%v", err)
  24758. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24759. return
  24760. }
  24761. } else if miConfig.MdtrtareaAdmvs == "421182" {
  24762. api3 := miConfig.Url + "hbyb/2208?psn_no=" + order.PsnNo +
  24763. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  24764. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  24765. resp3, requestErr3 := http.Get(api3)
  24766. if requestErr3 != nil {
  24767. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24768. return
  24769. }
  24770. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  24771. if ioErr3 != nil {
  24772. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  24773. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24774. return
  24775. }
  24776. var respJSON3 map[string]interface{}
  24777. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  24778. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24779. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24780. return
  24781. }
  24782. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24783. userJSONBytes3, _ := json.Marshal(respJSON3)
  24784. fmt.Println("log")
  24785. fmt.Println(string(userJSONBytes3))
  24786. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  24787. utils.ErrorLog("解析失败:%v", err)
  24788. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24789. return
  24790. }
  24791. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  24792. var api3 string
  24793. if miConfig.MdtrtareaAdmvs == "320921" {
  24794. api3 = "http://192.168.2.3:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  24795. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  24796. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  24797. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  24798. } else {
  24799. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  24800. api3 = "http://192.168.5.251:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  24801. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  24802. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  24803. }
  24804. resp3, requestErr3 := http.Get(api3)
  24805. if requestErr3 != nil {
  24806. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24807. return
  24808. }
  24809. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  24810. if ioErr3 != nil {
  24811. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  24812. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24813. return
  24814. }
  24815. var respJSON3 map[string]interface{}
  24816. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  24817. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24818. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24819. return
  24820. }
  24821. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24822. userJSONBytes3, _ := json.Marshal(respJSON3)
  24823. if err := json.Unmarshal(userJSONBytes3, &resSixteen10265Two); err != nil {
  24824. utils.ErrorLog("解析失败:%v", err)
  24825. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24826. return
  24827. }
  24828. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  24829. res.Output = resSixteen10265.Output
  24830. res.ErrMsg = resSixteen10265.ErrMsg
  24831. res.Cainfo = resSixteen10265.Cainfo
  24832. res.WarnMsg = resSixteen10265.WarnMsg
  24833. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  24834. res.Infcode = infocode
  24835. } else if miConfig.MdtrtareaAdmvs == "150499" {
  24836. var api3 string
  24837. api3 = "http://172.16.13.254:9532/" + "nmyb/2208?psn_no=" + order.PsnNo +
  24838. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  24839. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  24840. resp3, requestErr3 := http.Get(api3)
  24841. if requestErr3 != nil {
  24842. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24843. return
  24844. }
  24845. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  24846. if ioErr3 != nil {
  24847. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  24848. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24849. return
  24850. }
  24851. var respJSON3 map[string]interface{}
  24852. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  24853. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24854. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24855. return
  24856. }
  24857. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24858. userJSONBytes3, _ := json.Marshal(respJSON3)
  24859. if err := json.Unmarshal(userJSONBytes3, &resSixteen10265Two); err != nil {
  24860. utils.ErrorLog("解析失败:%v", err)
  24861. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24862. return
  24863. }
  24864. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  24865. res.Output = resSixteen10265.Output
  24866. res.ErrMsg = resSixteen10265.ErrMsg
  24867. res.Cainfo = resSixteen10265.Cainfo
  24868. res.WarnMsg = resSixteen10265.WarnMsg
  24869. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  24870. res.Infcode = infocode
  24871. } else if miConfig.MdtrtareaAdmvs == "350500" {
  24872. 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)
  24873. var dat map[string]interface{}
  24874. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  24875. fmt.Println(dat)
  24876. } else {
  24877. fmt.Println(err)
  24878. }
  24879. saveLog(result, src_resquest, "2208", "退费")
  24880. userJSONBytes, _ := json.Marshal(dat)
  24881. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  24882. utils.ErrorLog("解析失败:%v", err)
  24883. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24884. return
  24885. }
  24886. } else if miConfig.MdtrtareaAdmvs == "360302" {
  24887. 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, "")
  24888. var dat map[string]interface{}
  24889. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  24890. fmt.Println(dat)
  24891. } else {
  24892. fmt.Println(err)
  24893. }
  24894. saveLog(result, src_resquest, "2208", "退费")
  24895. userJSONBytes, _ := json.Marshal(dat)
  24896. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  24897. utils.ErrorLog("解析失败:%v", err)
  24898. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24899. return
  24900. }
  24901. } else if miConfig.MdtrtareaAdmvs == "341203" {
  24902. var api3 string
  24903. api3 = miConfig.SecretKey + "ahyb/2208?psn_no=" + order.PsnNo +
  24904. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  24905. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  24906. resp3, requestErr3 := http.Get(api3)
  24907. if requestErr3 != nil {
  24908. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24909. return
  24910. }
  24911. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  24912. if ioErr3 != nil {
  24913. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  24914. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24915. return
  24916. }
  24917. var respJSON3 map[string]interface{}
  24918. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  24919. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24920. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24921. return
  24922. }
  24923. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  24924. if status == "0" {
  24925. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  24926. c.ServeSuccessJSON(map[string]interface{}{
  24927. "failed_code": -10,
  24928. "msg": err_msg,
  24929. })
  24930. return
  24931. }
  24932. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24933. userJSONBytes3, _ := json.Marshal(respJSON3)
  24934. //if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  24935. // utils.ErrorLog("解析失败:%v", err)
  24936. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24937. // return
  24938. //}
  24939. if err := json.Unmarshal(userJSONBytes3, &ahres); err != nil {
  24940. utils.ErrorLog("解析失败:%v", err)
  24941. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24942. return
  24943. }
  24944. res.InfRefmsgid = ahres.InfRefmsgid
  24945. timestamp := int64(ahres.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  24946. // 创建对应的Time类型
  24947. t := time.UnixMilli(timestamp)
  24948. // 格式化成指定的日期字符串
  24949. str := t.Format("2006-01-02 15:04:05")
  24950. res.Output.Setlinfo.SetlTime = str
  24951. res.Output.Setlinfo.AcctMulaidPay = ahres.Output.Setlinfo.AcctMulaidPay
  24952. res.Output.Setlinfo.AcctPay = ahres.Output.Setlinfo.AcctPay
  24953. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  24954. res.Output.Setlinfo.ActPayDedc = ahres.Output.Setlinfo.ActPayDedc
  24955. //res.Output.Setlinfo.Age = ahres.Output.Setlinfo.Age
  24956. res.Output.Setlinfo.Balc = ahres.Output.Setlinfo.Balc
  24957. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  24958. //res.Output.Setlinfo.Certno = ahres.Output.Setlinfo.Certno
  24959. res.Output.Setlinfo.ClrOptins = ahres.Output.Setlinfo.ClrOptins
  24960. //
  24961. //res.Output.Setlinfo.ClrType = ahres.Output.Setlinfo.ClrOptins
  24962. //res.Output.Setlinfo.ClrWay = ahres.Output.Setlinfo.ClrOptins
  24963. //res.Output.Setlinfo.CvlservFlag = ahres.Output.Setlinfo.ClrOptins
  24964. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  24965. res.Output.Setlinfo.FulamtOwnpayAmt = ahres.Output.Setlinfo.FulamtOwnpayAmt
  24966. res.Output.Setlinfo.FundPaySumamt = ahres.Output.Setlinfo.FundPaySumamt
  24967. //res.Output.Setlinfo.Gend = ahres.Output.Setlinfo.Gend
  24968. res.Output.Setlinfo.HifesPay = ahres.Output.Setlinfo.HifesPay
  24969. res.Output.Setlinfo.HifmiPay = ahres.Output.Setlinfo.HifmiPay
  24970. res.Output.Setlinfo.HifpPay = ahres.Output.Setlinfo.HifpPay
  24971. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  24972. res.Output.Setlinfo.HospPartAmt = ahres.Output.Setlinfo.HospPartAmt
  24973. res.Output.Setlinfo.InscpScpAmt = ahres.Output.Setlinfo.InscpScpAmt
  24974. //res.Output.Setlinfo.Insutype = ahres.Output.Setlinfo.Insutype
  24975. res.Output.Setlinfo.MafPay = ahres.Output.Setlinfo.MafPay
  24976. //res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  24977. res.Output.Setlinfo.HifobPay = ahres.Output.Setlinfo.HifobPay
  24978. res.Output.Setlinfo.MdtrtID = ahres.Output.Setlinfo.MdtrtID
  24979. //res.Output.Setlinfo.MedType = ahres.Output.Setlinfo.MedType
  24980. res.Output.Setlinfo.MedfeeSumamt = ahres.Output.Setlinfo.MedfeeSumamt
  24981. res.Output.Setlinfo.MedinsSetlID = ahres.Output.Setlinfo.MedinsSetlID
  24982. //res.Output.Setlinfo.Naty = ahres.Output.Setlinfo.Naty
  24983. res.Output.Setlinfo.OthPay = ahres.Output.Setlinfo.OthPay
  24984. res.Output.Setlinfo.OverlmtSelfpay = ahres.Output.Setlinfo.OverlmtSelfpay
  24985. res.Output.Setlinfo.PreselfpayAmt = ahres.Output.Setlinfo.PreselfpayAmt
  24986. res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  24987. res.Output.Setlinfo.SetlID = ahres.Output.Setlinfo.SetlID
  24988. //res.Output.Setldetail = ahres.Output.Setldetail
  24989. res.ErrMsg = ahres.ErrMsg
  24990. res.Cainfo = ahres.Cainfo
  24991. res.WarnMsg = ahres.WarnMsg
  24992. res.Infcode = ahres.Infcode
  24993. } else if miConfig.MdtrtareaAdmvs == "430800" {
  24994. 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, "")
  24995. var dat map[string]interface{}
  24996. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  24997. fmt.Println(dat)
  24998. } else {
  24999. fmt.Println(err)
  25000. }
  25001. saveLog(result, src_resquest, "2208", "退费")
  25002. userJSONBytes, _ := json.Marshal(dat)
  25003. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  25004. utils.ErrorLog("解析失败:%v", err)
  25005. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25006. return
  25007. }
  25008. } else if miConfig.MdtrtareaAdmvs == "441799" {
  25009. api3 := miConfig.Url + "gdyb/2208?psn_no=" + order.PsnNo +
  25010. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&operator=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  25011. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  25012. resp3, requestErr3 := http.Get(api3)
  25013. if requestErr3 != nil {
  25014. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25015. return
  25016. }
  25017. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  25018. if ioErr3 != nil {
  25019. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  25020. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25021. return
  25022. }
  25023. var respJSON3 map[string]interface{}
  25024. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  25025. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25026. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25027. return
  25028. }
  25029. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25030. userJSONBytes3, _ := json.Marshal(respJSON3)
  25031. fmt.Println("log")
  25032. fmt.Println(string(userJSONBytes3))
  25033. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  25034. utils.ErrorLog("解析失败:%v", err)
  25035. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25036. return
  25037. }
  25038. } else {
  25039. if miConfig.Code == "H15049901371" {
  25040. 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)
  25041. var dat map[string]interface{}
  25042. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  25043. fmt.Println(dat)
  25044. } else {
  25045. fmt.Println(err)
  25046. }
  25047. saveLog(result, src_resquest, "2208", "退费")
  25048. userJSONBytes, _ := json.Marshal(dat)
  25049. if err := json.Unmarshal(userJSONBytes, &resSixteen10265); err != nil {
  25050. utils.ErrorLog("解析失败:%v", err)
  25051. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25052. return
  25053. }
  25054. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  25055. res.Output = resSixteen10265.Output
  25056. res.ErrMsg = resSixteen10265.ErrMsg
  25057. res.Cainfo = resSixteen10265.Cainfo
  25058. res.WarnMsg = resSixteen10265.WarnMsg
  25059. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  25060. res.Infcode = infocode
  25061. } else {
  25062. 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)
  25063. var dat map[string]interface{}
  25064. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  25065. fmt.Println(dat)
  25066. } else {
  25067. fmt.Println(err)
  25068. }
  25069. saveLog(result, src_resquest, "2208", "退费")
  25070. userJSONBytes, _ := json.Marshal(dat)
  25071. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  25072. if err := json.Unmarshal(userJSONBytes, &gz); err != nil {
  25073. utils.ErrorLog("解析失败:%v", err)
  25074. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25075. return
  25076. }
  25077. res.Infcode = gz.Infcode
  25078. } else {
  25079. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  25080. utils.ErrorLog("解析失败:%v", err)
  25081. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25082. return
  25083. }
  25084. }
  25085. }
  25086. }
  25087. if res.Infcode == 0 {
  25088. var res2 ResultSix
  25089. var resSix10265 ResultSix10265
  25090. if miConfig.MdtrtareaAdmvs == "421300" {
  25091. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  25092. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  25093. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  25094. resp3, requestErr3 := http.Get(api3)
  25095. if requestErr3 != nil {
  25096. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25097. return
  25098. }
  25099. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  25100. if ioErr3 != nil {
  25101. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  25102. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25103. return
  25104. }
  25105. var respJSON3 map[string]interface{}
  25106. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  25107. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25108. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25109. return
  25110. }
  25111. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25112. userJSONBytes3, _ := json.Marshal(respJSON3)
  25113. fmt.Println("log")
  25114. fmt.Println(string(userJSONBytes3))
  25115. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  25116. utils.ErrorLog("解析失败:%v", err)
  25117. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25118. return
  25119. }
  25120. } else if miConfig.MdtrtareaAdmvs == "420200" {
  25121. api3 := "http://192.168.0.197:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  25122. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  25123. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  25124. resp3, requestErr3 := http.Get(api3)
  25125. if requestErr3 != nil {
  25126. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25127. return
  25128. }
  25129. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  25130. if ioErr3 != nil {
  25131. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  25132. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25133. return
  25134. }
  25135. var respJSON3 map[string]interface{}
  25136. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  25137. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25138. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25139. return
  25140. }
  25141. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25142. userJSONBytes3, _ := json.Marshal(respJSON3)
  25143. fmt.Println("log")
  25144. fmt.Println(string(userJSONBytes3))
  25145. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  25146. utils.ErrorLog("解析失败:%v", err)
  25147. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25148. return
  25149. }
  25150. } else if miConfig.MdtrtareaAdmvs == "420902" {
  25151. api3 := miConfig.Url + "hbyb/2205?psn_no=" + order.PsnNo +
  25152. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  25153. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  25154. resp3, requestErr3 := http.Get(api3)
  25155. if requestErr3 != nil {
  25156. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25157. return
  25158. }
  25159. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  25160. if ioErr3 != nil {
  25161. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  25162. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25163. return
  25164. }
  25165. var respJSON3 map[string]interface{}
  25166. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  25167. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25168. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25169. return
  25170. }
  25171. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25172. userJSONBytes3, _ := json.Marshal(respJSON3)
  25173. fmt.Println("log")
  25174. fmt.Println(string(userJSONBytes3))
  25175. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  25176. utils.ErrorLog("解析失败:%v", err)
  25177. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25178. return
  25179. }
  25180. } else if miConfig.MdtrtareaAdmvs == "421182" {
  25181. api3 := miConfig.Url + "hbyb/2205?psn_no=" + order.PsnNo +
  25182. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  25183. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  25184. resp3, requestErr3 := http.Get(api3)
  25185. if requestErr3 != nil {
  25186. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25187. return
  25188. }
  25189. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  25190. if ioErr3 != nil {
  25191. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  25192. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25193. return
  25194. }
  25195. var respJSON3 map[string]interface{}
  25196. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  25197. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25198. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25199. return
  25200. }
  25201. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25202. userJSONBytes3, _ := json.Marshal(respJSON3)
  25203. fmt.Println("log")
  25204. fmt.Println(string(userJSONBytes3))
  25205. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  25206. utils.ErrorLog("解析失败:%v", err)
  25207. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25208. return
  25209. }
  25210. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  25211. var api3 string
  25212. if miConfig.MdtrtareaAdmvs == "320921" {
  25213. api3 = "http://192.168.2.3:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  25214. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  25215. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  25216. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  25217. } else {
  25218. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  25219. api3 = "http://192.168.5.251:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  25220. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  25221. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  25222. }
  25223. resp3, requestErr3 := http.Get(api3)
  25224. if requestErr3 != nil {
  25225. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25226. return
  25227. }
  25228. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  25229. if ioErr3 != nil {
  25230. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  25231. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25232. return
  25233. }
  25234. var respJSON3 map[string]interface{}
  25235. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  25236. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25237. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25238. return
  25239. }
  25240. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25241. userJSONBytes3, _ := json.Marshal(respJSON3)
  25242. fmt.Println("log")
  25243. fmt.Println(string(userJSONBytes3))
  25244. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  25245. utils.ErrorLog("解析失败:%v", err)
  25246. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25247. return
  25248. }
  25249. res2.InfRefmsgid = resSix10265.InfRefmsgid
  25250. res2.Output = resSix10265.Output
  25251. res2.ErrMsg = resSix10265.ErrMsg
  25252. res2.Cainfo = resSix10265.Cainfo
  25253. res2.WarnMsg = resSix10265.WarnMsg
  25254. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  25255. res2.Infcode = infocode
  25256. } else if miConfig.MdtrtareaAdmvs == "150499" {
  25257. var api3 string
  25258. api3 = "http://172.16.13.254:9532/" + "nmyb/2205?psn_no=" + order.PsnNo +
  25259. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  25260. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  25261. resp3, requestErr3 := http.Get(api3)
  25262. if requestErr3 != nil {
  25263. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25264. return
  25265. }
  25266. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  25267. if ioErr3 != nil {
  25268. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  25269. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25270. return
  25271. }
  25272. var respJSON3 map[string]interface{}
  25273. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  25274. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25275. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25276. return
  25277. }
  25278. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25279. userJSONBytes3, _ := json.Marshal(respJSON3)
  25280. fmt.Println("log")
  25281. fmt.Println(string(userJSONBytes3))
  25282. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  25283. utils.ErrorLog("解析失败:%v", err)
  25284. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25285. return
  25286. }
  25287. res2.InfRefmsgid = resSix10265.InfRefmsgid
  25288. res2.Output = resSix10265.Output
  25289. res2.ErrMsg = resSix10265.ErrMsg
  25290. res2.Cainfo = resSix10265.Cainfo
  25291. res2.WarnMsg = resSix10265.WarnMsg
  25292. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  25293. res2.Infcode = infocode
  25294. } else if miConfig.MdtrtareaAdmvs == "350500" {
  25295. 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)
  25296. var dat map[string]interface{}
  25297. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  25298. fmt.Println(dat)
  25299. } else {
  25300. fmt.Println(err)
  25301. }
  25302. saveLog(result2, src_request, "2205", "撤销明细")
  25303. userJSONBytes, _ := json.Marshal(dat)
  25304. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  25305. utils.ErrorLog("解析失败:%v", err)
  25306. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25307. return
  25308. }
  25309. } else if miConfig.MdtrtareaAdmvs == "360302" {
  25310. 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, "")
  25311. var dat map[string]interface{}
  25312. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  25313. fmt.Println(dat)
  25314. } else {
  25315. fmt.Println(err)
  25316. }
  25317. saveLog(result2, src_request, "2205", "撤销明细")
  25318. userJSONBytes, _ := json.Marshal(dat)
  25319. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  25320. utils.ErrorLog("解析失败:%v", err)
  25321. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25322. return
  25323. }
  25324. } else if miConfig.MdtrtareaAdmvs == "341203" {
  25325. var api3 string
  25326. api3 = miConfig.SecretKey + "ahyb/2205?psn_no=" + order.PsnNo +
  25327. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  25328. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  25329. resp3, requestErr3 := http.Get(api3)
  25330. if requestErr3 != nil {
  25331. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25332. return
  25333. }
  25334. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  25335. if ioErr3 != nil {
  25336. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  25337. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25338. return
  25339. }
  25340. var respJSON3 map[string]interface{}
  25341. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  25342. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25343. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25344. return
  25345. }
  25346. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  25347. if status == "0" {
  25348. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  25349. c.ServeSuccessJSON(map[string]interface{}{
  25350. "failed_code": -10,
  25351. "msg": err_msg,
  25352. })
  25353. return
  25354. }
  25355. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25356. userJSONBytes3, _ := json.Marshal(respJSON3)
  25357. fmt.Println("log")
  25358. fmt.Println(string(userJSONBytes3))
  25359. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  25360. utils.ErrorLog("解析失败:%v", err)
  25361. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25362. return
  25363. }
  25364. } else if miConfig.MdtrtareaAdmvs == "430800" {
  25365. 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, "")
  25366. var dat map[string]interface{}
  25367. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  25368. fmt.Println(dat)
  25369. } else {
  25370. fmt.Println(err)
  25371. }
  25372. saveLog(result2, src_request, "2205", "撤销明细")
  25373. userJSONBytes, _ := json.Marshal(dat)
  25374. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  25375. utils.ErrorLog("解析失败:%v", err)
  25376. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25377. return
  25378. }
  25379. } else if miConfig.MdtrtareaAdmvs == "441799" {
  25380. api3 := miConfig.Url + "gdyb/six?psn_no=" + order.PsnNo +
  25381. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  25382. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  25383. resp3, requestErr3 := http.Get(api3)
  25384. if requestErr3 != nil {
  25385. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25386. return
  25387. }
  25388. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  25389. if ioErr3 != nil {
  25390. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  25391. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25392. return
  25393. }
  25394. var respJSON3 map[string]interface{}
  25395. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  25396. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25397. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25398. return
  25399. }
  25400. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25401. userJSONBytes3, _ := json.Marshal(respJSON3)
  25402. fmt.Println("log")
  25403. fmt.Println(string(userJSONBytes3))
  25404. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  25405. utils.ErrorLog("解析失败:%v", err)
  25406. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25407. return
  25408. }
  25409. } else {
  25410. if miConfig.Code == "H15049901371" {
  25411. 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)
  25412. var dat map[string]interface{}
  25413. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  25414. fmt.Println(dat)
  25415. } else {
  25416. fmt.Println(err)
  25417. }
  25418. saveLog(result2, src_request, "2205", "撤销明细")
  25419. userJSONBytes, _ := json.Marshal(dat)
  25420. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  25421. utils.ErrorLog("解析失败:%v", err)
  25422. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25423. return
  25424. }
  25425. res2.InfRefmsgid = resSix10265.InfRefmsgid
  25426. res2.Output = resSix10265.Output
  25427. res2.ErrMsg = resSix10265.ErrMsg
  25428. res2.Cainfo = resSix10265.Cainfo
  25429. res2.WarnMsg = resSix10265.WarnMsg
  25430. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  25431. res2.Infcode = infocode
  25432. } else {
  25433. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  25434. res2.Infcode = 0
  25435. } else {
  25436. 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)
  25437. var dat map[string]interface{}
  25438. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  25439. fmt.Println(dat)
  25440. } else {
  25441. fmt.Println(err)
  25442. }
  25443. saveLog(result2, src_request, "2205", "撤销明细")
  25444. userJSONBytes, _ := json.Marshal(dat)
  25445. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  25446. utils.ErrorLog("解析失败:%v", err)
  25447. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25448. return
  25449. }
  25450. }
  25451. }
  25452. }
  25453. if res2.Infcode == -1 {
  25454. c.ServeSuccessJSON(map[string]interface{}{
  25455. "failed_code": -10,
  25456. "msg": res2.ErrMsg,
  25457. })
  25458. return
  25459. }
  25460. if res2.Infcode == 0 {
  25461. err := service.UpdataOrderStatus(order_id, order.Number, adminUser.CurrentOrgId, src_resquest, result)
  25462. if err == nil {
  25463. //当押金不为零时产生退费记录
  25464. if order.Decimal != 0 {
  25465. tmp := strconv.FormatInt(order.ID, 10)
  25466. err = service.MoneyIncrease(adminUser.CurrentOrgId, order.PatientId, tmp, order.Decimal)
  25467. if err != nil {
  25468. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25469. return
  25470. }
  25471. }
  25472. c.ServeSuccessJSON(map[string]interface{}{
  25473. "msg": "退费成功",
  25474. })
  25475. } else {
  25476. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25477. return
  25478. }
  25479. } else {
  25480. c.ServeSuccessJSON(map[string]interface{}{
  25481. "failed_code": -10,
  25482. "msg": res2.ErrMsg,
  25483. })
  25484. }
  25485. } else {
  25486. c.ServeSuccessJSON(map[string]interface{}{
  25487. "failed_code": -10,
  25488. "msg": res.ErrMsg,
  25489. })
  25490. }
  25491. }
  25492. }
  25493. func (c *HisApiController) RefundNumber() {
  25494. record_time := c.GetString("record_time")
  25495. //patient_id, _ := c.GetInt64("patient_id")
  25496. admin_user_id, _ := c.GetInt64("admin_user_id")
  25497. his_patient_id, _ := c.GetInt64("id")
  25498. timeLayout := "2006-01-02"
  25499. loc, _ := time.LoadLocation("Local")
  25500. adminUser := c.GetAdminUserInfo()
  25501. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  25502. fmt.Println(err)
  25503. if err != nil {
  25504. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  25505. return
  25506. }
  25507. recordDateTime := theTime.Unix()
  25508. //his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  25509. his, _ := service.GetHisPatientRecord(adminUser.CurrentOrgId, his_patient_id)
  25510. //patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  25511. //order, _ := service.GetHisOrderByID(order_id)
  25512. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  25513. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  25514. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  25515. count, _ := service.GetOrderCountByNumber(adminUser.CurrentOrgId, his.PatientId, recordDateTime, his.Number)
  25516. if count > 0 {
  25517. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeOrderParamWrong)
  25518. return
  25519. }
  25520. if config.IsOpen == 1 { //对接了医保,走医保流程
  25521. var res2 ResultSix
  25522. var res3 GZResultSix
  25523. var resSix10265 ResultSix10265
  25524. if miConfig.MdtrtareaAdmvs == "421300" {
  25525. api3 := "http://192.168.124.4:9532/" + "hbyb/2202?psn_no=" + his.PsnNo +
  25526. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  25527. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  25528. resp3, requestErr3 := http.Get(api3)
  25529. if requestErr3 != nil {
  25530. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25531. return
  25532. }
  25533. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  25534. if ioErr3 != nil {
  25535. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  25536. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25537. return
  25538. }
  25539. var respJSON3 map[string]interface{}
  25540. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  25541. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25542. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25543. return
  25544. }
  25545. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25546. userJSONBytes3, _ := json.Marshal(respJSON3)
  25547. fmt.Println("log")
  25548. fmt.Println(string(userJSONBytes3))
  25549. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  25550. utils.ErrorLog("解析失败:%v", err)
  25551. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25552. return
  25553. }
  25554. } else if miConfig.MdtrtareaAdmvs == "420200" {
  25555. api3 := "http://192.168.0.197:9532/" + "hbyb/2202?psn_no=" + his.PsnNo +
  25556. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  25557. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  25558. resp3, requestErr3 := http.Get(api3)
  25559. if requestErr3 != nil {
  25560. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25561. return
  25562. }
  25563. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  25564. if ioErr3 != nil {
  25565. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  25566. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25567. return
  25568. }
  25569. var respJSON3 map[string]interface{}
  25570. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  25571. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25572. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25573. return
  25574. }
  25575. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25576. userJSONBytes3, _ := json.Marshal(respJSON3)
  25577. fmt.Println("log")
  25578. fmt.Println(string(userJSONBytes3))
  25579. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  25580. utils.ErrorLog("解析失败:%v", err)
  25581. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25582. return
  25583. }
  25584. } else if miConfig.MdtrtareaAdmvs == "420902" {
  25585. api3 := miConfig.Url + "hbyb/2202?psn_no=" + his.PsnNo +
  25586. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  25587. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  25588. resp3, requestErr3 := http.Get(api3)
  25589. if requestErr3 != nil {
  25590. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25591. return
  25592. }
  25593. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  25594. if ioErr3 != nil {
  25595. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  25596. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25597. return
  25598. }
  25599. var respJSON3 map[string]interface{}
  25600. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  25601. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25602. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25603. return
  25604. }
  25605. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25606. userJSONBytes3, _ := json.Marshal(respJSON3)
  25607. fmt.Println("log")
  25608. fmt.Println(string(userJSONBytes3))
  25609. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  25610. utils.ErrorLog("解析失败:%v", err)
  25611. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25612. return
  25613. }
  25614. } else if miConfig.MdtrtareaAdmvs == "421182" {
  25615. api3 := miConfig.Url + "hbyb/2202?psn_no=" + his.PsnNo +
  25616. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  25617. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  25618. resp3, requestErr3 := http.Get(api3)
  25619. if requestErr3 != nil {
  25620. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25621. return
  25622. }
  25623. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  25624. if ioErr3 != nil {
  25625. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  25626. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25627. return
  25628. }
  25629. var respJSON3 map[string]interface{}
  25630. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  25631. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25632. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25633. return
  25634. }
  25635. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25636. userJSONBytes3, _ := json.Marshal(respJSON3)
  25637. fmt.Println("log")
  25638. fmt.Println(string(userJSONBytes3))
  25639. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  25640. utils.ErrorLog("解析失败:%v", err)
  25641. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25642. return
  25643. }
  25644. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  25645. var api3 string
  25646. if miConfig.MdtrtareaAdmvs == "320921" {
  25647. api3 = "http://192.168.2.3:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  25648. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  25649. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  25650. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  25651. } else {
  25652. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  25653. api3 = "http://192.168.5.251:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  25654. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  25655. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  25656. }
  25657. resp3, requestErr3 := http.Get(api3)
  25658. if requestErr3 != nil {
  25659. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25660. return
  25661. }
  25662. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  25663. if ioErr3 != nil {
  25664. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  25665. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25666. return
  25667. }
  25668. var respJSON3 map[string]interface{}
  25669. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  25670. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25671. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25672. return
  25673. }
  25674. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25675. userJSONBytes3, _ := json.Marshal(respJSON3)
  25676. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  25677. utils.ErrorLog("解析失败:%v", err)
  25678. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25679. return
  25680. }
  25681. res2.InfRefmsgid = resSix10265.InfRefmsgid
  25682. res2.Output = resSix10265.Output
  25683. res2.ErrMsg = resSix10265.ErrMsg
  25684. res2.Cainfo = resSix10265.Cainfo
  25685. res2.WarnMsg = resSix10265.WarnMsg
  25686. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  25687. res2.Infcode = infocode
  25688. } else if miConfig.MdtrtareaAdmvs == "150499" {
  25689. var api3 string
  25690. api3 = "http://172.16.13.254:9532/" + "nmyb/2202?psn_no=" + his.PsnNo +
  25691. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  25692. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  25693. resp3, requestErr3 := http.Get(api3)
  25694. if requestErr3 != nil {
  25695. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25696. return
  25697. }
  25698. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  25699. if ioErr3 != nil {
  25700. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  25701. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25702. return
  25703. }
  25704. var respJSON3 map[string]interface{}
  25705. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  25706. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25707. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25708. return
  25709. }
  25710. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25711. userJSONBytes3, _ := json.Marshal(respJSON3)
  25712. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  25713. utils.ErrorLog("解析失败:%v", err)
  25714. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25715. return
  25716. }
  25717. res2.InfRefmsgid = resSix10265.InfRefmsgid
  25718. res2.Output = resSix10265.Output
  25719. res2.ErrMsg = resSix10265.ErrMsg
  25720. res2.Cainfo = resSix10265.Cainfo
  25721. res2.WarnMsg = resSix10265.WarnMsg
  25722. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  25723. res2.Infcode = infocode
  25724. } else if miConfig.MdtrtareaAdmvs == "350500" {
  25725. 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)
  25726. var dat map[string]interface{}
  25727. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  25728. fmt.Println(dat)
  25729. } else {
  25730. fmt.Println(err)
  25731. }
  25732. saveLog(result, request, "2202", "退号")
  25733. userJSONBytes, _ := json.Marshal(dat)
  25734. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  25735. utils.ErrorLog("解析失败:%v", err)
  25736. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25737. return
  25738. }
  25739. } else if miConfig.MdtrtareaAdmvs == "360302" {
  25740. 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, "")
  25741. var dat map[string]interface{}
  25742. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  25743. fmt.Println(dat)
  25744. } else {
  25745. fmt.Println(err)
  25746. }
  25747. saveLog(result, request, "2202", "退号")
  25748. userJSONBytes, _ := json.Marshal(dat)
  25749. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  25750. utils.ErrorLog("解析失败:%v", err)
  25751. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25752. return
  25753. }
  25754. } else if miConfig.MdtrtareaAdmvs == "341203" {
  25755. var api3 string
  25756. api3 = miConfig.SecretKey + "ahyb/2202?psn_no=" + his.PsnNo +
  25757. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  25758. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  25759. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  25760. resp3, requestErr3 := http.Get(api3)
  25761. if requestErr3 != nil {
  25762. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25763. return
  25764. }
  25765. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  25766. if ioErr3 != nil {
  25767. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  25768. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25769. return
  25770. }
  25771. var respJSON3 map[string]interface{}
  25772. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  25773. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25774. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25775. return
  25776. }
  25777. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  25778. if status == "0" {
  25779. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  25780. c.ServeSuccessJSON(map[string]interface{}{
  25781. "failed_code": -10,
  25782. "msg": err_msg,
  25783. })
  25784. return
  25785. }
  25786. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25787. userJSONBytes3, _ := json.Marshal(respJSON3)
  25788. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  25789. utils.ErrorLog("解析失败:%v", err)
  25790. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25791. return
  25792. }
  25793. utils.ErrorLog("接口返回数据解析JSON失败: %v", res2.Infcode)
  25794. } else if miConfig.MdtrtareaAdmvs == "430800" {
  25795. 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, "")
  25796. var dat map[string]interface{}
  25797. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  25798. fmt.Println(dat)
  25799. } else {
  25800. fmt.Println(err)
  25801. }
  25802. saveLog(result, request, "2202", "退号")
  25803. userJSONBytes, _ := json.Marshal(dat)
  25804. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  25805. utils.ErrorLog("解析失败:%v", err)
  25806. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25807. return
  25808. }
  25809. } else if miConfig.MdtrtareaAdmvs == "441799" {
  25810. api3 := miConfig.Url + "gdyb/2202?psn_no=" + his.PsnNo +
  25811. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&operator=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  25812. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&admin_user_id=" + strconv.FormatInt(admin_user_id, 10)
  25813. resp3, requestErr3 := http.Get(api3)
  25814. if requestErr3 != nil {
  25815. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25816. return
  25817. }
  25818. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  25819. if ioErr3 != nil {
  25820. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  25821. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25822. return
  25823. }
  25824. var respJSON3 map[string]interface{}
  25825. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  25826. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25827. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25828. return
  25829. }
  25830. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25831. userJSONBytes3, _ := json.Marshal(respJSON3)
  25832. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  25833. utils.ErrorLog("解析失败:%v", err)
  25834. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25835. return
  25836. }
  25837. } else {
  25838. var api3 string
  25839. if miConfig.Code == "H15049901371" {
  25840. api3 = "http://127.0.0.1:9532/" + "gdyb/three?psn_no=" + his.PsnNo +
  25841. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  25842. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  25843. } else {
  25844. api3 = "http://127.0.0.1:9532/" + "gdyb/2202?psn_no=" + his.PsnNo +
  25845. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&operator=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  25846. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&admin_user_id=" + strconv.FormatInt(admin_user_id, 10)
  25847. }
  25848. resp3, requestErr3 := http.Get(api3)
  25849. if requestErr3 != nil {
  25850. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25851. return
  25852. }
  25853. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  25854. if ioErr3 != nil {
  25855. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  25856. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25857. return
  25858. }
  25859. var respJSON3 map[string]interface{}
  25860. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  25861. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25862. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25863. return
  25864. }
  25865. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25866. userJSONBytes3, _ := json.Marshal(respJSON3)
  25867. if miConfig.Code == "H15049901371" {
  25868. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  25869. utils.ErrorLog("解析失败:%v", err)
  25870. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25871. return
  25872. }
  25873. res2.InfRefmsgid = resSix10265.InfRefmsgid
  25874. res2.Output = resSix10265.Output
  25875. res2.ErrMsg = resSix10265.ErrMsg
  25876. res2.Cainfo = resSix10265.Cainfo
  25877. res2.WarnMsg = resSix10265.WarnMsg
  25878. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  25879. res2.Infcode = infocode
  25880. } else {
  25881. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  25882. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  25883. utils.ErrorLog("解析失败:%v", err)
  25884. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25885. return
  25886. }
  25887. res2.Infcode = res3.Infcode
  25888. } else {
  25889. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  25890. utils.ErrorLog("解析失败:%v", err)
  25891. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25892. return
  25893. }
  25894. }
  25895. }
  25896. }
  25897. if res2.Infcode == -1 {
  25898. utils.ErrorLog("解析失败:%v", res2.Infcode)
  25899. c.ServeSuccessJSON(map[string]interface{}{
  25900. "failed_code": -10,
  25901. "msg": res2.ErrMsg,
  25902. })
  25903. return
  25904. }
  25905. if res2.Infcode == 0 {
  25906. if err == nil {
  25907. c.ServeSuccessJSON(map[string]interface{}{
  25908. "msg": "退号成功",
  25909. })
  25910. service.UpdataRegStatusTwo(his_patient_id, recordDateTime, adminUser.CurrentOrgId)
  25911. } else {
  25912. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25913. return
  25914. }
  25915. }
  25916. } else {
  25917. //err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId)
  25918. //if err == nil {
  25919. // c.ServeSuccessJSON(map[string]interface{}{
  25920. // "msg": "退费成功",
  25921. // })
  25922. //} else {
  25923. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25924. // return
  25925. //}
  25926. }
  25927. }
  25928. func (c *HisApiController) RefundDetail() {
  25929. order_id, _ := c.GetInt64("order_id")
  25930. admin_user_id, _ := c.GetInt64("admin_user_id")
  25931. //his_patient_id, _ := c.GetInt64("his_patient_id")
  25932. number := c.GetString("number")
  25933. record_time := c.GetString("record_time")
  25934. patient_id, _ := c.GetInt64("patient_id")
  25935. //med_type, _ := c.GetInt64("med_type")
  25936. timeLayout := "2006-01-02"
  25937. loc, _ := time.LoadLocation("Local")
  25938. adminUser := c.GetAdminUserInfo()
  25939. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  25940. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  25941. fmt.Println(err)
  25942. if err != nil {
  25943. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  25944. return
  25945. }
  25946. recordDateTime := theTime.Unix()
  25947. //his, _ := service.GetNewVMHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  25948. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  25949. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  25950. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  25951. var order models.HisOrder
  25952. order, _ = service.GetHisOrderByID(order_id)
  25953. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  25954. if config.IsOpen == 1 { //对接了医保,走医保流程
  25955. var res2 ResultSix
  25956. if miConfig.MdtrtareaAdmvs == "421300" {
  25957. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  25958. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  25959. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  25960. resp3, requestErr3 := http.Get(api3)
  25961. if requestErr3 != nil {
  25962. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25963. return
  25964. }
  25965. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  25966. if ioErr3 != nil {
  25967. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  25968. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25969. return
  25970. }
  25971. var respJSON3 map[string]interface{}
  25972. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  25973. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25974. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25975. return
  25976. }
  25977. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25978. userJSONBytes3, _ := json.Marshal(respJSON3)
  25979. fmt.Println("log")
  25980. fmt.Println(string(userJSONBytes3))
  25981. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  25982. utils.ErrorLog("解析失败:%v", err)
  25983. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25984. return
  25985. }
  25986. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  25987. if err == nil {
  25988. c.ServeSuccessJSON(map[string]interface{}{
  25989. "msg": "撤销明细成功",
  25990. })
  25991. return
  25992. } else {
  25993. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25994. return
  25995. }
  25996. } else if miConfig.MdtrtareaAdmvs == "420200" {
  25997. api3 := "http://192.168.0.197:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  25998. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  25999. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  26000. resp3, requestErr3 := http.Get(api3)
  26001. if requestErr3 != nil {
  26002. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26003. return
  26004. }
  26005. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  26006. if ioErr3 != nil {
  26007. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  26008. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26009. return
  26010. }
  26011. var respJSON3 map[string]interface{}
  26012. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  26013. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26014. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26015. return
  26016. }
  26017. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26018. userJSONBytes3, _ := json.Marshal(respJSON3)
  26019. fmt.Println("log")
  26020. fmt.Println(string(userJSONBytes3))
  26021. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  26022. utils.ErrorLog("解析失败:%v", err)
  26023. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26024. return
  26025. }
  26026. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  26027. if err == nil {
  26028. c.ServeSuccessJSON(map[string]interface{}{
  26029. "msg": "撤销明细成功",
  26030. })
  26031. return
  26032. } else {
  26033. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26034. return
  26035. }
  26036. } else if miConfig.MdtrtareaAdmvs == "420902" {
  26037. api3 := miConfig.Url + "hbyb/2205?psn_no=" + order.PsnNo +
  26038. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  26039. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  26040. resp3, requestErr3 := http.Get(api3)
  26041. if requestErr3 != nil {
  26042. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26043. return
  26044. }
  26045. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  26046. if ioErr3 != nil {
  26047. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  26048. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26049. return
  26050. }
  26051. var respJSON3 map[string]interface{}
  26052. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  26053. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26054. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26055. return
  26056. }
  26057. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26058. userJSONBytes3, _ := json.Marshal(respJSON3)
  26059. fmt.Println("log")
  26060. fmt.Println(string(userJSONBytes3))
  26061. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  26062. utils.ErrorLog("解析失败:%v", err)
  26063. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26064. return
  26065. }
  26066. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  26067. if err == nil {
  26068. c.ServeSuccessJSON(map[string]interface{}{
  26069. "msg": "撤销明细成功",
  26070. })
  26071. return
  26072. } else {
  26073. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26074. return
  26075. }
  26076. } else if miConfig.MdtrtareaAdmvs == "421182" {
  26077. api3 := miConfig.Url + "hbyb/2205?psn_no=" + order.PsnNo +
  26078. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  26079. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  26080. resp3, requestErr3 := http.Get(api3)
  26081. if requestErr3 != nil {
  26082. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26083. return
  26084. }
  26085. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  26086. if ioErr3 != nil {
  26087. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  26088. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26089. return
  26090. }
  26091. var respJSON3 map[string]interface{}
  26092. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  26093. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26094. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26095. return
  26096. }
  26097. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26098. userJSONBytes3, _ := json.Marshal(respJSON3)
  26099. fmt.Println("log")
  26100. fmt.Println(string(userJSONBytes3))
  26101. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  26102. utils.ErrorLog("解析失败:%v", err)
  26103. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26104. return
  26105. }
  26106. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  26107. if err == nil {
  26108. c.ServeSuccessJSON(map[string]interface{}{
  26109. "msg": "撤销明细成功",
  26110. })
  26111. return
  26112. } else {
  26113. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26114. return
  26115. }
  26116. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  26117. var resSix10265 ResultSix10265
  26118. var api3 string
  26119. if miConfig.MdtrtareaAdmvs == "320921" {
  26120. api3 = "http://192.168.2.3:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  26121. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  26122. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  26123. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  26124. } else {
  26125. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  26126. api3 = "http://192.168.5.251:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  26127. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  26128. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  26129. }
  26130. resp3, requestErr3 := http.Get(api3)
  26131. utils.ErrorLog("接口: %v", requestErr3)
  26132. if requestErr3 != nil {
  26133. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26134. return
  26135. }
  26136. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  26137. if ioErr3 != nil {
  26138. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  26139. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26140. return
  26141. }
  26142. var respJSON3 map[string]interface{}
  26143. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  26144. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26145. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26146. return
  26147. }
  26148. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26149. userJSONBytes3, _ := json.Marshal(respJSON3)
  26150. fmt.Println("log")
  26151. fmt.Println(string(userJSONBytes3))
  26152. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  26153. utils.ErrorLog("解析失败:%v", err)
  26154. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26155. return
  26156. }
  26157. res2.InfRefmsgid = resSix10265.InfRefmsgid
  26158. res2.Output = resSix10265.Output
  26159. res2.ErrMsg = resSix10265.ErrMsg
  26160. res2.Cainfo = resSix10265.Cainfo
  26161. res2.WarnMsg = resSix10265.WarnMsg
  26162. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  26163. res2.Infcode = infocode
  26164. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  26165. if err == nil {
  26166. c.ServeSuccessJSON(map[string]interface{}{
  26167. "msg": "撤销明细成功",
  26168. })
  26169. return
  26170. } else {
  26171. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26172. return
  26173. }
  26174. } else if miConfig.MdtrtareaAdmvs == "341203" {
  26175. var api3 string
  26176. api3 = miConfig.SecretKey + "ahyb/2205?psn_no=" + order.PsnNo +
  26177. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  26178. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  26179. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  26180. resp3, requestErr3 := http.Get(api3)
  26181. utils.ErrorLog("接口: %v", requestErr3)
  26182. if requestErr3 != nil {
  26183. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26184. return
  26185. }
  26186. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  26187. if ioErr3 != nil {
  26188. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  26189. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26190. return
  26191. }
  26192. var respJSON3 map[string]interface{}
  26193. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  26194. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26195. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26196. return
  26197. }
  26198. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  26199. if status == "0" {
  26200. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  26201. c.ServeSuccessJSON(map[string]interface{}{
  26202. "failed_code": -10,
  26203. "msg": err_msg,
  26204. })
  26205. return
  26206. }
  26207. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26208. userJSONBytes3, _ := json.Marshal(respJSON3)
  26209. fmt.Println("log")
  26210. fmt.Println(string(userJSONBytes3))
  26211. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  26212. utils.ErrorLog("解析失败:%v", err)
  26213. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26214. return
  26215. }
  26216. fmt.Println(res2.Infcode)
  26217. if res2.Infcode == -1 {
  26218. c.ServeSuccessJSON(map[string]interface{}{
  26219. "failed_code": -10,
  26220. "msg": res2.ErrMsg,
  26221. })
  26222. return
  26223. }
  26224. if res2.Infcode == 0 {
  26225. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  26226. if err == nil {
  26227. c.ServeSuccessJSON(map[string]interface{}{
  26228. "msg": "撤销明细成功",
  26229. })
  26230. return
  26231. } else {
  26232. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26233. return
  26234. }
  26235. } else {
  26236. c.ServeSuccessJSON(map[string]interface{}{
  26237. "failed_code": -10,
  26238. "msg": res2.ErrMsg,
  26239. })
  26240. }
  26241. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  26242. if err == nil {
  26243. c.ServeSuccessJSON(map[string]interface{}{
  26244. "msg": "撤销明细成功",
  26245. })
  26246. return
  26247. } else {
  26248. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26249. return
  26250. }
  26251. } else if miConfig.MdtrtareaAdmvs == "150499" {
  26252. var resSix10265 ResultSix10265
  26253. var api3 string
  26254. api3 = "http://172.16.13.254:9532/" + "nmyb/2205?psn_no=" + order.PsnNo +
  26255. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  26256. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  26257. resp3, requestErr3 := http.Get(api3)
  26258. if requestErr3 != nil {
  26259. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26260. return
  26261. }
  26262. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  26263. if ioErr3 != nil {
  26264. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  26265. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26266. return
  26267. }
  26268. var respJSON3 map[string]interface{}
  26269. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  26270. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26271. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26272. return
  26273. }
  26274. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26275. userJSONBytes3, _ := json.Marshal(respJSON3)
  26276. fmt.Println("log")
  26277. fmt.Println(string(userJSONBytes3))
  26278. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  26279. utils.ErrorLog("解析失败:%v", err)
  26280. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26281. return
  26282. }
  26283. res2.InfRefmsgid = resSix10265.InfRefmsgid
  26284. res2.Output = resSix10265.Output
  26285. res2.ErrMsg = resSix10265.ErrMsg
  26286. res2.Cainfo = resSix10265.Cainfo
  26287. res2.WarnMsg = resSix10265.WarnMsg
  26288. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  26289. res2.Infcode = infocode
  26290. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  26291. if err == nil {
  26292. c.ServeSuccessJSON(map[string]interface{}{
  26293. "msg": "撤销明细成功",
  26294. })
  26295. return
  26296. } else {
  26297. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26298. return
  26299. }
  26300. } else if miConfig.MdtrtareaAdmvs == "350500" {
  26301. 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)
  26302. var dat map[string]interface{}
  26303. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  26304. fmt.Println(dat)
  26305. } else {
  26306. fmt.Println(err)
  26307. }
  26308. saveLog(result2, src_request, "2205", "撤销明细")
  26309. userJSONBytes, _ := json.Marshal(dat)
  26310. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  26311. utils.ErrorLog("解析失败:%v", err)
  26312. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26313. return
  26314. }
  26315. if res2.Infcode == 0 {
  26316. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  26317. if err == nil {
  26318. c.ServeSuccessJSON(map[string]interface{}{
  26319. "msg": "撤销明细成功",
  26320. })
  26321. return
  26322. } else {
  26323. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26324. return
  26325. }
  26326. } else {
  26327. c.ServeSuccessJSON(map[string]interface{}{
  26328. "failed_code": -10,
  26329. "msg": res2.ErrMsg,
  26330. })
  26331. }
  26332. } else if miConfig.MdtrtareaAdmvs == "360302" {
  26333. 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, "")
  26334. var dat map[string]interface{}
  26335. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  26336. fmt.Println(dat)
  26337. } else {
  26338. fmt.Println(err)
  26339. }
  26340. saveLog(result2, src_request, "2205", "撤销明细")
  26341. userJSONBytes, _ := json.Marshal(dat)
  26342. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  26343. utils.ErrorLog("解析失败:%v", err)
  26344. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26345. return
  26346. }
  26347. if res2.Infcode == 0 {
  26348. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  26349. if err == nil {
  26350. c.ServeSuccessJSON(map[string]interface{}{
  26351. "msg": "撤销明细成功",
  26352. })
  26353. return
  26354. } else {
  26355. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26356. return
  26357. }
  26358. } else {
  26359. c.ServeSuccessJSON(map[string]interface{}{
  26360. "failed_code": -10,
  26361. "msg": res2.ErrMsg,
  26362. })
  26363. }
  26364. } else if miConfig.MdtrtareaAdmvs == "430800" {
  26365. 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, "")
  26366. var dat map[string]interface{}
  26367. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  26368. fmt.Println(dat)
  26369. } else {
  26370. fmt.Println(err)
  26371. }
  26372. saveLog(result2, src_request, "2205", "撤销明细")
  26373. userJSONBytes, _ := json.Marshal(dat)
  26374. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  26375. utils.ErrorLog("解析失败:%v", err)
  26376. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26377. return
  26378. }
  26379. if res2.Infcode == 0 {
  26380. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  26381. if err == nil {
  26382. c.ServeSuccessJSON(map[string]interface{}{
  26383. "msg": "撤销明细成功",
  26384. })
  26385. return
  26386. } else {
  26387. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26388. return
  26389. }
  26390. } else {
  26391. c.ServeSuccessJSON(map[string]interface{}{
  26392. "failed_code": -10,
  26393. "msg": res2.ErrMsg,
  26394. })
  26395. }
  26396. } else if miConfig.MdtrtareaAdmvs == "441799" {
  26397. api2 := miConfig.Url + "gdyb/six?psn_no=" + his.PsnNo +
  26398. "&mdtrt_id=" + his.Number + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  26399. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  26400. resp2, requestErr2 := http.Get(api2)
  26401. if requestErr2 != nil {
  26402. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26403. return
  26404. }
  26405. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  26406. if ioErr2 != nil {
  26407. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  26408. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26409. return
  26410. }
  26411. var respJSON2 map[string]interface{}
  26412. if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  26413. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26414. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26415. return
  26416. }
  26417. respJSON2 = respJSON2["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26418. userJSONBytes3, _ := json.Marshal(respJSON2)
  26419. fmt.Println("log")
  26420. fmt.Println(string(userJSONBytes3))
  26421. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  26422. utils.ErrorLog("解析失败:%v", err)
  26423. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26424. return
  26425. }
  26426. if res2.Infcode == 0 {
  26427. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  26428. if err == nil {
  26429. c.ServeSuccessJSON(map[string]interface{}{
  26430. "msg": "撤销明细成功",
  26431. })
  26432. return
  26433. } else {
  26434. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26435. return
  26436. }
  26437. } else {
  26438. c.ServeSuccessJSON(map[string]interface{}{
  26439. "failed_code": -10,
  26440. "msg": res2.ErrMsg,
  26441. })
  26442. }
  26443. } else {
  26444. api2 := "http://127.0.0.1:9532/" + "gdyb/six?psn_no=" + his.PsnNo +
  26445. "&mdtrt_id=" + his.Number + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  26446. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&admin_user_id=" + strconv.FormatInt(admin_user_id, 10)
  26447. resp2, requestErr2 := http.Get(api2)
  26448. if requestErr2 != nil {
  26449. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26450. return
  26451. }
  26452. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  26453. if ioErr2 != nil {
  26454. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  26455. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26456. return
  26457. }
  26458. var respJSON2 map[string]interface{}
  26459. if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  26460. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26461. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26462. return
  26463. }
  26464. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  26465. if err == nil {
  26466. c.ServeSuccessJSON(map[string]interface{}{
  26467. "msg": "撤销明细成功",
  26468. })
  26469. return
  26470. } else {
  26471. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26472. return
  26473. }
  26474. }
  26475. } else {
  26476. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  26477. if err == nil {
  26478. c.ServeSuccessJSON(map[string]interface{}{
  26479. "msg": "退费成功",
  26480. })
  26481. } else {
  26482. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26483. return
  26484. }
  26485. }
  26486. }
  26487. // 对账
  26488. func (c *HisApiController) GetCheckAccount() {
  26489. start_time := c.GetString("start_time")
  26490. end_time := c.GetString("end_time")
  26491. insutype := c.GetString("insutype")
  26492. clr_type := c.GetString("clr_type")
  26493. clr_org := c.GetString("clr_optins")
  26494. admin_user_id, _ := c.GetInt64("admin_user_id")
  26495. adminUser := c.GetAdminUserInfo()
  26496. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  26497. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  26498. if len(clr_org) == 0 {
  26499. clr_org = miConfig.InsuplcAdmdvs
  26500. }
  26501. timeLayout := "2006-01-02"
  26502. loc, _ := time.LoadLocation("Local")
  26503. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  26504. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  26505. orders, _ := service.GetOrderByTime(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type, miConfig.MdtrtareaAdmvs)
  26506. orders_two, _ := service.GetOrderByTimeFive(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type, miConfig.MdtrtareaAdmvs)
  26507. fixmedins_setl_cnt := int64(len(orders))
  26508. var medfee_sumamt float64
  26509. var acct_pay float64
  26510. var fund_pay_sumamt float64
  26511. for _, item := range orders {
  26512. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  26513. acct_pay = acct_pay + item.AcctPay
  26514. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  26515. }
  26516. var user_name string
  26517. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  26518. if role.ID == 0 {
  26519. user_name = "xxx"
  26520. } else {
  26521. user_name = role.UserName
  26522. }
  26523. var res ResultEight
  26524. var res10188 ResultEightFor10188
  26525. if config.IsOpen == 1 {
  26526. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  26527. api := "http://192.168.2.3:9532/" + "jsyb/3201?" +
  26528. "insutype=" + insutype +
  26529. "&clr_type=" + clr_type +
  26530. "&setl_optins=" + clr_org +
  26531. "&stmt_begndate=" + start_time +
  26532. "&stm_enddate=" + end_time +
  26533. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  26534. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  26535. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  26536. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt+int64(len(orders_two)*2), 10) +
  26537. "&fixmedins_code=" + miConfig.Code +
  26538. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  26539. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  26540. "&secret_key=" + miConfig.SecretKey +
  26541. "&org_name=" + miConfig.OrgName +
  26542. "&doctor=" + user_name +
  26543. "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  26544. fmt.Println(api)
  26545. resp, requestErr := http.Get(api)
  26546. if requestErr != nil {
  26547. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26548. return
  26549. }
  26550. body, ioErr := ioutil.ReadAll(resp.Body)
  26551. fmt.Println(body)
  26552. if ioErr != nil {
  26553. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26554. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26555. return
  26556. }
  26557. var respJSON map[string]interface{}
  26558. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  26559. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26560. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26561. return
  26562. }
  26563. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26564. userJSONBytes, _ := json.Marshal(respJSON)
  26565. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  26566. utils.ErrorLog("解析失败:%v", err)
  26567. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26568. return
  26569. }
  26570. res.InfRefmsgid = res10188.InfRefmsgid
  26571. res.Output = res10188.Output
  26572. res.ErrMsg = res10188.ErrMsg
  26573. res.Cainfo = res10188.Cainfo
  26574. res.WarnMsg = res10188.WarnMsg
  26575. infocode, _ := strconv.ParseInt(res10188.Infcode, 10, 64)
  26576. res.Infcode = infocode
  26577. } else if miConfig.MdtrtareaAdmvs == "150499" {
  26578. if clr_type != "9903" {
  26579. clr_type = "99" // 就诊 ID(来自2201接口返回)
  26580. }
  26581. api := "http://172.16.13.254:9532/" + "nmyb/3201?" +
  26582. "insutype=" + insutype +
  26583. "&clr_type=" + clr_type +
  26584. "&setl_optins=" + clr_org +
  26585. "&stmt_begndate=" + start_time +
  26586. "&stm_enddate=" + end_time +
  26587. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  26588. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  26589. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  26590. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt+int64(len(orders_two)*2), 10) +
  26591. "&fixmedins_code=" + miConfig.Code +
  26592. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  26593. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  26594. "&secret_key=" + miConfig.SecretKey +
  26595. "&org_name=" + miConfig.OrgName +
  26596. "&doctor=" + user_name
  26597. resp, requestErr := http.Get(api)
  26598. if requestErr != nil {
  26599. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26600. return
  26601. }
  26602. body, ioErr := ioutil.ReadAll(resp.Body)
  26603. if ioErr != nil {
  26604. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26605. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26606. return
  26607. }
  26608. var respJSON map[string]interface{}
  26609. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  26610. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26611. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26612. return
  26613. }
  26614. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26615. result, _ := json.Marshal(respJSON)
  26616. fmt.Println("log")
  26617. fmt.Println(string(result))
  26618. if err := json.Unmarshal([]byte(result), &res10188); err != nil {
  26619. utils.ErrorLog("解析失败:%v", err)
  26620. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26621. return
  26622. }
  26623. res.InfRefmsgid = res10188.InfRefmsgid
  26624. res.Output = res10188.Output
  26625. res.ErrMsg = res10188.ErrMsg
  26626. res.Cainfo = res10188.Cainfo
  26627. res.WarnMsg = res10188.WarnMsg
  26628. infocode, _ := strconv.ParseInt(res10188.Infcode, 10, 64)
  26629. res.Infcode = infocode
  26630. } else if miConfig.MdtrtareaAdmvs == "350500" {
  26631. var baseParams models.BaseParams
  26632. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  26633. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  26634. baseParams.SecretKey = miConfig.SecretKey
  26635. baseParams.OrgName = miConfig.OrgName
  26636. baseParams.FixmedinsCode = miConfig.Code
  26637. baseParams.EncKey = miConfig.EncKey
  26638. baseParams.AppSecret = miConfig.AppSecret
  26639. baseParams.SignKey = miConfig.SignKey
  26640. baseParams.AppID = miConfig.Code
  26641. baseParams.Doctor = role.UserName
  26642. baseParams.RequestUrl = miConfig.Url
  26643. businessParams := models.BusinessParams{
  26644. Insutype: insutype,
  26645. ClrType: clr_type,
  26646. SetlOptins: clr_org,
  26647. StmtBegndate: start_time,
  26648. StmtEnddate: end_time,
  26649. MedfeeSumamt: medfee_sumamt,
  26650. FundPaySumamt: fund_pay_sumamt,
  26651. AcctPay: acct_pay,
  26652. FixmedinsSetlCnt: fixmedins_setl_cnt,
  26653. }
  26654. result, requestLog, err_msg := service.FJyb3201(baseParams, businessParams, fmt.Sprintf("%.4f", medfee_sumamt), fmt.Sprintf("%.4f", fund_pay_sumamt), fmt.Sprintf("%.4f", acct_pay))
  26655. fmt.Println(requestLog)
  26656. fmt.Println(result)
  26657. fmt.Println(err_msg)
  26658. var dat map[string]interface{}
  26659. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  26660. fmt.Println(dat)
  26661. } else {
  26662. fmt.Println(err)
  26663. }
  26664. userJSONBytes, _ := json.Marshal(dat)
  26665. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  26666. utils.ErrorLog("解析失败:%v", err)
  26667. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26668. return
  26669. }
  26670. } else if miConfig.MdtrtareaAdmvs == "430800" {
  26671. var baseParams models.BaseParams
  26672. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  26673. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  26674. baseParams.SecretKey = miConfig.SecretKey
  26675. baseParams.OrgName = miConfig.OrgName
  26676. baseParams.FixmedinsCode = miConfig.Code
  26677. baseParams.EncKey = miConfig.EncKey
  26678. baseParams.AppSecret = miConfig.AppSecret
  26679. baseParams.SignKey = miConfig.SignKey
  26680. baseParams.AppID = miConfig.Code
  26681. baseParams.Doctor = role.UserName
  26682. baseParams.RequestUrl = miConfig.Url
  26683. baseParams.AccessKey = miConfig.AccessKey
  26684. businessParams := models.BusinessParams{
  26685. Insutype: insutype,
  26686. ClrType: clr_type,
  26687. SetlOptins: "430822",
  26688. StmtBegndate: start_time,
  26689. StmtEnddate: end_time,
  26690. MedfeeSumamt: medfee_sumamt,
  26691. FundPaySumamt: fund_pay_sumamt,
  26692. AcctPay: acct_pay,
  26693. FixmedinsSetlCnt: fixmedins_setl_cnt,
  26694. }
  26695. 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)
  26696. fmt.Println(requestLog)
  26697. fmt.Println(result)
  26698. var dat map[string]interface{}
  26699. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  26700. fmt.Println(dat)
  26701. } else {
  26702. fmt.Println(err)
  26703. }
  26704. userJSONBytes, _ := json.Marshal(dat)
  26705. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  26706. utils.ErrorLog("解析失败:%v", err)
  26707. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26708. return
  26709. }
  26710. } else if miConfig.MdtrtareaAdmvs == "350500" {
  26711. var baseParams models.BaseParams
  26712. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  26713. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  26714. baseParams.SecretKey = miConfig.SecretKey
  26715. baseParams.OrgName = miConfig.OrgName
  26716. baseParams.FixmedinsCode = miConfig.Code
  26717. baseParams.EncKey = miConfig.EncKey
  26718. baseParams.AppSecret = miConfig.AppSecret
  26719. baseParams.SignKey = miConfig.SignKey
  26720. baseParams.AppID = miConfig.Code
  26721. baseParams.Doctor = role.UserName
  26722. baseParams.RequestUrl = miConfig.Url
  26723. businessParams := models.BusinessParams{
  26724. Insutype: insutype,
  26725. ClrType: clr_type,
  26726. SetlOptins: clr_org,
  26727. StmtBegndate: start_time,
  26728. StmtEnddate: end_time,
  26729. MedfeeSumamt: medfee_sumamt,
  26730. FundPaySumamt: fund_pay_sumamt,
  26731. AcctPay: acct_pay,
  26732. FixmedinsSetlCnt: fixmedins_setl_cnt,
  26733. }
  26734. result, requestLog, err_msg := service.FJyb3201(baseParams, businessParams, fmt.Sprintf("%.4f", medfee_sumamt), fmt.Sprintf("%.4f", fund_pay_sumamt), fmt.Sprintf("%.4f", acct_pay))
  26735. fmt.Println(requestLog)
  26736. fmt.Println(result)
  26737. fmt.Println(err_msg)
  26738. var dat map[string]interface{}
  26739. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  26740. fmt.Println(dat)
  26741. } else {
  26742. fmt.Println(err)
  26743. }
  26744. userJSONBytes, _ := json.Marshal(dat)
  26745. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  26746. utils.ErrorLog("解析失败:%v", err)
  26747. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26748. return
  26749. }
  26750. } else if miConfig.MdtrtareaAdmvs == "441799" {
  26751. if len(clr_type) == 0 {
  26752. clr_type = "11"
  26753. }
  26754. api := miConfig.Url + "gdyb/ten?" +
  26755. "insutype=" + insutype +
  26756. "&clr_type=" + clr_type +
  26757. "&setl_optins=" + clr_org +
  26758. "&stmt_begndate=" + start_time +
  26759. "&stm_enddate=" + end_time +
  26760. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  26761. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  26762. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  26763. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  26764. "&fixmedins_code=" + miConfig.Code +
  26765. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  26766. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  26767. "&secret_key=" + miConfig.SecretKey +
  26768. "&org_name=" + miConfig.OrgName +
  26769. "&doctor=" + user_name
  26770. fmt.Println(api)
  26771. resp, requestErr := http.Get(api)
  26772. if requestErr != nil {
  26773. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26774. return
  26775. }
  26776. body, ioErr := ioutil.ReadAll(resp.Body)
  26777. fmt.Println(body)
  26778. if ioErr != nil {
  26779. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26780. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26781. return
  26782. }
  26783. var respJSON map[string]interface{}
  26784. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  26785. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26786. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26787. return
  26788. }
  26789. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26790. userJSONBytes, _ := json.Marshal(respJSON)
  26791. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  26792. utils.ErrorLog("解析失败:%v", err)
  26793. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26794. return
  26795. }
  26796. } else if miConfig.MdtrtareaAdmvs == "360302" {
  26797. var baseParams models.BaseParams
  26798. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  26799. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  26800. baseParams.SecretKey = miConfig.SecretKey
  26801. baseParams.OrgName = miConfig.OrgName
  26802. baseParams.FixmedinsCode = miConfig.Code
  26803. baseParams.EncKey = miConfig.EncKey
  26804. baseParams.AppSecret = miConfig.AppSecret
  26805. baseParams.SignKey = miConfig.SignKey
  26806. baseParams.AppID = miConfig.Code
  26807. baseParams.Doctor = role.UserName
  26808. baseParams.RequestUrl = miConfig.Url
  26809. if clr_type == "9903" {
  26810. clr_type = "9901"
  26811. }
  26812. businessParams := models.BusinessParams{
  26813. Insutype: insutype,
  26814. ClrType: clr_type,
  26815. SetlOptins: "360302",
  26816. StmtBegndate: start_time,
  26817. StmtEnddate: end_time,
  26818. MedfeeSumamt: 0,
  26819. FundPaySumamt: 0,
  26820. AcctPay: 0,
  26821. FixmedinsSetlCnt: fixmedins_setl_cnt,
  26822. }
  26823. 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))
  26824. fmt.Println(requestLog)
  26825. fmt.Println(result)
  26826. var dat map[string]interface{}
  26827. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  26828. fmt.Println(dat)
  26829. } else {
  26830. fmt.Println(err)
  26831. }
  26832. userJSONBytes, _ := json.Marshal(dat)
  26833. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  26834. utils.ErrorLog("解析失败:%v", err)
  26835. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26836. return
  26837. }
  26838. } else if miConfig.MdtrtareaAdmvs == "341203" {
  26839. var api string
  26840. api = miConfig.SecretKey + "ahyb/3201?insutype=" + insutype +
  26841. "&clr_type=" + clr_type +
  26842. "&setl_optins=" + clr_org +
  26843. "&stmt_begndate=" + start_time +
  26844. "&stm_enddate=" + end_time +
  26845. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  26846. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  26847. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  26848. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt+int64(len(orders_two)*2), 10) +
  26849. "&fixmedins_code=" + miConfig.Code +
  26850. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  26851. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  26852. "&secret_key=" + miConfig.SecretKey +
  26853. "&org_name=" + miConfig.OrgName +
  26854. "&doctor=" + user_name + "&url=" + miConfig.Url
  26855. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  26856. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  26857. resp, requestErr := http.Get(api)
  26858. if requestErr != nil {
  26859. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26860. return
  26861. }
  26862. body, ioErr := ioutil.ReadAll(resp.Body)
  26863. if ioErr != nil {
  26864. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26865. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26866. return
  26867. }
  26868. var respJSON map[string]interface{}
  26869. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  26870. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26871. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26872. return
  26873. }
  26874. status := respJSON["data"].(map[string]interface{})["status"].(string)
  26875. if status == "0" {
  26876. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  26877. c.ServeSuccessJSON(map[string]interface{}{
  26878. "failed_code": -10,
  26879. "msg": err_msg,
  26880. })
  26881. return
  26882. }
  26883. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26884. userJSONBytes, _ := json.Marshal(respJSON)
  26885. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  26886. utils.ErrorLog("解析失败:%v", err)
  26887. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26888. return
  26889. }
  26890. } else {
  26891. if len(clr_type) == 0 {
  26892. clr_type = "11"
  26893. }
  26894. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  26895. "insutype=" + insutype +
  26896. "&clr_type=" + clr_type +
  26897. "&setl_optins=" + clr_org +
  26898. "&stmt_begndate=" + start_time +
  26899. "&stm_enddate=" + end_time +
  26900. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  26901. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  26902. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  26903. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  26904. "&fixmedins_code=" + miConfig.Code +
  26905. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  26906. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  26907. "&secret_key=" + miConfig.SecretKey +
  26908. "&org_name=" + miConfig.OrgName +
  26909. "&doctor=" + user_name + "&admin_user_id=" + strconv.FormatInt(admin_user_id, 10)
  26910. fmt.Println(api)
  26911. resp, requestErr := http.Get(api)
  26912. if requestErr != nil {
  26913. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26914. return
  26915. }
  26916. body, ioErr := ioutil.ReadAll(resp.Body)
  26917. fmt.Println(body)
  26918. if ioErr != nil {
  26919. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26920. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26921. return
  26922. }
  26923. var respJSON map[string]interface{}
  26924. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  26925. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26926. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26927. return
  26928. }
  26929. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26930. userJSONBytes, _ := json.Marshal(respJSON)
  26931. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  26932. utils.ErrorLog("解析失败:%v", err)
  26933. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26934. return
  26935. }
  26936. }
  26937. if res.Infcode == 0 {
  26938. if res.Output.Stmtinfo.StmtRslt == "0" {
  26939. micc := &models.MedicalInsuranceCostCompare{
  26940. StartTime: startime.Unix(),
  26941. EndTime: endtime.Unix(),
  26942. Insutype: insutype,
  26943. CheckType: 1,
  26944. Num: fixmedins_setl_cnt,
  26945. Mtime: time.Now().Unix(),
  26946. Status: 1,
  26947. UserOrgId: adminUser.CurrentOrgId,
  26948. CostTotal: medfee_sumamt,
  26949. FuncTotal: fund_pay_sumamt,
  26950. PsnPay: acct_pay,
  26951. Creator: admin_user_id,
  26952. Ctime: time.Now().Unix(),
  26953. ClrType: clr_type,
  26954. }
  26955. err := service.CreateMedicalInsuranceCostCompareRecord(micc)
  26956. if err == nil {
  26957. c.ServeSuccessJSON(map[string]interface{}{
  26958. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  26959. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  26960. })
  26961. } else {
  26962. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26963. }
  26964. } else {
  26965. c.ServeSuccessJSON(map[string]interface{}{
  26966. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  26967. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  26968. })
  26969. }
  26970. } else {
  26971. c.ServeSuccessJSON(map[string]interface{}{
  26972. "failed_code": -10,
  26973. "msg": res.ErrMsg,
  26974. })
  26975. }
  26976. }
  26977. }
  26978. func (c *HisApiController) Check310() {
  26979. adminUser := c.GetAdminUserInfo()
  26980. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  26981. var user_name string
  26982. user_name = "高慧裕"
  26983. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  26984. "insutype=" + "310" +
  26985. "&clr_type=" + "" +
  26986. "&setl_optins=" + "441202" +
  26987. "&stmt_begndate=" + "2022-03-01" +
  26988. "&stm_enddate=" + "2022-03-31" +
  26989. "&medfee_sumamt=" + "194930.12" +
  26990. "&fund_pay_sumamt=" + "188741.46" +
  26991. "&acct_pay=" + "0" +
  26992. "&fixmedins_setl_cnt=" + "452" +
  26993. "&fixmedins_code=" + miConfig.Code +
  26994. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  26995. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  26996. "&secret_key=" + miConfig.SecretKey +
  26997. "&org_name=" + miConfig.OrgName +
  26998. "&doctor=" + user_name
  26999. fmt.Println(api)
  27000. resp, requestErr := http.Get(api)
  27001. if requestErr != nil {
  27002. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27003. return
  27004. }
  27005. body, ioErr := ioutil.ReadAll(resp.Body)
  27006. fmt.Println(body)
  27007. if ioErr != nil {
  27008. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27009. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27010. return
  27011. }
  27012. var respJSON map[string]interface{}
  27013. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27014. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27015. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27016. return
  27017. }
  27018. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27019. userJSONBytes, _ := json.Marshal(respJSON)
  27020. var res ResultEight
  27021. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27022. utils.ErrorLog("解析失败:%v", err)
  27023. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27024. return
  27025. }
  27026. }
  27027. func (c *HisApiController) Check390() {
  27028. adminUser := c.GetAdminUserInfo()
  27029. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  27030. var user_name string
  27031. user_name = "高慧裕"
  27032. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  27033. "insutype=" + "390" +
  27034. "&clr_type=" + "" +
  27035. "&setl_optins=" + "441202" +
  27036. "&stmt_begndate=" + "2022-03-01" +
  27037. "&stm_enddate=" + "2022-03-31" +
  27038. "&medfee_sumamt=" + "1068448.89" +
  27039. "&fund_pay_sumamt=" + "1014677.62" +
  27040. "&acct_pay=" + "0" +
  27041. "&fixmedins_setl_cnt=" + "1950" +
  27042. "&fixmedins_code=" + miConfig.Code +
  27043. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  27044. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  27045. "&secret_key=" + miConfig.SecretKey +
  27046. "&org_name=" + miConfig.OrgName +
  27047. "&doctor=" + user_name
  27048. fmt.Println(api)
  27049. resp, requestErr := http.Get(api)
  27050. if requestErr != nil {
  27051. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27052. return
  27053. }
  27054. body, ioErr := ioutil.ReadAll(resp.Body)
  27055. fmt.Println(body)
  27056. if ioErr != nil {
  27057. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27058. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27059. return
  27060. }
  27061. var respJSON map[string]interface{}
  27062. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27063. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27064. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27065. return
  27066. }
  27067. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27068. userJSONBytes, _ := json.Marshal(respJSON)
  27069. var res ResultEight
  27070. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27071. utils.ErrorLog("解析失败:%v", err)
  27072. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27073. return
  27074. }
  27075. }
  27076. // 对账明细
  27077. func (c *HisApiController) GetCheckDetailAccount() {
  27078. start_time := c.GetString("start_time")
  27079. end_time := c.GetString("end_time")
  27080. admin_user_id, _ := c.GetInt64("admin_user_id")
  27081. adminUser := c.GetAdminUserInfo()
  27082. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  27083. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  27084. timeLayout := "2006-01-02"
  27085. loc, _ := time.LoadLocation("Local")
  27086. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  27087. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  27088. orders, _ := service.GetOrderByTimeTwo(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  27089. rand.Seed(time.Now().UnixNano())
  27090. num := rand.Intn(30000)
  27091. Mkdir(miConfig.OrgName)
  27092. file := strconv.FormatInt(int64(num), 10)
  27093. file_name := file + ".txt"
  27094. zip_name := file + ".zip"
  27095. zip_path := miConfig.OrgName + "/" + zip_name
  27096. file_path := miConfig.OrgName + "/" + file_name
  27097. decimal.DivisionPrecision = 2
  27098. var medfee_sumamt float64
  27099. var psn_cash_pay float64
  27100. var fund_pay_sumamt float64
  27101. fixmedins_setl_cnt := int64(len(orders))
  27102. for _, item := range orders {
  27103. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  27104. psn_cash_pay = psn_cash_pay + item.PsnCashPay
  27105. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  27106. }
  27107. f, err := os.Create(miConfig.OrgName + "/" + file_name)
  27108. defer f.Close()
  27109. if err != nil {
  27110. fmt.Println(err.Error())
  27111. } else {
  27112. for _, item := range orders {
  27113. var refd_setl_flag string
  27114. if item.OrderStatus == 2 {
  27115. refd_setl_flag = "0"
  27116. var str string
  27117. str = item.SetlId + " " +
  27118. item.MdtrtId + " " +
  27119. item.PsnNo + " " +
  27120. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  27121. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  27122. fmt.Sprintf("%.4f", item.AcctPay) + " " + refd_setl_flag + "\r\n"
  27123. _, err = f.Write([]byte(str))
  27124. }
  27125. if item.OrderStatus == 3 {
  27126. var str string
  27127. str = item.SetlId + " " +
  27128. item.MdtrtId + " " +
  27129. item.PsnNo + " " +
  27130. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  27131. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  27132. fmt.Sprintf("%.4f", item.AcctPay) + " " + "1" + "\r\n"
  27133. _, err = f.Write([]byte(str))
  27134. var str2 string
  27135. str2 = item.SetlId + " " +
  27136. item.MdtrtId + " " +
  27137. item.PsnNo + " " +
  27138. fmt.Sprintf("%.4f", 0-item.MedfeeSumamt) + " " +
  27139. fmt.Sprintf("%.4f", 0-item.FundPaySumamt) + " " +
  27140. fmt.Sprintf("%.4f", 0-item.AcctPay) + " " + "1" + "\r\n"
  27141. _, err = f.Write([]byte(str2))
  27142. }
  27143. }
  27144. }
  27145. Zip(file_path, zip_path)
  27146. fmt.Println(ReadFile(zip_path))
  27147. fmt.Println(string(ReadFile(zip_path)))
  27148. if config.IsOpen == 1 {
  27149. var user_name string
  27150. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  27151. if role.ID == 0 {
  27152. user_name = "管理员"
  27153. } else {
  27154. user_name = role.UserName
  27155. }
  27156. baseParams := models.BaseParams{
  27157. SecretKey: miConfig.SecretKey,
  27158. FixmedinsCode: miConfig.Code,
  27159. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  27160. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  27161. OrgName: miConfig.OrgName,
  27162. Doctor: user_name,
  27163. }
  27164. result := service.Gdyb9101(baseParams, file_name, ReadFile(file_path))
  27165. var dat map[string]interface{}
  27166. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  27167. fmt.Println(dat)
  27168. } else {
  27169. fmt.Println(err)
  27170. }
  27171. userJSONBytes, _ := json.Marshal(dat)
  27172. var res ResultNine
  27173. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27174. utils.ErrorLog("解析失败:%v", err)
  27175. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27176. return
  27177. }
  27178. if res.Infcode == 0 {
  27179. fileNo := res.Output.FileQuryNo
  27180. api := "http://127.0.0.1:9532/" + "gdyb/twelve?" +
  27181. "file_qury_no=" + fileNo +
  27182. "&setl_optins=" + "定点医保中心" +
  27183. "&stmt_begndate=" + start_time +
  27184. "&stm_enddate=" + end_time +
  27185. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  27186. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  27187. "&cash_payamt=" + fmt.Sprintf("%.4f", psn_cash_pay) +
  27188. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  27189. "&fixmedins_code=" + miConfig.Code +
  27190. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  27191. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  27192. "&secret_key=" + miConfig.SecretKey +
  27193. "&org_name=" + miConfig.OrgName +
  27194. "&doctor=" + user_name
  27195. resp, requestErr := http.Get(api)
  27196. if requestErr != nil {
  27197. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27198. return
  27199. }
  27200. body, ioErr := ioutil.ReadAll(resp.Body)
  27201. if ioErr != nil {
  27202. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27203. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27204. return
  27205. }
  27206. var respJSON map[string]interface{}
  27207. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27208. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27209. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27210. return
  27211. }
  27212. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27213. userJSONBytes, _ := json.Marshal(respJSON)
  27214. var res ResultTen
  27215. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27216. utils.ErrorLog("解析失败:%v", err)
  27217. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27218. return
  27219. }
  27220. if res.Infcode == 0 {
  27221. service.Gdyb9102(baseParams, res.Output.Fileinfo.Filename, res.Output.Fileinfo.FileQuryNo)
  27222. micc := &models.MedicalInsuranceCostCompare{
  27223. StartTime: startime.Unix(),
  27224. EndTime: endtime.Unix(),
  27225. Insutype: "0",
  27226. CheckType: 2,
  27227. Num: fixmedins_setl_cnt,
  27228. Mtime: time.Now().Unix(),
  27229. Status: 1,
  27230. UserOrgId: adminUser.CurrentOrgId,
  27231. CostTotal: medfee_sumamt,
  27232. FuncTotal: fund_pay_sumamt,
  27233. PsnPay: psn_cash_pay,
  27234. Creator: admin_user_id,
  27235. Ctime: time.Now().Unix(),
  27236. }
  27237. service.CreateMedicalInsuranceCostCompareRecord(micc)
  27238. c.ServeSuccessJSON(map[string]interface{}{
  27239. "msg": "明细对账成功",
  27240. })
  27241. }
  27242. } else {
  27243. }
  27244. }
  27245. }
  27246. type CustomOrderInfo struct {
  27247. Name string
  27248. Spec string
  27249. Unit string
  27250. Count float64
  27251. Price float64
  27252. Total float64
  27253. }
  27254. func (c *HisApiController) GetBatchSettleAccounts() {
  27255. admin_user_id, _ := c.GetInt64("admin_user_id")
  27256. order_ids := c.GetString("order_ids")
  27257. order_ids_arr := strings.Split(order_ids, ",")
  27258. data3 := []map[string]interface{}{}
  27259. for _, item := range order_ids_arr {
  27260. id, _ := strconv.ParseInt(item, 10, 64)
  27261. order_id := id
  27262. adminUser := c.GetAdminUserInfo()
  27263. order, _ := service.GetHisOrderByID(order_id)
  27264. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  27265. orderInfos, _ := service.GetHisOrderInfoByNumber(order.Number)
  27266. orderInfos_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  27267. orderInfos = append(orderInfos, orderInfos_two...)
  27268. his_hospital, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  27269. //diagnosisConfig, _ := service.FindDiagnoseById(his.Diagnosis)
  27270. var diagnosis_ids []string
  27271. if his.ID > 0 {
  27272. diagnosis_ids = strings.Split(his.Diagnosis, ",")
  27273. } else {
  27274. diagnosis_ids = strings.Split(his_hospital.Diagnosis, ",")
  27275. }
  27276. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, order.PatientId)
  27277. var dia_config []*models.HisXtDiagnoseConfig
  27278. var name string
  27279. for _, item := range diagnosis_ids {
  27280. id, _ := strconv.ParseInt(item, 10, 64)
  27281. diagnosisConfig, _ := service.FindDiagnoseById(id)
  27282. dia_config = append(dia_config, &diagnosisConfig)
  27283. if len(name) == 0 {
  27284. name = diagnosisConfig.ClassName
  27285. }
  27286. //} else {
  27287. // name = name + "," + diagnosisConfig.ClassName
  27288. //}
  27289. }
  27290. var bedCostTotal float64 = 0 //床位总费
  27291. var bedCostSelfTotal float64 = 0 //床位自费
  27292. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  27293. var bedSelfTotal float64 = 0 //床位部分项目自费
  27294. var bedInscpTotal float64 = 0 //床位部分项目自费
  27295. var operationCostTotal float64 = 0 //手术费
  27296. var operationCostSelfTotal float64 = 0 //手术费
  27297. var operationCostPartSelfTotal float64 = 0 //手术费
  27298. var operationSelfTotal float64 = 0 //床位部分项目自费
  27299. var operationInscpTotal float64 = 0 //床位部分项目自费
  27300. var otherCostTotal float64 = 0 //其他费用
  27301. var otherCostSelfTotal float64 = 0 //其他费用
  27302. var otherCostPartSelfTotal float64 = 0 //其他费用
  27303. var otherSelfTotal float64 = 0 //床位部分项目自费
  27304. var otherInscpTotal float64 = 0 //床位部分项目自费
  27305. var materialCostTotal float64 = 0 //材料费
  27306. var materialCostSelfTotal float64 = 0 //材料费
  27307. var materialCostPartSelfTotal float64 = 0 //材料费
  27308. var materialSelfTotal float64 = 0 //床位部分项目自费
  27309. var materialInscpTotal float64 = 0 //床位部分项目自费
  27310. var westernMedicineCostTotal float64 = 0 //西药费
  27311. var westernMedicineCostSelfTotal float64 = 0 //西药费
  27312. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  27313. var westernMedicineSelfTotal float64 = 0 //床位部分项目自费
  27314. var westernMedicineInscpTotal float64 = 0 //床位部分项目自费
  27315. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  27316. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  27317. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  27318. var chineseTraditionalSelfTotal float64 = 0 //床位部分项目自费
  27319. var chineseTraditionalInscpTotal float64 = 0 //床位部分项目自费
  27320. var checkCostTotal float64 = 0 //检查费
  27321. var checkCostSelfTotal float64 = 0 //检查费
  27322. var checkCostPartSelfTotal float64 = 0 //检查费
  27323. var checkSelfTotal float64 = 0 //床位部分项目自费
  27324. var checkInscpTotal float64 = 0 //床位部分项目自费
  27325. var laboratoryCostTotal float64 = 0 //化验费
  27326. var laboratoryCostSelfTotal float64 = 0 //化验费
  27327. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  27328. var laboratorySelfTotal float64 = 0 //床位部分项目自费
  27329. var laboratoryInscpTotal float64 = 0 //床位部分项目自费
  27330. var treatCostTotal float64 = 0 //治疗费用
  27331. var treatCostSelfTotal float64 = 0 //治疗费用
  27332. var treatCostPartSelfTotal float64 = 0 //治疗费用
  27333. var treatSelfTotal float64 = 0 //床位部分项目自费
  27334. var treatInscpTotal float64 = 0 //床位部分项目自费
  27335. decimal.DivisionPrecision = 2
  27336. for _, item := range orderInfos {
  27337. if item.MedChrgitmType == "01" { //床位费
  27338. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  27339. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  27340. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  27341. bedSelfTotal, _ = decimal.NewFromFloat(bedSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  27342. bedInscpTotal, _ = decimal.NewFromFloat(bedInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  27343. }
  27344. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  27345. if item.MedChrgitmType == "03" { //检查费
  27346. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  27347. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  27348. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  27349. laboratorySelfTotal, _ = decimal.NewFromFloat(laboratorySelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  27350. laboratoryInscpTotal, _ = decimal.NewFromFloat(laboratoryInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  27351. }
  27352. } else {
  27353. if item.MedChrgitmType == "03" && adminUser.CurrentOrgId == 9504 { //手术费
  27354. fmt.Println("------------")
  27355. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  27356. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  27357. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  27358. }
  27359. if item.MedChrgitmType == "03" && adminUser.CurrentOrgId != 9504 { //手术费
  27360. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  27361. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  27362. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  27363. checkSelfTotal, _ = decimal.NewFromFloat(checkSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  27364. checkInscpTotal, _ = decimal.NewFromFloat(checkInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  27365. }
  27366. }
  27367. if item.MedChrgitmType == "04" { //化验费
  27368. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  27369. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  27370. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  27371. laboratorySelfTotal, _ = decimal.NewFromFloat(laboratorySelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  27372. laboratoryInscpTotal, _ = decimal.NewFromFloat(laboratoryInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  27373. }
  27374. if item.MedChrgitmType == "05" { //治疗费
  27375. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  27376. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  27377. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  27378. treatSelfTotal, _ = decimal.NewFromFloat(treatSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  27379. treatInscpTotal, _ = decimal.NewFromFloat(treatInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  27380. }
  27381. if item.MedChrgitmType == "06" && adminUser.CurrentOrgId == 9504 { //手术费
  27382. fmt.Println("------------")
  27383. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  27384. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  27385. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  27386. }
  27387. if item.MedChrgitmType == "06" && adminUser.CurrentOrgId != 9504 { //手术费
  27388. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  27389. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  27390. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  27391. }
  27392. //if item.MedChrgitmType == "06" { //手术费
  27393. // operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  27394. // operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  27395. // operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  27396. // operationSelfTotal, _ = decimal.NewFromFloat(operationSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  27397. // operationInscpTotal, _ = decimal.NewFromFloat(operationInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  27398. //
  27399. //}
  27400. if item.MedChrgitmType == "08" || item.MedChrgitmType == "1402" || item.MedChrgitmType == "1403" { //材料费
  27401. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  27402. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  27403. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  27404. materialSelfTotal, _ = decimal.NewFromFloat(materialSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  27405. materialInscpTotal, _ = decimal.NewFromFloat(materialInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  27406. }
  27407. if item.MedChrgitmType == "09" { //西药费
  27408. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  27409. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  27410. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  27411. westernMedicineSelfTotal, _ = decimal.NewFromFloat(westernMedicineSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  27412. westernMedicineInscpTotal, _ = decimal.NewFromFloat(westernMedicineInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  27413. }
  27414. if item.MedChrgitmType == "11" { //中成费
  27415. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  27416. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  27417. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  27418. chineseTraditionalSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  27419. chineseTraditionalInscpTotal, _ = decimal.NewFromFloat(chineseTraditionalInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  27420. }
  27421. if item.MedChrgitmType == "14" || item.MedChrgitmType == "0" || item.MedChrgitmType == "12" || item.MedChrgitmType == "02" { //其他费
  27422. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  27423. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  27424. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  27425. otherSelfTotal, _ = decimal.NewFromFloat(otherSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  27426. otherInscpTotal, _ = decimal.NewFromFloat(otherInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  27427. }
  27428. }
  27429. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  27430. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  27431. var user_name string
  27432. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  27433. if role.ID == 0 {
  27434. user_name = "管理员"
  27435. } else {
  27436. user_name = role.UserName
  27437. }
  27438. baseParams := models.BaseParams{
  27439. SecretKey: miConfig.SecretKey,
  27440. FixmedinsCode: miConfig.Code,
  27441. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  27442. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  27443. OrgName: miConfig.OrgName,
  27444. Doctor: user_name,
  27445. RequestUrl: miConfig.Url,
  27446. AccessKey: miConfig.AccessKey,
  27447. }
  27448. businessParams := models.BusinessParams{
  27449. PsnNo: order.PsnNo,
  27450. MdtrtId: order.MdtrtId,
  27451. SetlId: order.SetlId,
  27452. }
  27453. var res ResultEleven
  27454. var resEleven10265 ResultEleven10265
  27455. if config.IsOpen == 1 {
  27456. baseParams.InsuplcAdmdvs = his.InsuplcAdmdvs
  27457. result := service.Gdyb5203(baseParams, businessParams)
  27458. service.Gdyb5204(baseParams, businessParams)
  27459. //service.Gdyb5302(businessParams.PsnNo, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs, baseParams.SecretKey)
  27460. var dat map[string]interface{}
  27461. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  27462. fmt.Println(dat)
  27463. } else {
  27464. fmt.Println(err)
  27465. }
  27466. userJSONBytes, _ := json.Marshal(dat)
  27467. if miConfig.Code == "H15049901371" {
  27468. if err := json.Unmarshal(userJSONBytes, &resEleven10265); err != nil {
  27469. utils.ErrorLog("解析失败:%v", err)
  27470. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27471. return
  27472. }
  27473. res.InfRefmsgid = resEleven10265.InfRefmsgid
  27474. res.Output = resEleven10265.Output
  27475. res.ErrMsg = resEleven10265.ErrMsg
  27476. res.Cainfo = resEleven10265.Cainfo
  27477. res.WarnMsg = resEleven10265.WarnMsg
  27478. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  27479. res.Infcode = infocode
  27480. } else {
  27481. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27482. utils.ErrorLog("解析失败:%v", err)
  27483. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27484. return
  27485. }
  27486. }
  27487. printor_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  27488. charge_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, order.Creator)
  27489. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, order.PatientId, order.SettleAccountsDate)
  27490. adminRole_two, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  27491. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, his_hospital.Doctor)
  27492. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  27493. var doctor_name string
  27494. if roles.ID == 0 {
  27495. doctor_name = "管理员"
  27496. } else {
  27497. doctor_name = roles.UserName
  27498. }
  27499. yiliao_leibie := ""
  27500. switch order.MedType {
  27501. case "11":
  27502. yiliao_leibie = "普通门诊"
  27503. break
  27504. case "12":
  27505. yiliao_leibie = "门诊挂号"
  27506. break
  27507. case "13":
  27508. yiliao_leibie = "急诊"
  27509. break
  27510. case "14":
  27511. yiliao_leibie = "门诊特殊病"
  27512. break
  27513. case "15":
  27514. yiliao_leibie = "门诊统筹"
  27515. break
  27516. case "16":
  27517. yiliao_leibie = "门诊慢性病"
  27518. break
  27519. case "21":
  27520. yiliao_leibie = "普通住院"
  27521. break
  27522. }
  27523. departments, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  27524. res.Output.Setlinfo.PsnCashPay = res.Output.Setlinfo.CashPayamt
  27525. if res.Infcode == 0 {
  27526. data2 := map[string]interface{}{
  27527. "diagnosis": name,
  27528. "order_infos": orderInfos,
  27529. "number": order.MdtrtId,
  27530. "date": order.SettleAccountsDate,
  27531. "charge_admin": charge_admin,
  27532. "printor_admin": printor_admin,
  27533. "info": res.Output.Setlinfo,
  27534. "order": order,
  27535. "bedCostTotal": bedCostTotal,
  27536. "bedCostSelfTotal": bedCostSelfTotal,
  27537. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  27538. "bedSelfTotal": bedSelfTotal,
  27539. "bedInscpTotal": bedInscpTotal,
  27540. "operationCostTotal": operationCostTotal,
  27541. "operationCostSelfTotal": operationCostSelfTotal,
  27542. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  27543. "operationSelfTotal": operationSelfTotal,
  27544. "operationInscpTotal": operationInscpTotal,
  27545. "otherCostTotal": otherCostTotal,
  27546. "otherCostSelfTotal": otherCostSelfTotal,
  27547. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  27548. "otherSelfTotal": otherSelfTotal,
  27549. "otherInscpTotal": otherInscpTotal,
  27550. "materialCostTotal": materialCostTotal,
  27551. "materialCostSelfTotal": materialCostSelfTotal,
  27552. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  27553. "materialSelfTotal": materialSelfTotal,
  27554. "materialInscpTotal": materialInscpTotal,
  27555. "westernMedicineCostTotal": westernMedicineCostTotal,
  27556. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  27557. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  27558. "westernMedicineSelfTotal": westernMedicineSelfTotal,
  27559. "westernMedicineInscpTotal": westernMedicineInscpTotal,
  27560. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  27561. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  27562. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  27563. "chineseTraditionalSelfTotal": chineseTraditionalSelfTotal,
  27564. "chineseTraditionalInscpTotal": chineseTraditionalInscpTotal,
  27565. "checkCostTotal": checkCostTotal,
  27566. "checkCostSelfTotal": checkCostSelfTotal,
  27567. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  27568. "checkSelfTotal": checkSelfTotal,
  27569. "checkInscpTotal": checkInscpTotal,
  27570. "laboratoryCostTotal": laboratoryCostTotal,
  27571. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  27572. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  27573. "laboratorySelfTotal": laboratorySelfTotal,
  27574. "laboratoryInscpTotal": laboratoryInscpTotal,
  27575. "treatCostTotal": treatCostTotal,
  27576. "treatCostSelfTotal": treatCostSelfTotal,
  27577. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  27578. "treatSelfTotal": treatSelfTotal,
  27579. "treatInscpTotal": treatInscpTotal,
  27580. "doctor_info": doctor_info,
  27581. "doctor_code": adminRole_two.DoctorCode,
  27582. "doctor_name": doctor_name,
  27583. "health_card_no": order.PsnNo,
  27584. "department": departments.Name,
  27585. "yiliao_leibie": yiliao_leibie,
  27586. "after_money": order.AccountPrice,
  27587. "patient": patient,
  27588. "org_name": miConfig.OrgName,
  27589. "org_code": miConfig.Code,
  27590. "order_number": order.Number,
  27591. "his_hospital": his_hospital,
  27592. "his": his,
  27593. "dia_config": dia_config,
  27594. "psn_cash_pay": order.PsnCashPay,
  27595. //"check_order_info": cus_slice,
  27596. }
  27597. data3 = append(data3, data2)
  27598. }
  27599. }
  27600. }
  27601. c.ServeSuccessJSON(map[string]interface{}{
  27602. "infos": data3,
  27603. })
  27604. }
  27605. func (c *HisApiController) GetSettleAccounts() {
  27606. //id, _ := c.GetInt64("id")
  27607. //record_time := c.GetString("record_time")
  27608. order_id, _ := c.GetInt64("order_id")
  27609. admin_user_id, _ := c.GetInt64("admin_user_id")
  27610. //timeLayout := "2006-01-02"
  27611. //loc, _ := time.LoadLocation("Local")
  27612. //
  27613. //theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  27614. //if err != nil {
  27615. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  27616. // return
  27617. //}Hbyb5203
  27618. //recordDateTime := theTime.Unix()
  27619. adminUser := c.GetAdminUserInfo()
  27620. order, _ := service.GetHisOrderByID(order_id)
  27621. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  27622. orderInfos, _ := service.GetHisOrderInfoByNumber(order.Number)
  27623. orderInfos_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  27624. orderInfos = append(orderInfos, orderInfos_two...)
  27625. his_hospital, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  27626. //diagnosisConfig, _ := service.FindDiagnoseById(his.Diagnosis)
  27627. var diagnosis_ids []string
  27628. if his.ID > 0 {
  27629. diagnosis_ids = strings.Split(his.Diagnosis, ",")
  27630. } else {
  27631. diagnosis_ids = strings.Split(his_hospital.Diagnosis, ",")
  27632. }
  27633. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, order.PatientId)
  27634. var dia_config []*models.HisXtDiagnoseConfig
  27635. var name string
  27636. for _, item := range diagnosis_ids {
  27637. id, _ := strconv.ParseInt(item, 10, 64)
  27638. diagnosisConfig, _ := service.FindDiagnoseById(id)
  27639. dia_config = append(dia_config, &diagnosisConfig)
  27640. if len(name) == 0 {
  27641. name = diagnosisConfig.ClassName
  27642. } else {
  27643. name = name + "," + diagnosisConfig.ClassName
  27644. }
  27645. }
  27646. if patient.UserOrgId == 10215 {
  27647. name = "慢性肾功能不全(血透治疗)"
  27648. }
  27649. var bedCostTotal float64 = 0 //床位总费
  27650. var bedCostSelfTotal float64 = 0 //床位自费
  27651. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  27652. var bedSelfTotal float64 = 0 //床位部分项目自费
  27653. var bedInscpTotal float64 = 0 //床位部分项目自费
  27654. var operationCostTotal float64 = 0 //手术费
  27655. var operationCostSelfTotal float64 = 0 //手术费
  27656. var operationCostPartSelfTotal float64 = 0 //手术费
  27657. var operationSelfTotal float64 = 0 //床位部分项目自费
  27658. var operationInscpTotal float64 = 0 //床位部分项目自费
  27659. var otherCostTotal float64 = 0 //其他费用
  27660. var otherCostSelfTotal float64 = 0 //其他费用
  27661. var otherCostPartSelfTotal float64 = 0 //其他费用
  27662. var otherSelfTotal float64 = 0 //床位部分项目自费
  27663. var otherInscpTotal float64 = 0 //床位部分项目自费
  27664. var materialCostTotal float64 = 0 //材料费
  27665. var materialCostSelfTotal float64 = 0 //材料费
  27666. var materialCostPartSelfTotal float64 = 0 //材料费
  27667. var materialSelfTotal float64 = 0 //床位部分项目自费
  27668. var materialInscpTotal float64 = 0 //床位部分项目自费
  27669. var westernMedicineCostTotal float64 = 0 //西药费
  27670. var westernMedicineCostSelfTotal float64 = 0 //西药费
  27671. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  27672. var westernMedicineSelfTotal float64 = 0 //床位部分项目自费
  27673. var westernMedicineInscpTotal float64 = 0 //床位部分项目自费
  27674. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  27675. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  27676. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  27677. var chineseTraditionalSelfTotal float64 = 0 //床位部分项目自费
  27678. var chineseTraditionalInscpTotal float64 = 0 //床位部分项目自费
  27679. var checkCostTotal float64 = 0 //检查费
  27680. var checkCostSelfTotal float64 = 0 //检查费
  27681. var checkCostPartSelfTotal float64 = 0 //检查费
  27682. var checkSelfTotal float64 = 0 //床位部分项目自费
  27683. var checkInscpTotal float64 = 0 //床位部分项目自费
  27684. var laboratoryCostTotal float64 = 0 //化验费
  27685. var laboratoryCostSelfTotal float64 = 0 //化验费
  27686. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  27687. var laboratorySelfTotal float64 = 0 //床位部分项目自费
  27688. var laboratoryInscpTotal float64 = 0 //床位部分项目自费
  27689. var treatCostTotal float64 = 0 //治疗费用
  27690. var treatCostSelfTotal float64 = 0 //治疗费用
  27691. var treatCostPartSelfTotal float64 = 0 //治疗费用
  27692. var treatSelfTotal float64 = 0 //床位部分项目自费
  27693. var treatInscpTotal float64 = 0 //床位部分项目自费
  27694. decimal.DivisionPrecision = 2
  27695. for _, item := range orderInfos {
  27696. if item.MedChrgitmType == "01" { //床位费
  27697. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  27698. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  27699. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  27700. bedSelfTotal, _ = decimal.NewFromFloat(bedSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  27701. bedInscpTotal, _ = decimal.NewFromFloat(bedInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  27702. }
  27703. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  27704. if item.MedChrgitmType == "03" { //检查费
  27705. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  27706. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  27707. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  27708. laboratorySelfTotal, _ = decimal.NewFromFloat(laboratorySelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  27709. laboratoryInscpTotal, _ = decimal.NewFromFloat(laboratoryInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  27710. }
  27711. } else {
  27712. if item.MedChrgitmType == "03" && adminUser.CurrentOrgId == 9504 { //手术费
  27713. fmt.Println("------------")
  27714. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  27715. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  27716. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  27717. }
  27718. if item.MedChrgitmType == "03" && adminUser.CurrentOrgId != 9504 { //手术费
  27719. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  27720. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  27721. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  27722. checkSelfTotal, _ = decimal.NewFromFloat(checkSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  27723. checkInscpTotal, _ = decimal.NewFromFloat(checkInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  27724. }
  27725. }
  27726. if item.MedChrgitmType == "04" { //化验费
  27727. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  27728. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  27729. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  27730. laboratorySelfTotal, _ = decimal.NewFromFloat(laboratorySelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  27731. laboratoryInscpTotal, _ = decimal.NewFromFloat(laboratoryInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  27732. }
  27733. if item.MedChrgitmType == "05" { //治疗费
  27734. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  27735. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  27736. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  27737. treatSelfTotal, _ = decimal.NewFromFloat(treatSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  27738. treatInscpTotal, _ = decimal.NewFromFloat(treatInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  27739. }
  27740. if item.MedChrgitmType == "06" && adminUser.CurrentOrgId == 9504 { //手术费
  27741. fmt.Println("------------")
  27742. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  27743. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  27744. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  27745. treatSelfTotal, _ = decimal.NewFromFloat(treatSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  27746. treatInscpTotal, _ = decimal.NewFromFloat(treatInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  27747. }
  27748. if item.MedChrgitmType == "06" && adminUser.CurrentOrgId != 9504 { //手术费
  27749. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  27750. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  27751. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  27752. operationSelfTotal, _ = decimal.NewFromFloat(operationSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  27753. operationInscpTotal, _ = decimal.NewFromFloat(operationInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  27754. }
  27755. if item.MedChrgitmType == "08" || item.MedChrgitmType == "1402" || item.MedChrgitmType == "1403" { //材料费
  27756. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  27757. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  27758. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  27759. materialSelfTotal, _ = decimal.NewFromFloat(materialSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  27760. materialInscpTotal, _ = decimal.NewFromFloat(materialInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  27761. }
  27762. if item.MedChrgitmType == "09" { //西药费
  27763. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  27764. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  27765. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  27766. westernMedicineSelfTotal, _ = decimal.NewFromFloat(westernMedicineSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  27767. westernMedicineInscpTotal, _ = decimal.NewFromFloat(westernMedicineInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  27768. }
  27769. if item.MedChrgitmType == "11" { //中成费
  27770. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  27771. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  27772. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  27773. chineseTraditionalSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  27774. chineseTraditionalInscpTotal, _ = decimal.NewFromFloat(chineseTraditionalInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  27775. }
  27776. if item.MedChrgitmType == "14" || item.MedChrgitmType == "0" || item.MedChrgitmType == "12" || item.MedChrgitmType == "02" { //其他费
  27777. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  27778. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  27779. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  27780. otherSelfTotal, _ = decimal.NewFromFloat(otherSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  27781. otherInscpTotal, _ = decimal.NewFromFloat(otherInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  27782. }
  27783. }
  27784. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  27785. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  27786. var user_name string
  27787. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  27788. if role.ID == 0 {
  27789. user_name = "管理员"
  27790. } else {
  27791. user_name = role.UserName
  27792. }
  27793. baseParams := models.BaseParams{
  27794. SecretKey: miConfig.SecretKey,
  27795. FixmedinsCode: miConfig.Code,
  27796. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  27797. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  27798. OrgName: miConfig.OrgName,
  27799. Doctor: user_name,
  27800. RequestUrl: miConfig.Url,
  27801. AccessKey: miConfig.AccessKey,
  27802. }
  27803. businessParams := models.BusinessParams{
  27804. PsnNo: order.PsnNo,
  27805. MdtrtId: order.MdtrtId,
  27806. SetlId: order.SetlId,
  27807. }
  27808. var res ResultEleven
  27809. var resah ResultElevenah
  27810. var resEleven10265 ResultEleven10265
  27811. if config.IsOpen == 1 {
  27812. if miConfig.MdtrtareaAdmvs == "421300" {
  27813. api := "http://192.168.124.4:9532/" + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  27814. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  27815. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  27816. resp, requestErr := http.Get(api)
  27817. if requestErr != nil {
  27818. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27819. return
  27820. }
  27821. body, ioErr := ioutil.ReadAll(resp.Body)
  27822. if ioErr != nil {
  27823. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27824. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27825. return
  27826. }
  27827. var respJSON map[string]interface{}
  27828. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27829. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27830. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27831. return
  27832. }
  27833. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27834. result, _ := json.Marshal(respJSON)
  27835. fmt.Println("log")
  27836. fmt.Println(string(result))
  27837. if err := json.Unmarshal([]byte(result), &res); err != nil {
  27838. utils.ErrorLog("解析失败:%v", err)
  27839. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27840. return
  27841. }
  27842. } else if miConfig.MdtrtareaAdmvs == "420200" {
  27843. api := "http://192.168.0.197:9532/" + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  27844. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  27845. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  27846. resp, requestErr := http.Get(api)
  27847. if requestErr != nil {
  27848. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27849. return
  27850. }
  27851. body, ioErr := ioutil.ReadAll(resp.Body)
  27852. if ioErr != nil {
  27853. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27854. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27855. return
  27856. }
  27857. var respJSON map[string]interface{}
  27858. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27859. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27860. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27861. return
  27862. }
  27863. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27864. result, _ := json.Marshal(respJSON)
  27865. fmt.Println("log")
  27866. fmt.Println(string(result))
  27867. if err := json.Unmarshal([]byte(result), &res); err != nil {
  27868. utils.ErrorLog("解析失败:%v", err)
  27869. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27870. return
  27871. }
  27872. } else if miConfig.MdtrtareaAdmvs == "420902" {
  27873. api := miConfig.Url + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  27874. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  27875. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  27876. resp, requestErr := http.Get(api)
  27877. if requestErr != nil {
  27878. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27879. return
  27880. }
  27881. body, ioErr := ioutil.ReadAll(resp.Body)
  27882. if ioErr != nil {
  27883. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27884. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27885. return
  27886. }
  27887. var respJSON map[string]interface{}
  27888. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27889. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27890. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27891. return
  27892. }
  27893. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27894. result, _ := json.Marshal(respJSON)
  27895. fmt.Println("log")
  27896. fmt.Println(string(result))
  27897. if err := json.Unmarshal([]byte(result), &res); err != nil {
  27898. utils.ErrorLog("解析失败:%v", err)
  27899. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27900. return
  27901. }
  27902. } else if miConfig.MdtrtareaAdmvs == "421182" {
  27903. api := miConfig.Url + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  27904. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  27905. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&med_type=" + order.MedType
  27906. resp, requestErr := http.Get(api)
  27907. if requestErr != nil {
  27908. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27909. return
  27910. }
  27911. body, ioErr := ioutil.ReadAll(resp.Body)
  27912. if ioErr != nil {
  27913. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27914. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27915. return
  27916. }
  27917. var respJSON map[string]interface{}
  27918. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27919. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27920. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27921. return
  27922. }
  27923. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27924. result, _ := json.Marshal(respJSON)
  27925. fmt.Println("log")
  27926. fmt.Println(string(result))
  27927. if err := json.Unmarshal([]byte(result), &res); err != nil {
  27928. utils.ErrorLog("解析失败:%v", err)
  27929. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27930. return
  27931. }
  27932. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  27933. var api string
  27934. if miConfig.MdtrtareaAdmvs == "320921" {
  27935. api = "http://192.168.2.3:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  27936. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  27937. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  27938. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  27939. } else {
  27940. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  27941. api = "http://192.168.5.251:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  27942. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  27943. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  27944. }
  27945. resp, requestErr := http.Get(api)
  27946. if requestErr != nil {
  27947. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27948. return
  27949. }
  27950. body, ioErr := ioutil.ReadAll(resp.Body)
  27951. if ioErr != nil {
  27952. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27953. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27954. return
  27955. }
  27956. var respJSON map[string]interface{}
  27957. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27958. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27959. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27960. return
  27961. }
  27962. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27963. result, _ := json.Marshal(respJSON)
  27964. fmt.Println("log")
  27965. fmt.Println(string(result))
  27966. if err := json.Unmarshal([]byte(result), &resEleven10265); err != nil {
  27967. utils.ErrorLog("解析失败:%v", err)
  27968. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27969. return
  27970. }
  27971. res.InfRefmsgid = resEleven10265.InfRefmsgid
  27972. res.Output = resEleven10265.Output
  27973. res.ErrMsg = resEleven10265.ErrMsg
  27974. res.Cainfo = resEleven10265.Cainfo
  27975. res.WarnMsg = resEleven10265.WarnMsg
  27976. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  27977. res.Infcode = infocode
  27978. } else if miConfig.MdtrtareaAdmvs == "350500" {
  27979. result, requestLog, _ := service.FJyb5203(baseParams, businessParams, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  27980. saveLog(result, requestLog, "5203", "结算单")
  27981. var dat map[string]interface{}
  27982. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  27983. fmt.Println(dat)
  27984. } else {
  27985. fmt.Println(err)
  27986. }
  27987. userJSONBytes, _ := json.Marshal(dat)
  27988. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27989. utils.ErrorLog("解析失败:%v", err)
  27990. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27991. return
  27992. }
  27993. } else if miConfig.MdtrtareaAdmvs == "360302" {
  27994. baseParams.InsuplcAdmdvs = his_hospital.InsuplcAdmdvs
  27995. result3, requestLog3 := service.Jxyb5201(baseParams, businessParams)
  27996. fmt.Println(result3)
  27997. fmt.Println(requestLog3)
  27998. result2, requestLog2 := service.Jxyb5202(baseParams, businessParams)
  27999. fmt.Println(result2)
  28000. fmt.Println(requestLog2)
  28001. result, requestLog := service.Jxyb5203(baseParams, businessParams)
  28002. saveLog(result, requestLog, "5203", "结算单")
  28003. var dat map[string]interface{}
  28004. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  28005. fmt.Println(dat)
  28006. } else {
  28007. fmt.Println(err)
  28008. }
  28009. userJSONBytes, _ := json.Marshal(dat)
  28010. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28011. utils.ErrorLog("解析失败:%v", err)
  28012. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28013. return
  28014. }
  28015. } else if miConfig.MdtrtareaAdmvs == "341203" {
  28016. var api string
  28017. api = miConfig.SecretKey + "ahyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  28018. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  28019. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  28020. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  28021. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  28022. resp, requestErr := http.Get(api)
  28023. if requestErr != nil {
  28024. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28025. return
  28026. }
  28027. body, ioErr := ioutil.ReadAll(resp.Body)
  28028. if ioErr != nil {
  28029. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28030. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28031. return
  28032. }
  28033. var respJSON map[string]interface{}
  28034. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  28035. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28036. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28037. return
  28038. }
  28039. status := respJSON["data"].(map[string]interface{})["status"].(string)
  28040. if status == "0" {
  28041. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  28042. c.ServeSuccessJSON(map[string]interface{}{
  28043. "failed_code": -10,
  28044. "msg": err_msg,
  28045. })
  28046. return
  28047. }
  28048. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28049. result, _ := json.Marshal(respJSON)
  28050. fmt.Println("log")
  28051. fmt.Println(string(result))
  28052. if err := json.Unmarshal([]byte(result), &resah); err != nil {
  28053. utils.ErrorLog("解析失败:%v", err)
  28054. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28055. return
  28056. }
  28057. res.InfRefmsgid = resah.InfRefmsgid
  28058. timestamp := int64(resah.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  28059. // 创建对应的Time类型
  28060. t := time.UnixMilli(timestamp)
  28061. // 格式化成指定的日期字符串
  28062. str := t.Format("2006-01-02 15:04:05")
  28063. timestamp2 := int64(resah.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  28064. // 创建对应的Time类型
  28065. t3 := time.UnixMilli(timestamp2)
  28066. // 格式化成指定的日期字符串
  28067. str2 := t3.Format("2006-01-02 15:04:05")
  28068. timestamp3 := int64(resah.Output.Setlinfo.Begndate) // 输入要转换的时间戳(这里仅作示例)
  28069. // 创建对应的Time类型
  28070. t4 := time.UnixMilli(timestamp3)
  28071. // 格式化成指定的日期字符串
  28072. str3 := t4.Format("2006-01-02 15:04:05")
  28073. timestamp4 := int64(resah.Output.Setlinfo.Enddate) // 输入要转换的时间戳(这里仅作示例)
  28074. // 创建对应的Time类型
  28075. t5 := time.UnixMilli(timestamp4)
  28076. // 格式化成指定的日期字符串
  28077. str5 := t5.Format("2006-01-02 15:04:05")
  28078. res.Output.Setlinfo.Brdy = str2
  28079. res.Output.Setlinfo.SetlTime = str
  28080. res.Output.Setlinfo.Begndate = str3
  28081. res.Output.Setlinfo.Enddate = str5
  28082. res.Output.Setlinfo.Year = resah.Output.Setlinfo.Year
  28083. res.Output.Setlinfo.PsnPay = resah.Output.Setlinfo.PsnPay
  28084. res.Output.Setlinfo.OpterID = resah.Output.Setlinfo.OpterID
  28085. res.Output.Setlinfo.FlxempeFlag = resah.Output.Setlinfo.FlxempeFlag
  28086. res.Output.Setlinfo.Gend = resah.Output.Setlinfo.Gend
  28087. res.Output.Setlinfo.MdtrtID = resah.Output.Setlinfo.MdtrtID
  28088. res.Output.Setlinfo.AcctMulaidPay = resah.Output.Setlinfo.AcctMulaidPay
  28089. res.Output.Setlinfo.AcctPay = resah.Output.Setlinfo.AcctPay
  28090. res.Output.Setlinfo.CvlservPay = resah.Output.Setlinfo.CvlservPay
  28091. res.Output.Setlinfo.ActPayDedc = resah.Output.Setlinfo.ActPayDedc
  28092. res.Output.Setlinfo.Age = resah.Output.Setlinfo.Age
  28093. res.Output.Setlinfo.Balc = resah.Output.Setlinfo.Balc
  28094. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  28095. res.Output.Setlinfo.Certno = resah.Output.Setlinfo.Certno
  28096. res.Output.Setlinfo.ClrOptins = resah.Output.Setlinfo.ClrOptins
  28097. res.Output.Setlinfo.ClrType = resah.Output.Setlinfo.ClrOptins
  28098. res.Output.Setlinfo.ClrWay = resah.Output.Setlinfo.ClrOptins
  28099. res.Output.Setlinfo.CvlservFlag = resah.Output.Setlinfo.ClrOptins
  28100. res.Output.Setlinfo.CvlservPay = resah.Output.Setlinfo.CvlservPay
  28101. res.Output.Setlinfo.FulamtOwnpayAmt = resah.Output.Setlinfo.FulamtOwnpayAmt
  28102. res.Output.Setlinfo.FundPaySumamt = resah.Output.Setlinfo.FundPaySumamt
  28103. res.Output.Setlinfo.Gend = resah.Output.Setlinfo.Gend
  28104. res.Output.Setlinfo.HifesPay = resah.Output.Setlinfo.HifesPay
  28105. res.Output.Setlinfo.HifmiPay = resah.Output.Setlinfo.HifmiPay
  28106. res.Output.Setlinfo.HifpPay = resah.Output.Setlinfo.HifpPay
  28107. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  28108. //res.Output.Setlinfo.HospPartAmt = resah.Output.Setlinfo.HospPartAmt
  28109. res.Output.Setlinfo.InscpScpAmt = resah.Output.Setlinfo.InscpScpAmt
  28110. res.Output.Setlinfo.Insutype = resah.Output.Setlinfo.Insutype
  28111. res.Output.Setlinfo.MafPay = resah.Output.Setlinfo.MafPay
  28112. //res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  28113. res.Output.Setlinfo.HifobPay = resah.Output.Setlinfo.HifobPay
  28114. res.Output.Setlinfo.MdtrtID = resah.Output.Setlinfo.MdtrtID
  28115. res.Output.Setlinfo.MedType = resah.Output.Setlinfo.MedType
  28116. res.Output.Setlinfo.MedfeeSumamt = resah.Output.Setlinfo.MedfeeSumamt
  28117. res.Output.Setlinfo.MedinsSetlID = resah.Output.Setlinfo.MedinsSetlID
  28118. res.Output.Setlinfo.Naty = resah.Output.Setlinfo.Naty
  28119. res.Output.Setlinfo.OthPay = resah.Output.Setlinfo.OthPay
  28120. res.Output.Setlinfo.OverlmtSelfpay = resah.Output.Setlinfo.OverlmtSelfpay
  28121. res.Output.Setlinfo.PoolPropSelfpay = resah.Output.Setlinfo.PoolPropSelfpay
  28122. res.Output.Setlinfo.PreselfpayAmt = resah.Output.Setlinfo.PreselfpayAmt
  28123. res.Output.Setlinfo.PsnCashPay = resah.Output.Setlinfo.PsnCashPay
  28124. res.Output.Setlinfo.PsnCertType = resah.Output.Setlinfo.ClrOptins
  28125. res.Output.Setlinfo.PsnName = resah.Output.Setlinfo.PsnName
  28126. res.Output.Setlinfo.PsnNo = resah.Output.Setlinfo.PsnNo
  28127. //res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  28128. res.Output.Setlinfo.PsnType = resah.Output.Setlinfo.PsnType
  28129. res.Output.Setlinfo.SetlID = resah.Output.Setlinfo.SetlID
  28130. //res.Output.Setldetail = resah.Output.Setldetail
  28131. res.ErrMsg = resah.ErrMsg
  28132. res.Cainfo = resah.Cainfo
  28133. res.WarnMsg = resah.WarnMsg
  28134. } else if miConfig.MdtrtareaAdmvs == "430800" {
  28135. result, requestLog := service.Hnyb5203(baseParams, businessParams)
  28136. saveLog(result, requestLog, "5203", "结算单")
  28137. var dat map[string]interface{}
  28138. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  28139. fmt.Println(dat)
  28140. } else {
  28141. fmt.Println(err)
  28142. }
  28143. userJSONBytes, _ := json.Marshal(dat)
  28144. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28145. utils.ErrorLog("解析失败:%v", err)
  28146. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28147. return
  28148. }
  28149. } else if miConfig.MdtrtareaAdmvs == "150499" {
  28150. api := "http://172.16.13.254:9532/" + "nmyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  28151. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  28152. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  28153. resp, requestErr := http.Get(api)
  28154. if requestErr != nil {
  28155. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28156. return
  28157. }
  28158. body, ioErr := ioutil.ReadAll(resp.Body)
  28159. if ioErr != nil {
  28160. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28161. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28162. return
  28163. }
  28164. var respJSON map[string]interface{}
  28165. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  28166. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28167. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28168. return
  28169. }
  28170. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28171. result, _ := json.Marshal(respJSON)
  28172. fmt.Println("log")
  28173. fmt.Println(string(result))
  28174. if err := json.Unmarshal([]byte(result), &resEleven10265); err != nil {
  28175. utils.ErrorLog("解析失败:%v", err)
  28176. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28177. return
  28178. }
  28179. res.InfRefmsgid = resEleven10265.InfRefmsgid
  28180. res.Output = resEleven10265.Output
  28181. res.ErrMsg = resEleven10265.ErrMsg
  28182. res.Cainfo = resEleven10265.Cainfo
  28183. res.WarnMsg = resEleven10265.WarnMsg
  28184. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  28185. res.Infcode = infocode
  28186. } else if miConfig.MdtrtareaAdmvs == "441799" {
  28187. api := miConfig.Url + "gdyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  28188. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  28189. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  28190. resp, requestErr := http.Get(api)
  28191. if requestErr != nil {
  28192. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28193. return
  28194. }
  28195. body, ioErr := ioutil.ReadAll(resp.Body)
  28196. if ioErr != nil {
  28197. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28198. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28199. return
  28200. }
  28201. var respJSON map[string]interface{}
  28202. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  28203. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28204. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28205. return
  28206. }
  28207. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28208. result, _ := json.Marshal(respJSON)
  28209. if err := json.Unmarshal([]byte(result), &res); err != nil {
  28210. utils.ErrorLog("解析失败:%v", err)
  28211. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28212. return
  28213. }
  28214. } else if miConfig.MdtrtareaAdmvs == "450721" {
  28215. service.Gxyb9001(baseParams.OrgName, baseParams.Doctor, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, admin_user_id, order.SetlId, order.MdtrtId, order.PsnNo, order.MedinsSetlId)
  28216. //return
  28217. } else {
  28218. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  28219. if len(his.InsuplcAdmdvs) == 0 {
  28220. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  28221. } else {
  28222. baseParams.InsuplcAdmdvs = his.InsuplcAdmdvs
  28223. }
  28224. result := service.Gdyb5203(baseParams, businessParams)
  28225. //service.Gdyb5204(baseParams, businessParams)
  28226. //service.Gdyb5302(businessParams.PsnNo, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs, baseParams.SecretKey)
  28227. var dat map[string]interface{}
  28228. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  28229. fmt.Println(dat)
  28230. } else {
  28231. fmt.Println(err)
  28232. }
  28233. userJSONBytes, _ := json.Marshal(dat)
  28234. if miConfig.Code == "H15049901371" {
  28235. if err := json.Unmarshal(userJSONBytes, &resEleven10265); err != nil {
  28236. utils.ErrorLog("解析失败:%v", err)
  28237. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28238. return
  28239. }
  28240. res.InfRefmsgid = resEleven10265.InfRefmsgid
  28241. res.Output = resEleven10265.Output
  28242. res.ErrMsg = resEleven10265.ErrMsg
  28243. res.Cainfo = resEleven10265.Cainfo
  28244. res.WarnMsg = resEleven10265.WarnMsg
  28245. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  28246. res.Infcode = infocode
  28247. } else {
  28248. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28249. utils.ErrorLog("解析失败:%v", err)
  28250. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28251. return
  28252. }
  28253. }
  28254. }
  28255. printor_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  28256. charge_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, order.Creator)
  28257. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, order.PatientId, order.SettleAccountsDate)
  28258. adminRole_two, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  28259. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, his_hospital.Doctor)
  28260. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  28261. var doctor_name string
  28262. if roles.ID == 0 {
  28263. doctor_name = "管理员"
  28264. } else {
  28265. doctor_name = roles.UserName
  28266. }
  28267. yiliao_leibie := ""
  28268. switch order.MedType {
  28269. case "11":
  28270. yiliao_leibie = "普通门诊"
  28271. break
  28272. case "12":
  28273. yiliao_leibie = "门诊挂号"
  28274. break
  28275. case "13":
  28276. yiliao_leibie = "急诊"
  28277. break
  28278. case "14":
  28279. yiliao_leibie = "门诊特殊病"
  28280. break
  28281. case "15":
  28282. yiliao_leibie = "门诊统筹"
  28283. break
  28284. case "16":
  28285. yiliao_leibie = "门诊慢性病"
  28286. break
  28287. case "21":
  28288. yiliao_leibie = "普通住院"
  28289. break
  28290. }
  28291. //var rf []CustomFundPay
  28292. //json.Unmarshal([]byte(order.SetlDetail), &rf)
  28293. departments, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  28294. res.Output.Setlinfo.PsnCashPay = order.PsnCashPay
  28295. if res.Infcode == 0 {
  28296. if adminUser.CurrentOrgId == 10215 || adminUser.CurrentOrgId == 10387 || adminUser.CurrentOrgId == 9919 || adminUser.CurrentOrgId == 10088 || adminUser.CurrentOrgId == 10150 || adminUser.CurrentOrgId == 10510 {
  28297. c.ServeSuccessJSON(map[string]interface{}{
  28298. "diagnosis": name,
  28299. "order_infos": orderInfos,
  28300. "number": order.MdtrtId,
  28301. "date": order.SettleAccountsDate,
  28302. "charge_admin": charge_admin,
  28303. "printor_admin": printor_admin,
  28304. "info": res.Output.Setlinfo,
  28305. "order": order,
  28306. "bedCostTotal": bedCostTotal,
  28307. "bedCostSelfTotal": bedCostSelfTotal,
  28308. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  28309. "bedSelfTotal": bedSelfTotal,
  28310. "bedInscpTotal": bedInscpTotal,
  28311. "operationCostTotal": operationCostTotal,
  28312. "operationCostSelfTotal": operationCostSelfTotal,
  28313. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  28314. "operationSelfTotal": operationSelfTotal,
  28315. "operationInscpTotal": operationInscpTotal,
  28316. "otherCostTotal": otherCostTotal,
  28317. "otherCostSelfTotal": otherCostSelfTotal,
  28318. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  28319. "otherSelfTotal": otherSelfTotal,
  28320. "otherInscpTotal": otherInscpTotal,
  28321. "materialCostTotal": materialCostTotal,
  28322. "materialCostSelfTotal": materialCostSelfTotal,
  28323. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  28324. "materialSelfTotal": materialSelfTotal,
  28325. "materialInscpTotal": materialInscpTotal,
  28326. "westernMedicineCostTotal": westernMedicineCostTotal,
  28327. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  28328. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  28329. "westernMedicineSelfTotal": westernMedicineSelfTotal,
  28330. "westernMedicineInscpTotal": westernMedicineInscpTotal,
  28331. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  28332. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  28333. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  28334. "chineseTraditionalSelfTotal": chineseTraditionalSelfTotal,
  28335. "chineseTraditionalInscpTotal": chineseTraditionalInscpTotal,
  28336. "checkCostTotal": checkCostTotal,
  28337. "checkCostSelfTotal": checkCostSelfTotal,
  28338. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  28339. "checkSelfTotal": checkSelfTotal,
  28340. "checkInscpTotal": checkInscpTotal,
  28341. "laboratoryCostTotal": laboratoryCostTotal,
  28342. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  28343. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  28344. "laboratorySelfTotal": laboratorySelfTotal,
  28345. "laboratoryInscpTotal": laboratoryInscpTotal,
  28346. "treatCostTotal": treatCostTotal,
  28347. "treatCostSelfTotal": treatCostSelfTotal,
  28348. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  28349. "treatSelfTotal": treatSelfTotal,
  28350. "treatInscpTotal": treatInscpTotal,
  28351. "doctor_info": doctor_info,
  28352. "doctor_code": adminRole_two.DoctorCode,
  28353. "doctor_name": doctor_name,
  28354. "health_card_no": order.PsnNo,
  28355. "department": departments.Name,
  28356. "yiliao_leibie": yiliao_leibie,
  28357. "after_money": order.AccountPrice,
  28358. "patient": patient,
  28359. "org_name": miConfig.OrgName,
  28360. "org_code": miConfig.Code,
  28361. "order_number": order.Number,
  28362. "his_hospital": his_hospital,
  28363. "his": his,
  28364. "dia_config": dia_config,
  28365. "psn_cash_pay": order.PsnCashPay,
  28366. //"funds": rf,
  28367. //"check_order_info": cus_slice,
  28368. })
  28369. } else {
  28370. c.ServeSuccessJSON(map[string]interface{}{
  28371. "diagnosis": name,
  28372. "order_infos": orderInfos,
  28373. "number": order.MdtrtId,
  28374. "date": order.SettleAccountsDate,
  28375. "charge_admin": charge_admin,
  28376. "printor_admin": printor_admin,
  28377. "info": order,
  28378. "order": order,
  28379. "bedCostTotal": bedCostTotal,
  28380. "bedCostSelfTotal": bedCostSelfTotal,
  28381. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  28382. "bedSelfTotal": bedSelfTotal,
  28383. "bedInscpTotal": bedInscpTotal,
  28384. "operationCostTotal": operationCostTotal,
  28385. "operationCostSelfTotal": operationCostSelfTotal,
  28386. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  28387. "operationSelfTotal": operationSelfTotal,
  28388. "operationInscpTotal": operationInscpTotal,
  28389. "otherCostTotal": otherCostTotal,
  28390. "otherCostSelfTotal": otherCostSelfTotal,
  28391. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  28392. "otherSelfTotal": otherSelfTotal,
  28393. "otherInscpTotal": otherInscpTotal,
  28394. "materialCostTotal": materialCostTotal,
  28395. "materialCostSelfTotal": materialCostSelfTotal,
  28396. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  28397. "materialSelfTotal": materialSelfTotal,
  28398. "materialInscpTotal": materialInscpTotal,
  28399. "westernMedicineCostTotal": westernMedicineCostTotal,
  28400. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  28401. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  28402. "westernMedicineSelfTotal": westernMedicineSelfTotal,
  28403. "westernMedicineInscpTotal": westernMedicineInscpTotal,
  28404. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  28405. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  28406. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  28407. "chineseTraditionalSelfTotal": chineseTraditionalSelfTotal,
  28408. "chineseTraditionalInscpTotal": chineseTraditionalInscpTotal,
  28409. "checkCostTotal": checkCostTotal,
  28410. "checkCostSelfTotal": checkCostSelfTotal,
  28411. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  28412. "checkSelfTotal": checkSelfTotal,
  28413. "checkInscpTotal": checkInscpTotal,
  28414. "laboratoryCostTotal": laboratoryCostTotal,
  28415. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  28416. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  28417. "laboratorySelfTotal": laboratorySelfTotal,
  28418. "laboratoryInscpTotal": laboratoryInscpTotal,
  28419. "treatCostTotal": treatCostTotal,
  28420. "treatCostSelfTotal": treatCostSelfTotal,
  28421. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  28422. "treatSelfTotal": treatSelfTotal,
  28423. "treatInscpTotal": treatInscpTotal,
  28424. "doctor_info": doctor_info,
  28425. "doctor_code": adminRole_two.DoctorCode,
  28426. "doctor_name": doctor_name,
  28427. "health_card_no": order.PsnNo,
  28428. "department": departments.Name,
  28429. "yiliao_leibie": yiliao_leibie,
  28430. "after_money": order.AccountPrice,
  28431. "patient": patient,
  28432. "org_name": miConfig.OrgName,
  28433. "org_code": miConfig.Code,
  28434. "order_number": order.Number,
  28435. "his_hospital": his_hospital,
  28436. "his": his,
  28437. "dia_config": dia_config,
  28438. "psn_cash_pay": order.PsnCashPay,
  28439. //"funds": rf,
  28440. //"check_order_info": cus_slice,
  28441. })
  28442. }
  28443. }
  28444. }
  28445. }
  28446. //func (c *HisApiController) CheckTreatment() {
  28447. // patient_id, _ := c.GetInt64("patient_id")
  28448. // id_card_no := c.GetString("id_card_no")
  28449. // insutype := c.GetString("insutype")
  28450. // med_type := c.GetString("med_type")
  28451. // admin_user_id, _ := c.GetInt64("admin_user_id")
  28452. //
  28453. // adminUser := c.GetAdminUserInfo()
  28454. // patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  28455. //
  28456. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  28457. // config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  28458. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  28459. //
  28460. // if miConfig.MdtrtareaAdmvs == "421300" {
  28461. // var res ResultTwo
  28462. // api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  28463. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  28464. // "&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)
  28465. // resp, requestErr := http.Get(api)
  28466. // if requestErr != nil {
  28467. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28468. // return
  28469. // }
  28470. //
  28471. // body, ioErr := ioutil.ReadAll(resp.Body)
  28472. // if ioErr != nil {
  28473. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28474. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28475. // return
  28476. // }
  28477. // var respJSON map[string]interface{}
  28478. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  28479. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28480. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28481. // return
  28482. // }
  28483. //
  28484. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28485. // result, _ := json.Marshal(respJSON)
  28486. //
  28487. // if err := json.Unmarshal([]byte(result), &res); err != nil {
  28488. // utils.ErrorLog("解析失败:%v", err)
  28489. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28490. // return
  28491. // }
  28492. //
  28493. // if res.Infcode == 0 {
  28494. //
  28495. // api := "http://192.168.124.4:9532/" + "hbyb/2001?cert_no=" + "" +
  28496. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  28497. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&psn_no=" + res.Output.Baseinfo.PsnNo + "&insutype=" + insutype + "&med_type=" + med_type
  28498. // resp, requestErr := http.Get(api)
  28499. // if requestErr != nil {
  28500. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28501. // return
  28502. // }
  28503. //
  28504. // body, ioErr := ioutil.ReadAll(resp.Body)
  28505. // if ioErr != nil {
  28506. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28507. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28508. // return
  28509. // }
  28510. // var respJSON map[string]interface{}
  28511. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  28512. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28513. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28514. // return
  28515. // }
  28516. // var res Result2001
  28517. //
  28518. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28519. // result2, _ := json.Marshal(respJSON)
  28520. //
  28521. // if err := json.Unmarshal([]byte(result2), &res); err != nil {
  28522. // utils.ErrorLog("解析失败:%v", err)
  28523. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28524. // return
  28525. // }
  28526. //
  28527. // if res.Infcode == 0 {
  28528. // c.ServeSuccessJSON(map[string]interface{}{
  28529. // "msg": res.Output.Trtinfo,
  28530. // })
  28531. // }
  28532. //
  28533. // } else {
  28534. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  28535. // return
  28536. // }
  28537. //
  28538. // } else {
  28539. //
  28540. // result := service.Gdyb1101A(id_card_no, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  28541. // var dat map[string]interface{}
  28542. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  28543. // fmt.Println(dat)
  28544. // } else {
  28545. // fmt.Println(err)
  28546. // }
  28547. // userJSONBytes, _ := json.Marshal(dat)
  28548. // var res ResultTwo
  28549. // var res10265 ResultTwo10265
  28550. // if miConfig.Code == "H15049901371" {
  28551. // if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  28552. // utils.ErrorLog("解析失败:%v", err)
  28553. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28554. // return
  28555. // }
  28556. // res.ErrMsg = res10265.ErrMsg
  28557. // infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  28558. // res.Infcode = infocode
  28559. // res.Output = res10265.Output
  28560. // res.InfRefmsgid = res10265.InfRefmsgid
  28561. // } else {
  28562. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28563. // utils.ErrorLog("解析失败:%v", err)
  28564. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28565. // return
  28566. // }
  28567. // }
  28568. //
  28569. // var user_name string
  28570. // role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, adminUser.AdminUser.Id)
  28571. // if role.ID == 0 {
  28572. // user_name = "xxx"
  28573. // } else {
  28574. // user_name = role.UserName
  28575. // }
  28576. //
  28577. // baseParams := models.BaseParams{
  28578. // SecretKey: miConfig.SecretKey,
  28579. // FixmedinsCode: miConfig.Code,
  28580. // InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  28581. // MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  28582. // OrgName: miConfig.OrgName,
  28583. // Doctor: user_name,
  28584. // }
  28585. //
  28586. // if config.IsOpen == 1 {
  28587. // if miConfig.Code == "H15049901371" {
  28588. // if med_type == "14" {
  28589. // if insutype == "390" {
  28590. // med_type = "9933"
  28591. // } else if insutype == "310" {
  28592. // med_type = "990502"
  28593. // }
  28594. // } else if med_type == "11" {
  28595. // med_type = "11"
  28596. // }
  28597. // }
  28598. // result := service.Gdyb2001(baseParams, res.Output.Baseinfo.PsnNo, insutype, med_type)
  28599. // var dat map[string]interface{}
  28600. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  28601. // fmt.Println(dat)
  28602. // } else {
  28603. // fmt.Println(err)
  28604. // }
  28605. // var res Result2001
  28606. // var res10265 Result2001Org10265
  28607. // if miConfig.Code == "H15049901371" {
  28608. // if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  28609. // utils.ErrorLog("解析失败:%v", err)
  28610. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28611. // return
  28612. // }
  28613. // res.ErrMsg = res10265.ErrMsg
  28614. // res.Output = res10265.Output
  28615. // res.InfRefmsgid = res10265.InfRefmsgid
  28616. // infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  28617. // res.Infcode = infocode
  28618. // } else {
  28619. // if err := json.Unmarshal([]byte(result), &res); err != nil {
  28620. // utils.ErrorLog("解析失败:%v", err)
  28621. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28622. // return
  28623. // }
  28624. // }
  28625. // if res.Infcode == 0 {
  28626. // c.ServeSuccessJSON(map[string]interface{}{
  28627. // "msg": res.Output.Trtinfo,
  28628. // })
  28629. // }
  28630. // }
  28631. // }
  28632. //}
  28633. //func (c *HisApiController) PutRecord() {
  28634. // id, _ := c.GetInt64("id")
  28635. // record_time := c.GetString("record_time")
  28636. // timeLayout := "2006-01-02"
  28637. // loc, _ := time.LoadLocation("Local")
  28638. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  28639. // if err != nil {
  28640. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  28641. // return
  28642. // }
  28643. // recordDateTime := theTime.Unix()
  28644. //
  28645. // adminInfo := c.GetAdminUserInfo()
  28646. // patient, _ := service.GetPatientByID(adminInfo.CurrentOrgId, id)
  28647. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  28648. //
  28649. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  28650. //
  28651. // fmt.Println(miConfig.SecretKey)
  28652. //
  28653. // if patient == nil {
  28654. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  28655. // return
  28656. // }
  28657. // if len(patient.IdCardNo) == 0 {
  28658. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  28659. // return
  28660. // }
  28661. // config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  28662. // if config.IsOpen == 1 {
  28663. // 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
  28664. // resp, requestErr := http.Get(api)
  28665. // if requestErr != nil {
  28666. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28667. // return
  28668. // }
  28669. // defer resp.Body.Close()
  28670. // body, ioErr := ioutil.ReadAll(resp.Body)
  28671. // if ioErr != nil {
  28672. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28673. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28674. // return
  28675. // }
  28676. // var respJSON map[string]interface{}
  28677. //
  28678. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  28679. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28680. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28681. // return
  28682. // }
  28683. //
  28684. // userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28685. // userJSONBytes, _ := json.Marshal(userJSON)
  28686. // var res ResultTwo
  28687. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28688. // utils.ErrorLog("解析失败:%v", err)
  28689. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28690. // return
  28691. // }
  28692. // Iinfos, _ := json.Marshal(res.Output.Iinfo)
  28693. // Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  28694. // infoStr := string(Iinfos)
  28695. // idetinfoStr := string(Idetinfos)
  28696. //
  28697. // if res.Infcode == 0 {
  28698. // his := models.VMHisPatient{
  28699. // Status: 1,
  28700. // Ctime: time.Now().Unix(),
  28701. // Mtime: time.Now().Unix(),
  28702. // PsnNo: res.Output.Baseinfo.PsnNo,
  28703. // PsnCertType: res.Output.Baseinfo.PsnCertType,
  28704. // Certno: res.Output.Baseinfo.Certno,
  28705. // PsnName: res.Output.Baseinfo.PsnName,
  28706. // Gend: res.Output.Baseinfo.Gend,
  28707. // Naty: res.Output.Baseinfo.Naty,
  28708. // Brdy: res.Output.Baseinfo.Brdy,
  28709. // Age: res.Output.Baseinfo.Age,
  28710. // Iinfo: infoStr,
  28711. // Idetinfo: idetinfoStr,
  28712. // PatientId: patient.ID,
  28713. // RecordDate: theTime.Unix(),
  28714. // UserOrgId: adminInfo.CurrentOrgId,
  28715. // AdminUserId: adminInfo.AdminUser.Id,
  28716. // IsReturn: 1,
  28717. // }
  28718. //
  28719. // //doctor_id := strconv.FormatInt(patientPrescription.DoctorId, 10)
  28720. // //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")
  28721. // //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")
  28722. //
  28723. // //var dat map[string]interface{}
  28724. // //if err := json.Unmarshal([]byte(result), &dat); err == nil {
  28725. // // fmt.Println(dat)
  28726. // //} else {
  28727. // // fmt.Println(err)
  28728. // //}
  28729. //
  28730. // var dat2 map[string]interface{}
  28731. // if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  28732. // fmt.Println(dat2)
  28733. // } else {
  28734. // fmt.Println(err)
  28735. // }
  28736. //
  28737. // } else {
  28738. // adminUser := c.GetAdminUserInfo()
  28739. // errlog := &models.HisOrderError{
  28740. // UserOrgId: adminUser.CurrentOrgId,
  28741. // Ctime: time.Now().Unix(),
  28742. // Mtime: time.Now().Unix(),
  28743. // ErrMsg: res.ErrMsg,
  28744. // Status: 1,
  28745. // PatientId: id,
  28746. // RecordTime: recordDateTime,
  28747. // Stage: 1,
  28748. // }
  28749. // service.CreateErrMsgLog(errlog)
  28750. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  28751. // return
  28752. // }
  28753. // }
  28754. //
  28755. //}
  28756. //func (c *HisApiController) GetUploadDiag() {
  28757. // id, _ := c.GetInt64("id")
  28758. // record_time := c.GetString("record_time")
  28759. //
  28760. // diagnosis_id, _ := c.GetInt64("diagnosis")
  28761. // sick_type, _ := c.GetInt64("sick_type")
  28762. // reg_type, _ := c.GetInt64("reg_type")
  28763. //
  28764. // timeLayout := "2006-01-02"
  28765. // loc, _ := time.LoadLocation("Local")
  28766. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  28767. // if err != nil {
  28768. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  28769. // return
  28770. // }
  28771. //
  28772. // var patientPrescription models.HisPrescriptionInfo
  28773. // recordDateTime := theTime.Unix()
  28774. // adminInfo := c.GetAdminUserInfo()
  28775. // patientPrescription, _ = service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  28776. //
  28777. // if patientPrescription.ID == 0 {
  28778. // patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  28779. // }
  28780. //
  28781. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  28782. // diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  28783. // his, _ := service.GetVMHisPatientInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  28784. // sickConfig, _ := service.FindSickById(sick_type)
  28785. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  28786. //
  28787. // api2 := "http://127.0.0.1:9532/" + "gdyb/four?psn_no=" + his.PsnNo +
  28788. // "&mdtrt_id=" + his.Number + "&doctor=" + patientPrescription.Doctor + "&department=" + department.Name +
  28789. // "&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 +
  28790. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&sick_code=" + sickConfig.ContentCode + "&sick_name=" + sickConfig.ClassName
  28791. // resp2, requestErr2 := http.Get(api2)
  28792. // if requestErr2 != nil {
  28793. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28794. // return
  28795. // }
  28796. // body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  28797. // if ioErr2 != nil {
  28798. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  28799. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28800. // return
  28801. // }
  28802. // var respJSON2 map[string]interface{}
  28803. // if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  28804. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28805. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28806. // return
  28807. // }
  28808. // respJSON2 = respJSON2["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28809. // userJSONBytes2, _ := json.Marshal(respJSON2)
  28810. //
  28811. // var res2 ResultSix
  28812. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  28813. // utils.ErrorLog("解析失败:%v", err)
  28814. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28815. // return
  28816. // }
  28817. // if res2.Infcode != 0 {
  28818. // adminUser := c.GetAdminUserInfo()
  28819. // errlog := &models.HisOrderError{
  28820. // UserOrgId: adminUser.CurrentOrgId,
  28821. // Ctime: time.Now().Unix(),
  28822. // Mtime: time.Now().Unix(),
  28823. // ErrMsg: res2.ErrMsg,
  28824. // Status: 1,
  28825. // PatientId: id,
  28826. // RecordTime: recordDateTime,
  28827. // Stage: 3,
  28828. // }
  28829. // service.CreateErrMsgLog(errlog)
  28830. //
  28831. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterThreeException)
  28832. // return
  28833. // }
  28834. //
  28835. // c.ServeSuccessJSON(map[string]interface{}{
  28836. // "msg": "上传成功",
  28837. // })
  28838. //
  28839. //}
  28840. type QueryResult struct {
  28841. ID int64
  28842. Name string
  28843. Code string
  28844. List_type_code string
  28845. }
  28846. func (c *HisApiController) GetCheckCode() {
  28847. ids_str := c.GetString("ids")
  28848. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  28849. ids_arr := strings.Split(ids_str, ",")
  28850. var queryResult []QueryResult
  28851. ids := make([]int64, 0)
  28852. for _, item := range ids_arr {
  28853. id, _ := strconv.ParseInt(item, 10, 64)
  28854. ids = append(ids, id)
  28855. }
  28856. if record_type == 1 {
  28857. drugs, _ := service.GetBatchDrugList(ids)
  28858. for _, item := range drugs {
  28859. result := QueryResult{
  28860. ID: item.ID,
  28861. Name: item.DrugName,
  28862. Code: item.MedicalInsuranceNumber,
  28863. List_type_code: "101",
  28864. }
  28865. queryResult = append(queryResult, result)
  28866. }
  28867. } else if record_type == 2 {
  28868. goods, _ := service.GetBatchGoodInformationList(ids)
  28869. fmt.Println(goods)
  28870. for _, item := range goods {
  28871. result := QueryResult{
  28872. ID: item.ID,
  28873. Name: item.GoodName,
  28874. Code: item.SocialSecurityDirectoryCode,
  28875. List_type_code: "301",
  28876. }
  28877. queryResult = append(queryResult, result)
  28878. }
  28879. } else if record_type == 3 {
  28880. projects, _ := service.GetBathchMyPorjecgList(ids)
  28881. for _, item := range projects {
  28882. result := QueryResult{
  28883. ID: item.ID,
  28884. Name: item.ProjectName,
  28885. Code: item.MedicalCode,
  28886. List_type_code: "201",
  28887. }
  28888. queryResult = append(queryResult, result)
  28889. }
  28890. }
  28891. admin_user_id, _ := c.GetInt64("admin_user_id")
  28892. adminUser := c.GetAdminUserInfo()
  28893. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  28894. //config, _ := /**/service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  28895. var user_name string
  28896. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  28897. if role.ID == 0 {
  28898. user_name = "管理员"
  28899. } else {
  28900. user_name = role.UserName
  28901. }
  28902. baseParams := models.BaseParams{
  28903. SecretKey: miConfig.SecretKey,
  28904. FixmedinsCode: miConfig.Code,
  28905. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  28906. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  28907. OrgName: miConfig.OrgName,
  28908. Doctor: user_name,
  28909. }
  28910. var result string
  28911. if miConfig.MdtrtareaAdmvs == "430800" {
  28912. for _, item := range queryResult {
  28913. if record_type == 1 {
  28914. 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)
  28915. } else if record_type == 2 {
  28916. fmt.Println(item.Code)
  28917. 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)
  28918. } else if record_type == 3 {
  28919. 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)
  28920. }
  28921. var dat map[string]interface{}
  28922. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  28923. fmt.Println(dat)
  28924. } else {
  28925. fmt.Println(err)
  28926. }
  28927. userJSONBytes, _ := json.Marshal(dat)
  28928. var res ResultSix
  28929. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28930. utils.ErrorLog("解析失败:%v", err)
  28931. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28932. return
  28933. }
  28934. if res.Infcode == 0 {
  28935. if record_type == 1 {
  28936. service.UpdateBaseDrugById(item.ID)
  28937. } else if record_type == 2 {
  28938. service.UpdateGoodInformaitonByDetail(item.ID)
  28939. } else if record_type == 3 {
  28940. service.UpdateProjectById(item.ID)
  28941. }
  28942. c.ServeSuccessJSON(map[string]interface{}{
  28943. "failed_code": 0,
  28944. "msg": "目录对照成功",
  28945. })
  28946. } else {
  28947. c.ServeSuccessJSON(map[string]interface{}{
  28948. "failed_code": -10,
  28949. "msg": res.ErrMsg,
  28950. })
  28951. }
  28952. }
  28953. } else {
  28954. for _, item := range queryResult {
  28955. var result string
  28956. if record_type == 1 {
  28957. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2023-04-26", "", item.List_type_code, admin_user_id)
  28958. } else if record_type == 2 {
  28959. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2023-04-26", "", item.List_type_code, admin_user_id)
  28960. } else if record_type == 3 {
  28961. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2023-04-26", "", item.List_type_code, admin_user_id)
  28962. }
  28963. var dat map[string]interface{}
  28964. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  28965. fmt.Println(dat)
  28966. } else {
  28967. fmt.Println(err)
  28968. }
  28969. userJSONBytes, _ := json.Marshal(dat)
  28970. var res ResultSix
  28971. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28972. utils.ErrorLog("解析失败:%v", err)
  28973. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28974. return
  28975. }
  28976. if res.Infcode == 0 {
  28977. if record_type == 1 {
  28978. service.UpdateBaseDrugById(item.ID)
  28979. } else if record_type == 2 {
  28980. service.UpdateGoodInformaitonByDetail(item.ID)
  28981. } else if record_type == 3 {
  28982. service.UpdateProjectById(item.ID)
  28983. }
  28984. c.ServeSuccessJSON(map[string]interface{}{
  28985. "failed_code": 0,
  28986. "msg": "目录对照成功",
  28987. })
  28988. } else {
  28989. c.ServeSuccessJSON(map[string]interface{}{
  28990. "failed_code": -10,
  28991. "msg": res.ErrMsg,
  28992. })
  28993. }
  28994. }
  28995. }
  28996. }
  28997. func (c *HisApiController) UnCheckCode() {
  28998. ids_str := c.GetString("ids")
  28999. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  29000. admin_user_id, _ := c.GetInt64("admin_user_id")
  29001. ids_arr := strings.Split(ids_str, ",")
  29002. var queryResult []QueryResult
  29003. ids := make([]int64, 0)
  29004. for _, item := range ids_arr {
  29005. id, _ := strconv.ParseInt(item, 10, 64)
  29006. ids = append(ids, id)
  29007. }
  29008. if record_type == 1 {
  29009. drugs, _ := service.GetBatchDrugList(ids)
  29010. for _, item := range drugs {
  29011. result := QueryResult{
  29012. ID: item.ID,
  29013. Name: item.DrugName,
  29014. Code: item.MedicalInsuranceNumber,
  29015. List_type_code: "101",
  29016. }
  29017. queryResult = append(queryResult, result)
  29018. }
  29019. } else if record_type == 2 {
  29020. goods, _ := service.GetBatchGoodInformationList(ids)
  29021. for _, item := range goods {
  29022. result := QueryResult{
  29023. ID: item.ID,
  29024. Name: item.GoodName,
  29025. Code: item.SocialSecurityDirectoryCode,
  29026. List_type_code: "301",
  29027. }
  29028. queryResult = append(queryResult, result)
  29029. }
  29030. } else if record_type == 3 {
  29031. projects, _ := service.GetBathchMyPorjecgList(ids)
  29032. for _, item := range projects {
  29033. result := QueryResult{
  29034. ID: item.ID,
  29035. Name: item.ProjectName,
  29036. Code: item.MedicalCode,
  29037. List_type_code: "201",
  29038. }
  29039. queryResult = append(queryResult, result)
  29040. }
  29041. }
  29042. adminUser := c.GetAdminUserInfo()
  29043. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  29044. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  29045. var user_name string
  29046. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  29047. if role.ID == 0 {
  29048. user_name = "xxx"
  29049. } else {
  29050. user_name = role.UserName
  29051. }
  29052. baseParams := &models.BaseParams{
  29053. SecretKey: miConfig.SecretKey,
  29054. FixmedinsCode: miConfig.Code,
  29055. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  29056. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  29057. OrgName: miConfig.OrgName,
  29058. Doctor: user_name,
  29059. }
  29060. if config.IsOpen == 1 {
  29061. if miConfig.MdtrtareaAdmvs == "430800" {
  29062. for _, item := range queryResult {
  29063. var result string
  29064. if record_type == 1 {
  29065. 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)
  29066. } else if record_type == 2 {
  29067. fmt.Println(item.Code)
  29068. 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)
  29069. } else if record_type == 3 {
  29070. 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)
  29071. }
  29072. var dat map[string]interface{}
  29073. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  29074. fmt.Println(dat)
  29075. } else {
  29076. fmt.Println(err)
  29077. }
  29078. userJSONBytes, _ := json.Marshal(dat)
  29079. var res ResultSix
  29080. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29081. utils.ErrorLog("解析失败:%v", err)
  29082. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29083. return
  29084. }
  29085. if res.Infcode == 0 {
  29086. if record_type == 1 {
  29087. service.UpdateBaseDrugById(item.ID)
  29088. } else if record_type == 2 {
  29089. service.UpdateGoodInformaitonByDetail(item.ID)
  29090. } else if record_type == 3 {
  29091. service.UpdateProjectById(item.ID)
  29092. }
  29093. c.ServeSuccessJSON(map[string]interface{}{
  29094. "failed_code": 0,
  29095. "msg": "目录对照成功",
  29096. })
  29097. } else {
  29098. c.ServeSuccessJSON(map[string]interface{}{
  29099. "failed_code": -10,
  29100. "msg": res.ErrMsg,
  29101. })
  29102. }
  29103. }
  29104. } else {
  29105. for _, item := range queryResult {
  29106. var result string
  29107. if record_type == 1 {
  29108. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  29109. } else if record_type == 2 {
  29110. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  29111. } else if record_type == 3 {
  29112. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  29113. }
  29114. var dat2 map[string]interface{}
  29115. if err := json.Unmarshal([]byte(result), &dat2); err == nil {
  29116. fmt.Println(dat2)
  29117. } else {
  29118. fmt.Println(err)
  29119. }
  29120. userJSONBytes, _ := json.Marshal(dat2)
  29121. var res ResultSix
  29122. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29123. utils.ErrorLog("解析失败:%v", err)
  29124. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29125. return
  29126. }
  29127. if res.Infcode == 0 {
  29128. if record_type == 1 {
  29129. service.UpdateDrugByIdDetail(item.ID)
  29130. } else if record_type == 2 {
  29131. service.UpdateGoodInfoById(item.ID)
  29132. } else if record_type == 3 {
  29133. service.UpdateMyProjectById(item.ID)
  29134. }
  29135. c.ServeSuccessJSON(map[string]interface{}{
  29136. "failed_code": 0,
  29137. "msg": "撤销目录对照成功",
  29138. })
  29139. } else {
  29140. c.ServeSuccessJSON(map[string]interface{}{
  29141. "failed_code": -10,
  29142. "msg": res.ErrMsg,
  29143. })
  29144. }
  29145. }
  29146. }
  29147. }
  29148. }
  29149. func (c *HisApiController) GetPatientInfo() {
  29150. id_card_no := c.GetString("id_card_no")
  29151. admin_user_id, _ := c.GetInt64("admin_user_id")
  29152. patient, _ := service.GetPatientByIDCard(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  29153. if patient.ID == 0 {
  29154. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  29155. return
  29156. }
  29157. role, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  29158. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  29159. config, _ := service.GetMedicalInsuranceConfig(c.GetAdminUserInfo().CurrentOrgId)
  29160. var res ResultTwo
  29161. var res10265 ResultTwo10265
  29162. if config.IsOpen == 1 {
  29163. if miConfig.MdtrtareaAdmvs == "150499" {
  29164. //请求内网数据
  29165. api := "http://172.16.13.254:9532/" + "nmyb/1101?cert_no=" + patient.IdCardNo +
  29166. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  29167. "&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
  29168. resp, requestErr := http.Get(api)
  29169. if requestErr != nil {
  29170. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29171. return
  29172. }
  29173. body, ioErr := ioutil.ReadAll(resp.Body)
  29174. if ioErr != nil {
  29175. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29176. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29177. return
  29178. }
  29179. var respJSON map[string]interface{}
  29180. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  29181. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29182. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29183. return
  29184. }
  29185. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29186. result_byte, _ := json.Marshal(respJSON)
  29187. result := string(result_byte)
  29188. var dat map[string]interface{}
  29189. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  29190. fmt.Println(dat)
  29191. } else {
  29192. fmt.Println(err)
  29193. }
  29194. userJSONBytes, _ := json.Marshal(dat)
  29195. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  29196. utils.ErrorLog("解析失败:%v", err)
  29197. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29198. return
  29199. }
  29200. Infcode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  29201. res.Infcode = Infcode
  29202. res.ErrMsg = res10265.ErrMsg
  29203. res.Output = res10265.Output
  29204. res.InfRefmsgid = res10265.InfRefmsgid
  29205. res.RespondTime = res10265.RespondTime
  29206. res.WarnInfo = res10265.WarnInfo
  29207. } else {
  29208. result := service.Gdyb1101A(id_card_no, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  29209. var dat map[string]interface{}
  29210. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  29211. fmt.Println(dat)
  29212. } else {
  29213. fmt.Println(err)
  29214. }
  29215. userJSONBytes, _ := json.Marshal(dat)
  29216. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29217. utils.ErrorLog("解析失败:%v", err)
  29218. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29219. return
  29220. }
  29221. }
  29222. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29223. // utils.ErrorLog("解析失败:%v", err)
  29224. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29225. // return
  29226. //}
  29227. for index, item := range res.Output.Iinfo {
  29228. if item.PsnInsuStas == "2" {
  29229. fmt.Println("--------")
  29230. res.Output.Iinfo[index].Insutype = "300"
  29231. res.Output.Iinfo[index].PsnInsuStas = "1"
  29232. }
  29233. }
  29234. fmt.Println(res.Output.Iinfo)
  29235. if res.Infcode != 0 {
  29236. c.ServeSuccessJSON(map[string]interface{}{
  29237. "failed_code": -10,
  29238. "msg": res.ErrMsg,
  29239. })
  29240. } else {
  29241. c.ServeSuccessJSON(map[string]interface{}{
  29242. "failed_code": 0,
  29243. "info": res,
  29244. })
  29245. }
  29246. }
  29247. }
  29248. func (c *HisApiController) PsnPutOnRecord() {
  29249. record_type, _ := c.GetInt64("type")
  29250. patient_id, _ := c.GetInt64("patient_id")
  29251. admin_user_id, _ := c.GetInt64("admin_user_id")
  29252. start_time := c.GetString("start_time")
  29253. end_time := c.GetString("end_time")
  29254. adminUser := c.GetAdminUserInfo()
  29255. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  29256. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  29257. var patients []*models.Patients
  29258. if record_type == 1 { //全部备案
  29259. patient, _ := service.GetAllPatient(adminUser.CurrentOrgId)
  29260. patients = append(patients, patient...)
  29261. } else { //单个备案
  29262. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  29263. patients = append(patients, patient)
  29264. }
  29265. var user_name string
  29266. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  29267. if role.ID == 0 {
  29268. user_name = "xxx"
  29269. } else {
  29270. user_name = role.UserName
  29271. }
  29272. if config.IsOpen == 1 {
  29273. for _, item := range patients {
  29274. 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
  29275. resp, requestErr := http.Get(api)
  29276. if requestErr != nil {
  29277. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29278. return
  29279. }
  29280. defer resp.Body.Close()
  29281. body, ioErr := ioutil.ReadAll(resp.Body)
  29282. if ioErr != nil {
  29283. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29284. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29285. return
  29286. }
  29287. var respJSON map[string]interface{}
  29288. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  29289. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29290. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29291. return
  29292. }
  29293. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29294. userJSONBytes, _ := json.Marshal(userJSON)
  29295. var res ResultTwo
  29296. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29297. utils.ErrorLog("解析失败:%v", err)
  29298. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29299. return
  29300. }
  29301. if res.Infcode == 0 {
  29302. 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)
  29303. var dat map[string]interface{}
  29304. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  29305. fmt.Println(dat)
  29306. } else {
  29307. fmt.Println(err)
  29308. }
  29309. userJSONBytes, _ := json.Marshal(dat)
  29310. var res2 ResultThirteen
  29311. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  29312. utils.ErrorLog("解析失败:%v", err)
  29313. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29314. return
  29315. }
  29316. if res2.Infcode == 0 {
  29317. psnResult := &models.GdybPsnRecord{
  29318. UserOrgId: adminUser.CurrentOrgId,
  29319. PatientId: item.ID,
  29320. PsnNo: res.Output.Baseinfo.PsnNo,
  29321. Ctime: time.Now().Unix(),
  29322. Mtime: time.Now().Unix(),
  29323. Status: 1,
  29324. IsCancel: 1,
  29325. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  29326. }
  29327. service.CreatePsnRecord(psnResult)
  29328. } else {
  29329. c.ServeSuccessJSON(map[string]interface{}{
  29330. "failed_code": -10,
  29331. "msg": res2.ErrMsg,
  29332. })
  29333. return
  29334. }
  29335. }
  29336. }
  29337. }
  29338. }
  29339. func (c *HisApiController) PsnUnPutOnRecord() {
  29340. id, _ := c.GetInt64("id")
  29341. //record_type, _ := c.GetInt64("type")
  29342. admin_user_id, _ := c.GetInt64("admin_user_id")
  29343. adminUser := c.GetAdminUserInfo()
  29344. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  29345. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  29346. var user_name string
  29347. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  29348. if role.ID == 0 {
  29349. user_name = "xxx"
  29350. } else {
  29351. user_name = role.UserName
  29352. }
  29353. psn_record, _ := service.GetPsnRecordById(id)
  29354. if psn_record.ID == 0 {
  29355. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  29356. return
  29357. }
  29358. if config.IsOpen == 1 {
  29359. result := service.Gdyb2506(psn_record.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  29360. var dat map[string]interface{}
  29361. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  29362. fmt.Println(dat)
  29363. } else {
  29364. fmt.Println(err)
  29365. }
  29366. userJSONBytes, _ := json.Marshal(dat)
  29367. var res ResultFourteen
  29368. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29369. utils.ErrorLog("解析失败:%v", err)
  29370. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29371. return
  29372. }
  29373. if res.Infcode == 0 {
  29374. psn_record.IsCancel = 2
  29375. service.CreatePsnRecord(&psn_record)
  29376. } else {
  29377. c.ServeSuccessJSON(map[string]interface{}{
  29378. "failed_code": -10,
  29379. "msg": res.ErrMsg,
  29380. })
  29381. return
  29382. }
  29383. }
  29384. }
  29385. func (c *HisApiController) PsnPutNCDSOnRecord() {
  29386. patient_id, _ := c.GetInt64("patient_id")
  29387. insutype_two := c.GetString("insutype")
  29388. psn_no := c.GetString("psn_no")
  29389. doctor_id, _ := c.GetInt64("doctor_id")
  29390. sick_id, _ := c.GetInt64("sick_id")
  29391. department_id, _ := c.GetInt64("department_id")
  29392. start_time := c.GetString("start_time")
  29393. end_time := c.GetString("end_time")
  29394. check_time := c.GetString("check_time")
  29395. hospital_code := c.GetString("hospital_code")
  29396. hospital_name := c.GetString("hospital_name")
  29397. adminUser := c.GetAdminUserInfo()
  29398. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  29399. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  29400. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  29401. sick, _ := service.FindSickById(sick_id)
  29402. doctor, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  29403. if len(hospital_code) == 0 {
  29404. hospital_code = miConfig.Code
  29405. }
  29406. if len(hospital_name) == 0 {
  29407. hospital_name = miConfig.OrgName
  29408. }
  29409. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  29410. var res ResultTwo
  29411. var res10265 ResultTwo10265
  29412. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  29413. psn_info, _ := service.GetPsnByPatientId(patient.ID)
  29414. api := "http://192.168.2.3:9532/" + "hbyb/1101?cert_no=" + "" +
  29415. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  29416. "&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
  29417. resp, requestErr := http.Get(api)
  29418. if requestErr != nil {
  29419. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29420. return
  29421. }
  29422. body, ioErr := ioutil.ReadAll(resp.Body)
  29423. if ioErr != nil {
  29424. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29425. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29426. return
  29427. }
  29428. var respJSON map[string]interface{}
  29429. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  29430. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29431. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29432. return
  29433. }
  29434. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29435. result, _ := json.Marshal(respJSON)
  29436. fmt.Println("log")
  29437. fmt.Println(string(result))
  29438. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  29439. utils.ErrorLog("解析失败:%v", err)
  29440. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29441. return
  29442. }
  29443. res.ErrMsg = res10265.ErrMsg
  29444. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  29445. res.Infcode = infocode
  29446. res.Output = res10265.Output
  29447. res.InfRefmsgid = res10265.InfRefmsgid
  29448. } else {
  29449. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  29450. if miConfig.Code == "H15049901371" {
  29451. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  29452. utils.ErrorLog("解析失败:%v", err)
  29453. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29454. return
  29455. }
  29456. res.ErrMsg = res10265.ErrMsg
  29457. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  29458. res.Infcode = infocode
  29459. res.Output = res10265.Output
  29460. res.InfRefmsgid = res10265.InfRefmsgid
  29461. } else {
  29462. if err := json.Unmarshal([]byte(result), &res); err != nil {
  29463. utils.ErrorLog("解析失败:%v", err)
  29464. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29465. return
  29466. }
  29467. }
  29468. }
  29469. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  29470. infoStr := string(Iinfos)
  29471. var rf []*ResultFive
  29472. json.Unmarshal([]byte(infoStr), &rf)
  29473. var insuplc_admdvs string
  29474. var insutype string
  29475. var is390 int = 0
  29476. var is310 int = 0
  29477. var insutypes []*ResultFive
  29478. for _, item := range rf {
  29479. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  29480. insutypes = append(insutypes, item)
  29481. }
  29482. }
  29483. if len(insutypes) == 1 {
  29484. insutype = insutypes[0].Insutype
  29485. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  29486. } else {
  29487. for _, i := range insutypes {
  29488. if i.Insutype == "390" {
  29489. is390 = 1
  29490. }
  29491. if i.Insutype == "310" {
  29492. is310 = 1
  29493. }
  29494. }
  29495. }
  29496. if is390 == 1 {
  29497. insutype = "390"
  29498. }
  29499. if is310 == 1 {
  29500. insutype = "310"
  29501. }
  29502. if len(insutypes) == 2 {
  29503. insutype = insutype_two
  29504. }
  29505. if len(insutypes) == 0 {
  29506. insutype = "310"
  29507. }
  29508. insutype = insutype_two
  29509. fmt.Println(insutype)
  29510. for _, item := range rf {
  29511. fmt.Println(item.Insutype)
  29512. fmt.Println(insutype)
  29513. if item.Insutype == insutype {
  29514. fmt.Println(item.Insutype)
  29515. fmt.Println(insutype)
  29516. insuplc_admdvs = item.InsuplcAdmdvs
  29517. }
  29518. }
  29519. fmt.Println(insuplc_admdvs)
  29520. var res2 ResultThirteen
  29521. var res10265_2 ResultThirteen10265
  29522. if config.IsOpen == 1 {
  29523. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  29524. } else {
  29525. if miConfig.MdtrtareaAdmvs == "150499" {
  29526. //
  29527. //api := "http://172.16.13.254:9532/" + "nmyb/2503?psn_no=" + psn_no + "&insutype=" + insutype + "sick_name" + sick.ClassName + "&sick_code=" + sick.CountryCode +
  29528. // "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  29529. // "&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
  29530. //resp, requestErr := http.Get(api)
  29531. //if requestErr != nil {
  29532. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29533. // return
  29534. //}
  29535. //
  29536. //body, ioErr := ioutil.ReadAll(resp.Body)
  29537. //if ioErr != nil {
  29538. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29539. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29540. // return
  29541. //}
  29542. //var respJSON map[string]interface{}
  29543. //if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  29544. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29545. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29546. // return
  29547. //}
  29548. //
  29549. //respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29550. //result, _ := json.Marshal(respJSON)
  29551. //if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  29552. // utils.ErrorLog("解析失败:%v", err)
  29553. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29554. // return
  29555. //}
  29556. //infocode = resThree.Infcode
  29557. //result, _ := json.Marshal(respJSON)
  29558. //if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  29559. // utils.ErrorLog("解析失败:%v", err)
  29560. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29561. // return
  29562. //}
  29563. //
  29564. //resThree.ErrMsg = resThree10265.ErrMsg
  29565. //
  29566. //resThree.Output = resThree10265.Output
  29567. //
  29568. //resThree.InfRefmsgid = resThree10265.InfRefmsgid
  29569. //
  29570. //infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  29571. //
  29572. } else {
  29573. 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)
  29574. var dat map[string]interface{}
  29575. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  29576. fmt.Println(dat)
  29577. } else {
  29578. fmt.Println(err)
  29579. }
  29580. userJSONBytes, _ := json.Marshal(dat)
  29581. if miConfig.Code == "H15049901371" {
  29582. if err := json.Unmarshal(userJSONBytes, &res10265_2); err != nil {
  29583. utils.ErrorLog("解析失败:%v", err)
  29584. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29585. return
  29586. }
  29587. res2.ErrMsg = res10265_2.ErrMsg
  29588. infocode, _ := strconv.ParseInt(res10265_2.Infcode, 10, 64)
  29589. res2.Infcode = infocode
  29590. res2.Output = res10265_2.Output
  29591. res2.InfRefmsgid = res10265_2.InfRefmsgid
  29592. } else {
  29593. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  29594. utils.ErrorLog("解析失败:%v", err)
  29595. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29596. return
  29597. }
  29598. }
  29599. }
  29600. }
  29601. if res2.Infcode == 0 {
  29602. psnResult := &models.GdybPsnNcdsRecord{
  29603. UserOrgId: adminUser.CurrentOrgId,
  29604. PatientId: patient.ID,
  29605. PsnNo: psn_no,
  29606. DoctorId: doctor.AdminUserId,
  29607. DepartmentId: department_id,
  29608. SickType: sick_id,
  29609. Insutype: insutype,
  29610. Ctime: time.Now().Unix(),
  29611. Mtime: time.Now().Unix(),
  29612. Status: 1,
  29613. IsCancel: 1,
  29614. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  29615. }
  29616. service.CreatePsnNCDSRecord(psnResult)
  29617. c.ServeSuccessJSON(map[string]interface{}{
  29618. "failed_code": 0,
  29619. "msg": "备案成功",
  29620. "result": psnResult,
  29621. })
  29622. } else {
  29623. c.ServeSuccessJSON(map[string]interface{}{
  29624. "failed_code": -10,
  29625. "msg": res2.ErrMsg,
  29626. })
  29627. return
  29628. }
  29629. }
  29630. }
  29631. func (c *HisApiController) PsnPutUnNCDSOnRecord() {
  29632. id, _ := c.GetInt64("id")
  29633. admin_user_id, _ := c.GetInt64("admin_user_id")
  29634. adminUser := c.GetAdminUserInfo()
  29635. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  29636. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  29637. //config, _ := service.Ge(adminUser.CurrentOrgId)
  29638. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  29639. //role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  29640. //var user_name string
  29641. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  29642. //if role.ID == 0 {
  29643. // user_name = "xxx"
  29644. //} else {
  29645. // user_name = role.UserName
  29646. //}
  29647. psn_record, _ := service.GetPsnNCDSRecordById(id)
  29648. if psn_record.ID == 0 {
  29649. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  29650. return
  29651. }
  29652. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  29653. var res ResultTwo
  29654. var res10265 ResultTwo10265
  29655. if miConfig.Code == "H15049901371" {
  29656. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  29657. utils.ErrorLog("解析失败:%v", err)
  29658. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29659. return
  29660. }
  29661. res.ErrMsg = res10265.ErrMsg
  29662. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  29663. res.Infcode = infocode
  29664. res.Output = res10265.Output
  29665. res.InfRefmsgid = res10265.InfRefmsgid
  29666. } else {
  29667. if err := json.Unmarshal([]byte(result), &res); err != nil {
  29668. utils.ErrorLog("解析失败:%v", err)
  29669. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29670. return
  29671. }
  29672. }
  29673. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  29674. infoStr := string(Iinfos)
  29675. var rf []*ResultFive
  29676. json.Unmarshal([]byte(infoStr), &rf)
  29677. var insuplc_admdvs string
  29678. var insutype string
  29679. var is390 int = 0
  29680. var is310 int = 0
  29681. var insutypes []*ResultFive
  29682. for _, item := range rf {
  29683. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  29684. insutypes = append(insutypes, item)
  29685. }
  29686. }
  29687. if len(insutypes) == 1 {
  29688. insutype = insutypes[0].Insutype
  29689. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  29690. } else {
  29691. for _, i := range insutypes {
  29692. if i.Insutype == "390" {
  29693. is390 = 1
  29694. }
  29695. if i.Insutype == "310" {
  29696. is310 = 1
  29697. }
  29698. }
  29699. }
  29700. if is390 == 1 {
  29701. insutype = "390"
  29702. }
  29703. if is310 == 1 {
  29704. insutype = "310"
  29705. }
  29706. if len(insutypes) == 0 {
  29707. insutype = "310"
  29708. }
  29709. insutype = psn_record.Insutype
  29710. for _, item := range rf {
  29711. if item.Insutype == insutype {
  29712. insuplc_admdvs = item.InsuplcAdmdvs
  29713. }
  29714. }
  29715. if config.IsOpen == 1 {
  29716. result := service.Gdyb2504(psn_record.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, insuplc_admdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  29717. var dat map[string]interface{}
  29718. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  29719. fmt.Println(dat)
  29720. } else {
  29721. fmt.Println(err)
  29722. }
  29723. userJSONBytes, _ := json.Marshal(dat)
  29724. var res ResultFourteen
  29725. var res10265 ResultFourteen10265
  29726. if miConfig.Code == "H15049901371" {
  29727. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  29728. utils.ErrorLog("解析失败:%v", err)
  29729. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29730. return
  29731. }
  29732. res.ErrMsg = res10265.ErrMsg
  29733. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  29734. res.Infcode = infocode
  29735. res.Output = res10265.Output
  29736. res.InfRefmsgid = res10265.InfRefmsgid
  29737. } else {
  29738. if err := json.Unmarshal([]byte(result), &res); err != nil {
  29739. utils.ErrorLog("解析失败:%v", err)
  29740. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29741. return
  29742. }
  29743. }
  29744. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29745. // utils.ErrorLog("解析失败:%v", err)
  29746. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29747. // return
  29748. //}
  29749. if res.Infcode == 0 {
  29750. psn_record.IsCancel = 2
  29751. service.CreatePsnNCDSRecord(&psn_record)
  29752. c.ServeSuccessJSON(map[string]interface{}{
  29753. "failed_code": 0,
  29754. "msg": "撤销备案成功",
  29755. })
  29756. } else {
  29757. c.ServeSuccessJSON(map[string]interface{}{
  29758. "failed_code": -10,
  29759. "msg": res.ErrMsg,
  29760. })
  29761. return
  29762. }
  29763. }
  29764. }
  29765. func (c *HisApiController) TestTest() {
  29766. patient, _ := service.GetHisPatientInfo(4, 456, 1619712000)
  29767. fmt.Println(patient.Iinfo)
  29768. }
  29769. type CustomData struct {
  29770. MsgId string
  29771. PsnNo string
  29772. Info string
  29773. }
  29774. func (c *HisApiController) ReversalData() {
  29775. var customData []*CustomData
  29776. custom := &CustomData{
  29777. MsgId: "H44022900158202103301714472004",
  29778. PsnNo: "44020000001101329945",
  29779. Info: "2207",
  29780. }
  29781. customData = append(customData, custom)
  29782. custom1 := &CustomData{
  29783. MsgId: "H4402290015820210330172057803",
  29784. PsnNo: "44020000001101161813",
  29785. Info: "2207",
  29786. }
  29787. customData = append(customData, custom1)
  29788. custom2 := &CustomData{
  29789. MsgId: "H44022900158202103301705198813",
  29790. PsnNo: "44190000133097375417",
  29791. Info: "2207",
  29792. }
  29793. customData = append(customData, custom2)
  29794. custom3 := &CustomData{
  29795. MsgId: "H44022900158202103301715524756",
  29796. PsnNo: "44020000001100187221",
  29797. Info: "2207",
  29798. }
  29799. customData = append(customData, custom3)
  29800. custom4 := &CustomData{
  29801. MsgId: "H44022900158202103301730376224",
  29802. PsnNo: "44020000001101959155",
  29803. Info: "2207",
  29804. }
  29805. customData = append(customData, custom4)
  29806. custom5 := &CustomData{
  29807. MsgId: "H44022900158202103301748008725",
  29808. PsnNo: "44020000001104246641",
  29809. Info: "2207",
  29810. }
  29811. customData = append(customData, custom5)
  29812. custom6 := &CustomData{
  29813. MsgId: "H44022900158202103301718096755",
  29814. PsnNo: "44020000001102211860",
  29815. Info: "2207",
  29816. }
  29817. customData = append(customData, custom6)
  29818. custom7 := &CustomData{
  29819. MsgId: "H44022900158202103301736551640",
  29820. PsnNo: "44020000001102687718",
  29821. Info: "2207",
  29822. }
  29823. customData = append(customData, custom7)
  29824. custom8 := &CustomData{
  29825. MsgId: "H44022900158202103301743097676",
  29826. PsnNo: "44020000001102127785",
  29827. Info: "2207",
  29828. }
  29829. customData = append(customData, custom8)
  29830. custom9 := &CustomData{
  29831. MsgId: "H44022900158202103301712304203",
  29832. PsnNo: "44020000001101518097",
  29833. Info: "2207",
  29834. }
  29835. customData = append(customData, custom9)
  29836. custom10 := &CustomData{
  29837. MsgId: "H44022900158202103301738448785",
  29838. PsnNo: "44020000001100500813",
  29839. Info: "2207",
  29840. }
  29841. customData = append(customData, custom10)
  29842. custom11 := &CustomData{
  29843. MsgId: "H44022900158202103301732455843",
  29844. PsnNo: "44020000001102690557",
  29845. Info: "2207",
  29846. }
  29847. customData = append(customData, custom11)
  29848. custom12 := &CustomData{
  29849. MsgId: "H44022900158202103301745421708",
  29850. PsnNo: "44020000001102211928",
  29851. Info: "2207",
  29852. }
  29853. customData = append(customData, custom12)
  29854. custom1212 := &CustomData{
  29855. MsgId: "H440229001582021033017351627",
  29856. PsnNo: "44020000001102481733",
  29857. Info: "2207",
  29858. }
  29859. customData = append(customData, custom1212)
  29860. custom13 := &CustomData{
  29861. MsgId: "H44022900158202103301740327951",
  29862. PsnNo: "44020000001103174866",
  29863. Info: "2207",
  29864. }
  29865. customData = append(customData, custom13)
  29866. custom14 := &CustomData{
  29867. MsgId: "H4402290015820210330174922668",
  29868. PsnNo: "44020000001102927272",
  29869. Info: "2207",
  29870. }
  29871. customData = append(customData, custom14)
  29872. custom15 := &CustomData{
  29873. MsgId: "H44022900158202103301752362273",
  29874. PsnNo: "44020000001102942890",
  29875. Info: "2207",
  29876. }
  29877. customData = append(customData, custom15)
  29878. custom16 := &CustomData{
  29879. MsgId: "H44022900158202103301751082917",
  29880. PsnNo: "44020000001101662162",
  29881. Info: "2207",
  29882. }
  29883. customData = append(customData, custom16)
  29884. custom17 := &CustomData{
  29885. MsgId: "H44022900158202103301754147728",
  29886. PsnNo: "44020000000229014511",
  29887. Info: "2207",
  29888. }
  29889. customData = append(customData, custom17)
  29890. adminUser := c.GetAdminUserInfo()
  29891. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  29892. for _, item := range customData {
  29893. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  29894. fmt.Println(result)
  29895. }
  29896. }
  29897. func (c *HisApiController) GetAllopatry() {
  29898. year := c.GetString("year")
  29899. month := c.GetString("month")
  29900. admin_user_id, _ := c.GetInt64("admin_user_id")
  29901. adminUser := c.GetAdminUserInfo()
  29902. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  29903. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  29904. result, _ := service.Gdyb9001Two(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  29905. var dat map[string]interface{}
  29906. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  29907. fmt.Println(dat)
  29908. } else {
  29909. fmt.Println(err)
  29910. }
  29911. userJSONBytes, _ := json.Marshal(dat)
  29912. var res models.Result9001
  29913. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29914. utils.ErrorLog("解析失败:%v", err)
  29915. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29916. return
  29917. }
  29918. fmt.Println(res.Output.Signinoutb)
  29919. fmt.Println(res.Output.Signinoutb.SignNo)
  29920. fmt.Println(string(userJSONBytes))
  29921. result3, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo, 0)
  29922. var dat3 map[string]interface{}
  29923. if err := json.Unmarshal([]byte(result3), &dat3); err == nil {
  29924. fmt.Println(dat3)
  29925. } else {
  29926. fmt.Println(err)
  29927. }
  29928. userJSONBytes3, _ := json.Marshal(dat3)
  29929. var res3 models.Result3260
  29930. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  29931. utils.ErrorLog("解析失败:%v", err)
  29932. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29933. return
  29934. }
  29935. var curpage int
  29936. var pagesize int = 100
  29937. var start int = 1
  29938. //var stop int
  29939. //pagecount := 10
  29940. pagecount := int(math.Ceil(float64(res3.Output.Totalrow) / float64(pagesize)))
  29941. var res22 []models.Result3260
  29942. for curpage = 1; curpage <= pagecount; curpage++ {
  29943. if curpage == 1 {
  29944. start = 0
  29945. } else {
  29946. start = (curpage-1)*pagesize + 1
  29947. }
  29948. fmt.Println(start)
  29949. //stop = curpage * pagesize
  29950. //if stop > int(res3.Output.Totalrow) {
  29951. // stop =int(res3.Output.Totalrow)
  29952. //}
  29953. result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo, start)
  29954. var dat2 map[string]interface{}
  29955. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  29956. fmt.Println(dat)
  29957. } else {
  29958. fmt.Println(err)
  29959. }
  29960. userJSONBytes2, _ := json.Marshal(dat2)
  29961. var res2 models.Result3260
  29962. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  29963. utils.ErrorLog("解析失败:%v", err)
  29964. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29965. return
  29966. }
  29967. if res2.Infcode == 0 {
  29968. res22 = append(res22, res2)
  29969. //service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res2, res.Output.Signinoutb.SignNo)
  29970. //var dat2 map[string]interface{}
  29971. //if err := json.Unmarshal([]byte(result3), &dat2); err == nil {
  29972. // fmt.Println(dat)
  29973. //} else {
  29974. // fmt.Println(err)
  29975. //}
  29976. //c.ServeSuccessJSON(map[string]interface{}{
  29977. // "list": res2.Output.Data,
  29978. //})
  29979. //continue
  29980. }
  29981. }
  29982. service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res22, res.Output.Signinoutb.SignNo)
  29983. //service.Gdyb3263(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res22, res.Output.Signinoutb.SignNo)
  29984. //result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo, 101)
  29985. //var dat2 map[string]interface{}
  29986. //if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  29987. // fmt.Println(dat)
  29988. //} else {
  29989. // fmt.Println(err)
  29990. //}
  29991. //userJSONBytes2, _ := json.Marshal(dat2)
  29992. //var res2 models.Result3260
  29993. //if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  29994. // utils.ErrorLog("解析失败:%v", err)
  29995. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29996. // return
  29997. //}
  29998. //if res2.Infcode == 0 {
  29999. // service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res2, res.Output.Signinoutb.SignNo)
  30000. // var dat2 map[string]interface{}
  30001. // if err := json.Unmarshal([]byte(result3), &dat2); err == nil {
  30002. // fmt.Println(dat)
  30003. // } else {
  30004. // fmt.Println(err)
  30005. // }
  30006. // c.ServeSuccessJSON(map[string]interface{}{
  30007. // "list": res2.Output.Data,
  30008. // })
  30009. //}
  30010. }
  30011. func (c *HisApiController) ComfirmAllopatry() {
  30012. year := c.GetString("year")
  30013. month := c.GetString("month")
  30014. admin_user_id, _ := c.GetInt64("admin_user_id")
  30015. adminUser := c.GetAdminUserInfo()
  30016. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  30017. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  30018. result, _ := service.Gdyb9001Two(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  30019. var dat map[string]interface{}
  30020. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  30021. fmt.Println(dat)
  30022. } else {
  30023. fmt.Println(err)
  30024. }
  30025. userJSONBytes, _ := json.Marshal(dat)
  30026. var res models.Result9001
  30027. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30028. utils.ErrorLog("解析失败:%v", err)
  30029. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30030. return
  30031. }
  30032. result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo, 0)
  30033. var dat2 map[string]interface{}
  30034. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  30035. fmt.Println(dat)
  30036. } else {
  30037. fmt.Println(err)
  30038. }
  30039. userJSONBytes2, _ := json.Marshal(dat2)
  30040. var res2 models.Result3260
  30041. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  30042. utils.ErrorLog("解析失败:%v", err)
  30043. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30044. return
  30045. }
  30046. //if res2.Infcode == 0 {
  30047. // result, _, msgId := service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res2, res.Output.Signinoutb.SignNo)
  30048. // var dat map[string]interface{}
  30049. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  30050. // fmt.Println(dat)
  30051. // } else {
  30052. // fmt.Println(err)
  30053. // }
  30054. // userJSONBytes, _ := json.Marshal(dat)
  30055. // var res3 models.Result3261
  30056. // if err := json.Unmarshal(userJSONBytes, &res3); err != nil {
  30057. // utils.ErrorLog("解析失败:%v", err)
  30058. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30059. // return
  30060. // }
  30061. //
  30062. // if res3.Infcode == 0 {
  30063. // record := &models.HisYidiClearRecord{
  30064. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  30065. // Ctime: time.Now().Unix(),
  30066. // Mtime: time.Now().Unix(),
  30067. // Status: 1,
  30068. // MsgId: msgId,
  30069. // }
  30070. // service.SaveClearRecord(record)
  30071. // c.ServeSuccessJSON(map[string]interface{}{
  30072. // "msg": "提取成功",
  30073. // })
  30074. // }
  30075. //}
  30076. }
  30077. func (c *HisApiController) RefundAllopatry() {
  30078. year := c.GetString("year")
  30079. month := c.GetString("month")
  30080. //id, _ := c.GetInt64("id")
  30081. admin_user_id, _ := c.GetInt64("admin_user_id")
  30082. adminUser := c.GetAdminUserInfo()
  30083. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  30084. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  30085. //record, _ := service.GetClearRecordById(id)
  30086. result2, _ := service.Gdyb9001Two(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  30087. var dat map[string]interface{}
  30088. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  30089. fmt.Println(dat)
  30090. } else {
  30091. fmt.Println(err)
  30092. }
  30093. userJSONBytes, _ := json.Marshal(dat)
  30094. var res models.Result9001
  30095. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30096. utils.ErrorLog("解析失败:%v", err)
  30097. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30098. return
  30099. }
  30100. result, _ := service.Gdyb3262(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, "", res.Output.Signinoutb.SignNo)
  30101. var dat2 map[string]interface{}
  30102. if err := json.Unmarshal([]byte(result), &dat2); err == nil {
  30103. fmt.Println(dat)
  30104. } else {
  30105. fmt.Println(err)
  30106. }
  30107. userJSONBytes2, _ := json.Marshal(dat2)
  30108. var empty ResultFourteen
  30109. if err := json.Unmarshal(userJSONBytes2, &empty); err != nil {
  30110. utils.ErrorLog("解析失败:%v", err)
  30111. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30112. return
  30113. }
  30114. if empty.Infcode == 0 {
  30115. c.ServeSuccessJSON(map[string]interface{}{
  30116. "msg": "撤销成功",
  30117. })
  30118. return
  30119. }
  30120. }
  30121. func (c *HisApiController) ReversalOtherData() {
  30122. var customData []*CustomData
  30123. custom := &CustomData{
  30124. MsgId: "H44022900158202103301714472004",
  30125. PsnNo: "44020000001101329945",
  30126. Info: "2208",
  30127. }
  30128. customData = append(customData, custom)
  30129. custom1 := &CustomData{
  30130. MsgId: "H4402290015820210330172057803",
  30131. PsnNo: "44020000001101161813",
  30132. Info: "2208",
  30133. }
  30134. customData = append(customData, custom1)
  30135. custom2 := &CustomData{
  30136. MsgId: "H44022900158202103301705198813",
  30137. PsnNo: "44190000133097375417",
  30138. Info: "2208",
  30139. }
  30140. customData = append(customData, custom2)
  30141. custom3 := &CustomData{
  30142. MsgId: "H44022900158202103301715524756",
  30143. PsnNo: "44020000001100187221",
  30144. Info: "2208",
  30145. }
  30146. customData = append(customData, custom3)
  30147. custom4 := &CustomData{
  30148. MsgId: "H44022900158202103301730376224",
  30149. PsnNo: "44020000001101959155",
  30150. Info: "2208",
  30151. }
  30152. customData = append(customData, custom4)
  30153. custom5 := &CustomData{
  30154. MsgId: "H44022900158202103301748008725",
  30155. PsnNo: "44020000001104246641",
  30156. Info: "2208",
  30157. }
  30158. customData = append(customData, custom5)
  30159. custom6 := &CustomData{
  30160. MsgId: "H44022900158202103301718096755",
  30161. PsnNo: "44020000001102211860",
  30162. Info: "2208",
  30163. }
  30164. customData = append(customData, custom6)
  30165. custom7 := &CustomData{
  30166. MsgId: "H44022900158202103301736551640",
  30167. PsnNo: "44020000001102687718",
  30168. Info: "2208",
  30169. }
  30170. customData = append(customData, custom7)
  30171. custom8 := &CustomData{
  30172. MsgId: "H44022900158202103301743097676",
  30173. PsnNo: "44020000001102127785",
  30174. Info: "2208",
  30175. }
  30176. customData = append(customData, custom8)
  30177. custom9 := &CustomData{
  30178. MsgId: "H44022900158202103301712304203",
  30179. PsnNo: "44020000001101518097",
  30180. Info: "2208",
  30181. }
  30182. customData = append(customData, custom9)
  30183. custom10 := &CustomData{
  30184. MsgId: "H44022900158202103301738448785",
  30185. PsnNo: "44020000001100500813",
  30186. Info: "2208",
  30187. }
  30188. customData = append(customData, custom10)
  30189. custom11 := &CustomData{
  30190. MsgId: "H44022900158202103301732455843",
  30191. PsnNo: "44020000001102690557",
  30192. Info: "2208",
  30193. }
  30194. customData = append(customData, custom11)
  30195. custom12 := &CustomData{
  30196. MsgId: "H44022900158202103301745421708",
  30197. PsnNo: "44020000001102211928",
  30198. Info: "2208",
  30199. }
  30200. customData = append(customData, custom12)
  30201. custom1212 := &CustomData{
  30202. MsgId: "H440229001582021033017351627",
  30203. PsnNo: "44020000001102481733",
  30204. Info: "2208",
  30205. }
  30206. customData = append(customData, custom1212)
  30207. custom13 := &CustomData{
  30208. MsgId: "H44022900158202103301740327951",
  30209. PsnNo: "44020000001103174866",
  30210. Info: "2208",
  30211. }
  30212. customData = append(customData, custom13)
  30213. custom14 := &CustomData{
  30214. MsgId: "H4402290015820210330174922668",
  30215. PsnNo: "44020000001102927272",
  30216. Info: "2208",
  30217. }
  30218. customData = append(customData, custom14)
  30219. custom15 := &CustomData{
  30220. MsgId: "H44022900158202103301752362273",
  30221. PsnNo: "44020000001102942890",
  30222. Info: "2208",
  30223. }
  30224. customData = append(customData, custom15)
  30225. custom16 := &CustomData{
  30226. MsgId: "H44022900158202103301751082917",
  30227. PsnNo: "44020000001101662162",
  30228. Info: "2208",
  30229. }
  30230. customData = append(customData, custom16)
  30231. custom17 := &CustomData{
  30232. MsgId: "H44022900158202103301754147728",
  30233. PsnNo: "44020000000229014511",
  30234. Info: "2208",
  30235. }
  30236. customData = append(customData, custom17)
  30237. adminUser := c.GetAdminUserInfo()
  30238. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  30239. for _, item := range customData {
  30240. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  30241. fmt.Println(result)
  30242. }
  30243. }
  30244. func PathExists(path string) (bool, error) {
  30245. _, err := os.Stat(path)
  30246. if err == nil {
  30247. return true, nil
  30248. }
  30249. if os.IsNotExist(err) {
  30250. return false, nil
  30251. }
  30252. return false, err
  30253. }
  30254. // 创建文件夹
  30255. func Mkdir(dir string) {
  30256. // 创建文件夹
  30257. exist, err := PathExists(dir)
  30258. if err != nil {
  30259. fmt.Println(err.Error())
  30260. } else {
  30261. if exist {
  30262. fmt.Println(dir + "文件夹已存在!")
  30263. } else {
  30264. // 文件夹名称,权限
  30265. err := os.Mkdir(dir, os.ModePerm)
  30266. if err != nil {
  30267. fmt.Println(dir+"文件夹创建失败:", err.Error())
  30268. } else {
  30269. fmt.Println(dir + "文件夹创建成功!")
  30270. }
  30271. }
  30272. }
  30273. }
  30274. // 压缩文件
  30275. func Zip(srcFile string, destZip string) error {
  30276. zipfile, err := os.Create(destZip)
  30277. if err != nil {
  30278. return err
  30279. }
  30280. defer zipfile.Close()
  30281. archive := zip.NewWriter(zipfile)
  30282. defer archive.Close()
  30283. filepath.Walk(srcFile, func(path string, info os.FileInfo, err error) error {
  30284. if err != nil {
  30285. return err
  30286. }
  30287. header, err := zip.FileInfoHeader(info)
  30288. if err != nil {
  30289. return err
  30290. }
  30291. header.Name = strings.TrimPrefix(path, filepath.Dir(srcFile)+"/")
  30292. // header.Name = path
  30293. if info.IsDir() {
  30294. header.Name += "/"
  30295. } else {
  30296. header.Method = zip.Deflate
  30297. }
  30298. writer, err := archive.CreateHeader(header)
  30299. if err != nil {
  30300. return err
  30301. }
  30302. if !info.IsDir() {
  30303. file, err := os.Open(path)
  30304. if err != nil {
  30305. return err
  30306. }
  30307. defer file.Close()
  30308. _, err = io.Copy(writer, file)
  30309. }
  30310. return err
  30311. })
  30312. return err
  30313. }
  30314. func ReadFile(filePath string) []byte {
  30315. f, err := os.Open(filePath)
  30316. if err != nil {
  30317. fmt.Println("read file fail", err)
  30318. return nil
  30319. }
  30320. defer f.Close()
  30321. fd, err := ioutil.ReadAll(f)
  30322. if err != nil {
  30323. fmt.Println("read to fd fail", err)
  30324. return nil
  30325. }
  30326. return fd
  30327. }
  30328. func saveLogq(result string, request string, infno string, desc string) {
  30329. dir := "日志"
  30330. utils.Mkdir(dir)
  30331. month := time.Unix(1557042972, 0).Format("1")
  30332. year := time.Now().Format("2006")
  30333. month = time.Now().Format("01")
  30334. day := time.Now().Format("02")
  30335. hour := time.Now().Format("15")
  30336. min := time.Now().Format("04")
  30337. sec := time.Now().Format("05")
  30338. result_time := year + "-" + month + "-" + day + " " + hour + ":" + min + ":" + sec
  30339. file := year + month + day + "_log"
  30340. file_name := file + ".txt"
  30341. file_path := "日志" + "/" + file_name
  30342. exist, _ := utils.PathExists(file_path)
  30343. if exist { //存在
  30344. fmt.Println("存在")
  30345. f, err := os.OpenFile(file_path, os.O_WRONLY, 0644)
  30346. if err != nil {
  30347. fmt.Println("read fail")
  30348. }
  30349. content := "\r\n" + "\r\n" + "\r\n" + result_time + " " + "【 " + desc + infno + "入参" + " 】:" + "\r\n" + request + "\r\n" + result_time + " " + "【 " + desc + infno + "出参" + " 】:" + "\r\n" + result
  30350. n, _ := f.Seek(0, 2)
  30351. _, err = f.WriteAt([]byte(content), n)
  30352. } else { //不存在
  30353. fmt.Println("文件不存在,创建文件")
  30354. f, err := os.Create("日志" + "/" + file_name)
  30355. defer f.Close()
  30356. if err != nil {
  30357. } else {
  30358. _, err = f.Write([]byte("记录日志"))
  30359. }
  30360. }
  30361. }
  30362. func saveLog(result string, request string, infno string, desc string) {
  30363. org_id, _ := beego.AppConfig.Int64("org_id")
  30364. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  30365. dir := miConfig.OrgName + "日志"
  30366. utils.Mkdir(dir)
  30367. month := time.Unix(1557042972, 0).Format("1")
  30368. year := time.Now().Format("2006")
  30369. month = time.Now().Format("01")
  30370. day := time.Now().Format("02")
  30371. hour := time.Now().Format("15")
  30372. min := time.Now().Format("04")
  30373. sec := time.Now().Format("05")
  30374. result_time := year + "-" + month + "-" + day + " " + hour + ":" + min + ":" + sec
  30375. file := strconv.FormatInt(org_id, 10) + "_" + year + month + day + "_log"
  30376. file_name := file + ".txt"
  30377. file_path := miConfig.OrgName + "日志" + "/" + file_name
  30378. exist, _ := utils.PathExists(file_path)
  30379. if exist { //存在
  30380. fmt.Println("存在")
  30381. f, err := os.OpenFile(file_path, os.O_WRONLY, 0644)
  30382. if err != nil {
  30383. fmt.Println("read fail")
  30384. }
  30385. content := "\r\n" + "\r\n" + "\r\n" + result_time + " " + "【 " + desc + infno + "入参" + " 】:" + "\r\n" + request + "\r\n" + result_time + " " + "【 " + desc + infno + "出参" + " 】:" + "\r\n" + result
  30386. n, _ := f.Seek(0, 2)
  30387. _, err = f.WriteAt([]byte(content), n)
  30388. } else { //不存在
  30389. fmt.Println("文件不存在,创建文件")
  30390. f, err := os.Create(miConfig.OrgName + "日志" + "/" + file_name)
  30391. defer f.Close()
  30392. if err != nil {
  30393. } else {
  30394. _, err = f.Write([]byte("记录日志"))
  30395. }
  30396. }
  30397. }
  30398. type Charset string
  30399. const (
  30400. UTF8 = Charset("UTF-8")
  30401. GB18030 = Charset("GB18030")
  30402. )
  30403. func ConvertToString(src string, srcCode string, tagCode string) string {
  30404. srcCoder := mahonia.NewDecoder(srcCode)
  30405. srcResult := srcCoder.ConvertString(src)
  30406. tagCoder := mahonia.NewDecoder(tagCode)
  30407. _, cdata, _ := tagCoder.Translate([]byte(srcResult), true)
  30408. result := string(cdata)
  30409. return result
  30410. }
  30411. func ReadEleCard(admin_user_id int64, org_id int64, c *HisApiController) string {
  30412. roles, _ := service.GetAdminUserInfoByID(org_id, admin_user_id)
  30413. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  30414. var token string
  30415. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  30416. var api string
  30417. if miConfig.MdtrtareaAdmvs == "320921" {
  30418. 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 +
  30419. "&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
  30420. fmt.Println(api)
  30421. } else {
  30422. 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 +
  30423. "&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
  30424. }
  30425. resp, requestErr := http.Get(api)
  30426. if requestErr != nil {
  30427. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30428. return ""
  30429. }
  30430. body, ioErr := ioutil.ReadAll(resp.Body)
  30431. if ioErr != nil {
  30432. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30433. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30434. return ""
  30435. }
  30436. var respJSON map[string]interface{}
  30437. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  30438. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30439. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30440. return ""
  30441. }
  30442. var status string
  30443. status = respJSON["data"].(map[string]interface{})["status"].(string)
  30444. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  30445. var res ResultTwo //1101结果
  30446. var res10265 ResultTwo10265 //1101结果
  30447. if status == "0" { //读卡成功
  30448. var card_info string //卡信息
  30449. var busi_card_info string
  30450. token = respJSON["data"].(map[string]interface{})["token"].(string)
  30451. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  30452. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  30453. fmt.Println(card_info)
  30454. fmt.Println(busi_card_info)
  30455. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  30456. result, _ := json.Marshal(respJSON)
  30457. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  30458. utils.ErrorLog("解析失败:%v", err)
  30459. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30460. return ""
  30461. }
  30462. res.ErrMsg = res10265.ErrMsg
  30463. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  30464. res.Infcode = infocode
  30465. res.Output = res10265.Output
  30466. res.InfRefmsgid = res10265.InfRefmsgid
  30467. if res.Infcode == 0 {
  30468. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  30469. if err == gorm.ErrRecordNotFound {
  30470. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  30471. return ""
  30472. } else if err != nil {
  30473. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  30474. return ""
  30475. } else {
  30476. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  30477. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  30478. infoStr := string(Iinfos)
  30479. idetinfoStr := string(Idetinfos)
  30480. psn := &models.HisPsn{
  30481. PsnNo: res.Output.Baseinfo.PsnNo,
  30482. PatientId: patient.ID,
  30483. Certno: res.Output.Baseinfo.Certno,
  30484. Gend: res.Output.Baseinfo.Gend,
  30485. Naty: res.Output.Baseinfo.Naty,
  30486. PsnCertType: res.Output.Baseinfo.PsnCertType,
  30487. PsnName: res.Output.Baseinfo.PsnName,
  30488. Idetinfo: idetinfoStr,
  30489. Insuinfo: infoStr,
  30490. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  30491. CardInfo: card_info,
  30492. VerifyNumber: token,
  30493. }
  30494. service.CreateHisPsn(psn)
  30495. return token
  30496. }
  30497. }
  30498. } else {
  30499. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  30500. return ""
  30501. }
  30502. } else { //读卡失败
  30503. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  30504. return ""
  30505. }
  30506. return token
  30507. }
  30508. func ReadEleCardforah(admin_user_id int64, org_id int64, c *HisApiController) string {
  30509. roles, _ := service.GetAdminUserInfoByID(org_id, admin_user_id)
  30510. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  30511. var token string
  30512. var api string
  30513. api = miConfig.SecretKey + "ahyb/readcardcharge?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  30514. "&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
  30515. fmt.Println(api)
  30516. resp, requestErr := http.Get(api)
  30517. if requestErr != nil {
  30518. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30519. return ""
  30520. }
  30521. body, ioErr := ioutil.ReadAll(resp.Body)
  30522. if ioErr != nil {
  30523. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30524. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30525. return ""
  30526. }
  30527. var respJSON map[string]interface{}
  30528. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  30529. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30530. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30531. return ""
  30532. }
  30533. var status string
  30534. status = respJSON["data"].(map[string]interface{})["status"].(string)
  30535. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  30536. var res ResultTwo //1101结果
  30537. if status == "1" { //读卡成功
  30538. var card_info string //卡信息
  30539. var busi_card_info string
  30540. token = respJSON["data"].(map[string]interface{})["token"].(string)
  30541. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  30542. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  30543. fmt.Println(card_info)
  30544. fmt.Println(busi_card_info)
  30545. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  30546. result, _ := json.Marshal(respJSON)
  30547. if err := json.Unmarshal([]byte(result), &res); err != nil {
  30548. utils.ErrorLog("解析失败:%v", err)
  30549. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30550. return ""
  30551. }
  30552. if res.Infcode == 0 {
  30553. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  30554. if err == gorm.ErrRecordNotFound {
  30555. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  30556. return ""
  30557. } else if err != nil {
  30558. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  30559. return ""
  30560. } else {
  30561. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  30562. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  30563. infoStr := string(Iinfos)
  30564. idetinfoStr := string(Idetinfos)
  30565. psn := &models.HisPsn{
  30566. PsnNo: res.Output.Baseinfo.PsnNo,
  30567. PatientId: patient.ID,
  30568. Certno: res.Output.Baseinfo.Certno,
  30569. Gend: res.Output.Baseinfo.Gend,
  30570. Naty: res.Output.Baseinfo.Naty,
  30571. PsnCertType: res.Output.Baseinfo.PsnCertType,
  30572. PsnName: res.Output.Baseinfo.PsnName,
  30573. Idetinfo: idetinfoStr,
  30574. Insuinfo: infoStr,
  30575. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  30576. CardInfo: card_info,
  30577. VerifyNumber: token,
  30578. }
  30579. service.CreateHisPsn(psn)
  30580. return token
  30581. }
  30582. }
  30583. } else {
  30584. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  30585. return ""
  30586. }
  30587. return token
  30588. }
  30589. func ReadEleFace(admin_user_id int64, org_id int64, c *HisApiController) string {
  30590. roles, _ := service.GetAdminUserInfoByID(org_id, admin_user_id)
  30591. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  30592. var token string
  30593. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  30594. var api string
  30595. if miConfig.MdtrtareaAdmvs == "320921" {
  30596. 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 +
  30597. "&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
  30598. fmt.Println(api)
  30599. } else {
  30600. 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 +
  30601. "&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
  30602. }
  30603. resp, requestErr := http.Get(api)
  30604. if requestErr != nil {
  30605. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30606. return ""
  30607. }
  30608. body, ioErr := ioutil.ReadAll(resp.Body)
  30609. if ioErr != nil {
  30610. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30611. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30612. return ""
  30613. }
  30614. var respJSON map[string]interface{}
  30615. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  30616. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30617. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30618. return ""
  30619. }
  30620. var status string
  30621. status = respJSON["data"].(map[string]interface{})["status"].(string)
  30622. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  30623. var res ResultTwo //1101结果
  30624. var res10265 ResultTwo10265 //1101结果
  30625. if status == "0" { //读卡成功
  30626. var card_info string //卡信息
  30627. var busi_card_info string
  30628. token = respJSON["data"].(map[string]interface{})["token"].(string)
  30629. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  30630. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  30631. fmt.Println(card_info)
  30632. fmt.Println(busi_card_info)
  30633. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  30634. result, _ := json.Marshal(respJSON)
  30635. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  30636. utils.ErrorLog("解析失败:%v", err)
  30637. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30638. return ""
  30639. }
  30640. res.ErrMsg = res10265.ErrMsg
  30641. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  30642. res.Infcode = infocode
  30643. res.Output = res10265.Output
  30644. res.InfRefmsgid = res10265.InfRefmsgid
  30645. if res.Infcode == 0 {
  30646. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  30647. if err == gorm.ErrRecordNotFound {
  30648. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  30649. return ""
  30650. } else if err != nil {
  30651. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  30652. return ""
  30653. } else {
  30654. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  30655. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  30656. infoStr := string(Iinfos)
  30657. idetinfoStr := string(Idetinfos)
  30658. psn := &models.HisPsn{
  30659. PsnNo: res.Output.Baseinfo.PsnNo,
  30660. PatientId: patient.ID,
  30661. Certno: res.Output.Baseinfo.Certno,
  30662. Gend: res.Output.Baseinfo.Gend,
  30663. Naty: res.Output.Baseinfo.Naty,
  30664. PsnCertType: res.Output.Baseinfo.PsnCertType,
  30665. PsnName: res.Output.Baseinfo.PsnName,
  30666. Idetinfo: idetinfoStr,
  30667. Insuinfo: infoStr,
  30668. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  30669. CardInfo: card_info,
  30670. VerifyNumber: token,
  30671. }
  30672. service.CreateHisPsn(psn)
  30673. return token
  30674. }
  30675. }
  30676. } else {
  30677. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  30678. return ""
  30679. }
  30680. } else { //读卡失败
  30681. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  30682. return ""
  30683. }
  30684. return token
  30685. }
  30686. func DeleteExtraSpaceTwo(s string) string {
  30687. //删除字符串中的多余空格,有多个空格时,仅保留一个空格
  30688. s1 := strings.Replace(s, " ", " ", -1) //替换tab为空格
  30689. regstr := "\\s{2,}" //两个及两个以上空格的正则表达式
  30690. reg, _ := regexp.Compile(regstr) //编译正则表达式
  30691. s2 := make([]byte, len(s1)) //定义字符数组切片
  30692. copy(s2, s1) //将字符串复制到切片
  30693. spc_index := reg.FindStringIndex(string(s2)) //在字符串中搜索
  30694. for len(spc_index) > 0 { //找到适配项
  30695. s2 = append(s2[:spc_index[0]+1], s2[spc_index[1]:]...) //删除多余空格
  30696. spc_index = reg.FindStringIndex(string(s2)) //继续在字符串中搜索
  30697. }
  30698. return string(s2)
  30699. }
  30700. func Remove0000(s string) string {
  30701. str := make([]rune, 0, len(s))
  30702. for _, v := range []rune(s) {
  30703. if v == 0 {
  30704. continue
  30705. }
  30706. str = append(str, v)
  30707. }
  30708. return string(str)
  30709. }
  30710. func (c *HisApiController) GetELeCertInfo(code string, operator_id string, operator_name string) (string, string) {
  30711. DllDef := syscall.MustLoadDLL("HeaSecReadInfo.dll")
  30712. readCard := DllDef.MustFindProc("EcQuery")
  30713. pCardInfo := make([]byte, 8192)
  30714. pBusiCardInfo := make([]byte, 8192)
  30715. data := make(map[string]interface{})
  30716. //pData := make(map[string]interface{})
  30717. inputData := make(map[string]interface{})
  30718. inputData["orgId"] = code
  30719. inputData["businessType"] = "01101"
  30720. inputData["operatorId"] = operator_id
  30721. inputData["operatorName"] = operator_name
  30722. inputData["officeId"] = "001"
  30723. inputData["officeName"] = "血透室"
  30724. //
  30725. data["data"] = inputData
  30726. data["transType"] = "ec.query"
  30727. data["orgId"] = code
  30728. bytesData, _ := json.Marshal(data)
  30729. pCardInfo = bytesData
  30730. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&pCardInfo[0])), (uintptr)(unsafe.Pointer(&pBusiCardInfo[0])))
  30731. fmt.Println(ret2)
  30732. //fmt.Println(DeleteExtraSpace(string(bytesData)))
  30733. //fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  30734. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(bytesData)), "gbk", "utf-8"))
  30735. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  30736. if ret2 != 0 {
  30737. return "", ""
  30738. }
  30739. return DeleteExtraSpace(string(bytesData)), DeleteExtraSpace(string(pBusiCardInfo))
  30740. }
  30741. func DeleteExtraSpace(s string) string {
  30742. //删除字符串中的多余空格,有多个空格时,仅保留一个空格
  30743. s1 := strings.Replace(s, " ", " ", -1) //替换tab为空格
  30744. regstr := "\\s{2,}" //两个及两个以上空格的正则表达式
  30745. reg, _ := regexp.Compile(regstr) //编译正则表达式
  30746. s2 := make([]byte, len(s1)) //定义字符数组切片
  30747. copy(s2, s1) //将字符串复制到切片
  30748. spc_index := reg.FindStringIndex(string(s2)) //在字符串中搜索
  30749. for len(spc_index) > 0 { //找到适配项
  30750. s2 = append(s2[:spc_index[0]+1], s2[spc_index[1]:]...) //删除多余空格
  30751. spc_index = reg.FindStringIndex(string(s2)) //继续在字符串中搜索
  30752. }
  30753. return string(s2)
  30754. }
  30755. // 对账
  30756. func (c *HisApiController) Post3202() {
  30757. start_time := c.GetString("start_time")
  30758. end_time := c.GetString("end_time")
  30759. //insutype := c.GetString("insutype")
  30760. clr_type := c.GetString("clr_type")
  30761. clr_org := c.GetString("clr_optins")
  30762. admin_user_id, _ := c.GetInt64("admin_user_id")
  30763. adminUser := c.GetAdminUserInfo()
  30764. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  30765. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  30766. if len(clr_org) == 0 {
  30767. clr_org = miConfig.MdtrtareaAdmvs
  30768. }
  30769. timeLayout := "2006-01-02"
  30770. loc, _ := time.LoadLocation("Local")
  30771. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  30772. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  30773. var orders []*models.HisOrder
  30774. if clr_org == "421300" {
  30775. orders, _ = service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  30776. } else {
  30777. orders, _ = service.GetOrderByTime11222(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  30778. }
  30779. //orders_two, _ := service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, "310", "", clr_type)
  30780. //fixmedins_setl_cnt := int64(len(orders))
  30781. var medfee_sumamt float64
  30782. var acct_pay float64
  30783. var fund_pay_sumamt float64
  30784. for _, item := range orders {
  30785. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  30786. acct_pay = acct_pay + item.AcctPay
  30787. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  30788. }
  30789. //var medfee_sumamt_two float64
  30790. //var acct_pay_two float64
  30791. //var fund_pay_sumamt_two float64
  30792. //for _, item := range orders_two {
  30793. // medfee_sumamt_two = medfee_sumamt_two + item.MedfeeSumamt
  30794. // acct_pay_two = acct_pay_two + item.AcctPay
  30795. // fund_pay_sumamt_two = fund_pay_sumamt_two + item.FundPaySumamt
  30796. //}
  30797. //var user_name string
  30798. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  30799. //if role.ID == 0 {
  30800. // user_name = "xxx"
  30801. //} else {
  30802. // user_name = role.UserName
  30803. //}
  30804. var res ResultSix
  30805. if config.IsOpen == 1 {
  30806. var bps []*models.BusinessParamsTwo
  30807. var bp models.BusinessParamsTwo
  30808. medfee_sumamt_str := fmt.Sprintf("%.2f", medfee_sumamt)
  30809. acct_pay_str := fmt.Sprintf("%.2f", acct_pay)
  30810. fund_pay_sumamt_str := fmt.Sprintf("%.2f", fund_pay_sumamt)
  30811. bp.MedfeeSumamt = medfee_sumamt_str
  30812. bp.AcctPay = acct_pay_str
  30813. bp.FundPaySumamt = fund_pay_sumamt_str
  30814. bp.Insutype = ""
  30815. bp.StmtBegndate = start_time
  30816. bp.ClrType = clr_type
  30817. bp.SetlOptins = clr_org
  30818. bp.StmtEnddate = end_time
  30819. bps = append(bps, &bp)
  30820. data := make(map[string]interface{})
  30821. data["bps"] = bps
  30822. data["org_name"] = miConfig.OrgName
  30823. data["doctor"] = role.UserName
  30824. data["fixmedins_code"] = miConfig.Code
  30825. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  30826. //data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  30827. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  30828. if miConfig.MdtrtareaAdmvs == "421300" {
  30829. client := &http.Client{}
  30830. bytesData, _ := json.Marshal(data)
  30831. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/3202", bytes.NewReader(bytesData))
  30832. resp, _ := client.Do(req)
  30833. defer resp.Body.Close()
  30834. body, ioErr := ioutil.ReadAll(resp.Body)
  30835. if ioErr != nil {
  30836. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30837. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30838. return
  30839. }
  30840. var respJSON map[string]interface{}
  30841. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30842. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30843. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30844. return
  30845. }
  30846. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30847. userJSONBytes, _ := json.Marshal(respJSON)
  30848. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30849. utils.ErrorLog("解析失败:%v", err)
  30850. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30851. return
  30852. }
  30853. }
  30854. if miConfig.MdtrtareaAdmvs == "420200" {
  30855. client := &http.Client{}
  30856. bytesData, _ := json.Marshal(data)
  30857. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/3202", bytes.NewReader(bytesData))
  30858. resp, _ := client.Do(req)
  30859. defer resp.Body.Close()
  30860. body, ioErr := ioutil.ReadAll(resp.Body)
  30861. if ioErr != nil {
  30862. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30863. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30864. return
  30865. }
  30866. var respJSON map[string]interface{}
  30867. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30868. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30869. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30870. return
  30871. }
  30872. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30873. userJSONBytes, _ := json.Marshal(respJSON)
  30874. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30875. utils.ErrorLog("解析失败:%v", err)
  30876. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30877. return
  30878. }
  30879. }
  30880. if miConfig.MdtrtareaAdmvs == "421182" {
  30881. client := &http.Client{}
  30882. bytesData, _ := json.Marshal(data)
  30883. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/3202", bytes.NewReader(bytesData))
  30884. resp, _ := client.Do(req)
  30885. defer resp.Body.Close()
  30886. body, ioErr := ioutil.ReadAll(resp.Body)
  30887. if ioErr != nil {
  30888. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30889. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30890. return
  30891. }
  30892. var respJSON map[string]interface{}
  30893. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30894. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30895. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30896. return
  30897. }
  30898. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30899. userJSONBytes, _ := json.Marshal(respJSON)
  30900. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30901. utils.ErrorLog("解析失败:%v", err)
  30902. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30903. return
  30904. }
  30905. }
  30906. if res.Infcode == 0 {
  30907. c.ServeSuccessJSON(map[string]interface{}{
  30908. "msg": "发起成功",
  30909. })
  30910. } else {
  30911. c.ServeSuccessJSON(map[string]interface{}{
  30912. "failed_code": -10,
  30913. "msg": res.ErrMsg,
  30914. })
  30915. }
  30916. }
  30917. }
  30918. func (c *HisApiController) Post3202b() {
  30919. start_time := c.GetString("start_time")
  30920. end_time := c.GetString("end_time")
  30921. //insutype := c.GetString("insutype")
  30922. clr_type := c.GetString("clr_type")
  30923. clr_org := c.GetString("clr_optins")
  30924. admin_user_id, _ := c.GetInt64("admin_user_id")
  30925. adminUser := c.GetAdminUserInfo()
  30926. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  30927. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  30928. if len(clr_org) == 0 {
  30929. clr_org = miConfig.MdtrtareaAdmvs
  30930. }
  30931. timeLayout := "2006-01-02"
  30932. loc, _ := time.LoadLocation("Local")
  30933. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  30934. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  30935. orders, _ := service.GetOrderByTimeFourfor11(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  30936. //orders_two, _ := service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, "310", "", clr_type)
  30937. //fixmedins_setl_cnt := int64(len(orders))
  30938. var medfee_sumamt float64
  30939. var acct_pay float64
  30940. var fund_pay_sumamt float64
  30941. for _, item := range orders {
  30942. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  30943. acct_pay = acct_pay + item.AcctPay
  30944. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  30945. }
  30946. //var medfee_sumamt_two float64
  30947. //var acct_pay_two float64
  30948. //var fund_pay_sumamt_two float64
  30949. //for _, item := range orders_two {
  30950. // medfee_sumamt_two = medfee_sumamt_two + item.MedfeeSumamt
  30951. // acct_pay_two = acct_pay_two + item.AcctPay
  30952. // fund_pay_sumamt_two = fund_pay_sumamt_two + item.FundPaySumamt
  30953. //}
  30954. //var user_name string
  30955. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  30956. //if role.ID == 0 {
  30957. // user_name = "xxx"
  30958. //} else {
  30959. // user_name = role.UserName
  30960. //}
  30961. var res ResultSix
  30962. if config.IsOpen == 1 {
  30963. var bps []*models.BusinessParamsTwo
  30964. var bp models.BusinessParamsTwo
  30965. medfee_sumamt_str := fmt.Sprintf("%.2f", medfee_sumamt)
  30966. acct_pay_str := fmt.Sprintf("%.2f", acct_pay)
  30967. fund_pay_sumamt_str := fmt.Sprintf("%.2f", fund_pay_sumamt)
  30968. bp.MedfeeSumamt = medfee_sumamt_str
  30969. bp.AcctPay = acct_pay_str
  30970. bp.FundPaySumamt = fund_pay_sumamt_str
  30971. bp.Insutype = "390"
  30972. bp.StmtBegndate = start_time
  30973. bp.ClrType = clr_type
  30974. bp.SetlOptins = clr_org
  30975. bp.StmtEnddate = end_time
  30976. bps = append(bps, &bp)
  30977. data := make(map[string]interface{})
  30978. data["bps"] = bps
  30979. data["org_name"] = miConfig.OrgName
  30980. data["doctor"] = role.UserName
  30981. data["fixmedins_code"] = miConfig.Code
  30982. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  30983. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  30984. if miConfig.MdtrtareaAdmvs == "421300" {
  30985. client := &http.Client{}
  30986. bytesData, _ := json.Marshal(data)
  30987. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/3202b", bytes.NewReader(bytesData))
  30988. resp, _ := client.Do(req)
  30989. defer resp.Body.Close()
  30990. body, ioErr := ioutil.ReadAll(resp.Body)
  30991. if ioErr != nil {
  30992. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30993. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30994. return
  30995. }
  30996. var respJSON map[string]interface{}
  30997. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30998. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30999. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31000. return
  31001. }
  31002. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31003. userJSONBytes, _ := json.Marshal(respJSON)
  31004. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  31005. utils.ErrorLog("解析失败:%v", err)
  31006. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31007. return
  31008. }
  31009. }
  31010. if miConfig.MdtrtareaAdmvs == "420200" {
  31011. client := &http.Client{}
  31012. bytesData, _ := json.Marshal(data)
  31013. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/3202b", bytes.NewReader(bytesData))
  31014. resp, _ := client.Do(req)
  31015. defer resp.Body.Close()
  31016. body, ioErr := ioutil.ReadAll(resp.Body)
  31017. if ioErr != nil {
  31018. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  31019. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31020. return
  31021. }
  31022. var respJSON map[string]interface{}
  31023. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  31024. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31025. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31026. return
  31027. }
  31028. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31029. userJSONBytes, _ := json.Marshal(respJSON)
  31030. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  31031. utils.ErrorLog("解析失败:%v", err)
  31032. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31033. return
  31034. }
  31035. }
  31036. if miConfig.MdtrtareaAdmvs == "421182" {
  31037. client := &http.Client{}
  31038. bytesData, _ := json.Marshal(data)
  31039. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/3202b", bytes.NewReader(bytesData))
  31040. resp, _ := client.Do(req)
  31041. defer resp.Body.Close()
  31042. body, ioErr := ioutil.ReadAll(resp.Body)
  31043. if ioErr != nil {
  31044. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  31045. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31046. return
  31047. }
  31048. var respJSON map[string]interface{}
  31049. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  31050. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31051. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31052. return
  31053. }
  31054. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31055. userJSONBytes, _ := json.Marshal(respJSON)
  31056. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  31057. utils.ErrorLog("解析失败:%v", err)
  31058. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31059. return
  31060. }
  31061. }
  31062. if res.Infcode == 0 {
  31063. c.ServeSuccessJSON(map[string]interface{}{
  31064. "msg": "发起成功",
  31065. })
  31066. } else {
  31067. c.ServeSuccessJSON(map[string]interface{}{
  31068. "failed_code": -10,
  31069. "msg": res.ErrMsg,
  31070. })
  31071. }
  31072. }
  31073. }
  31074. func (c *HisApiController) Post1608() {
  31075. start_time := c.GetString("start_time")
  31076. end_time := c.GetString("end_time")
  31077. admin_user_id, _ := c.GetInt64("admin_user_id")
  31078. adminUser := c.GetAdminUserInfo()
  31079. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  31080. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  31081. timeLayout := "2006-01-02"
  31082. loc, _ := time.LoadLocation("Local")
  31083. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  31084. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  31085. orders, _ := service.GetOrderByTimeFourfor11(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  31086. //orders_two, _ := service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, "310", "", clr_type)
  31087. fixmedins_setl_cnt := int64(len(orders))
  31088. var medfee_sumamt float64
  31089. var func_smamt float64
  31090. for _, item := range orders {
  31091. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  31092. func_smamt = func_smamt + item.FundPaySumamt + item.AcctPay
  31093. }
  31094. times := strings.Split(start_time, "-")
  31095. time_tows := strings.Split(end_time, "-")
  31096. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  31097. var res ResultSix
  31098. if config.IsOpen == 1 {
  31099. //var bps []*models.BusinessParamsTwo
  31100. //var bp models.BusinessParamsTwo
  31101. medfee_sumamt_str := fmt.Sprintf("%.2f", medfee_sumamt)
  31102. func_smamt_str := fmt.Sprintf("%.2f", func_smamt)
  31103. data := make(map[string]interface{})
  31104. data["org_name"] = miConfig.OrgName
  31105. data["doctor"] = role.UserName
  31106. data["func_smamt"] = func_smamt_str
  31107. data["fixmedins_code"] = miConfig.Code
  31108. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  31109. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  31110. data["cnt"] = strconv.FormatInt(fixmedins_setl_cnt, 10)
  31111. data["medfee_sumamt"] = medfee_sumamt_str
  31112. data["start_time"] = times[0] + times[1] + times[2]
  31113. data["end_time"] = time_tows[0] + time_tows[1] + time_tows[2]
  31114. if miConfig.MdtrtareaAdmvs == "421300" {
  31115. client := &http.Client{}
  31116. bytesData, _ := json.Marshal(data)
  31117. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/1608", bytes.NewReader(bytesData))
  31118. resp, _ := client.Do(req)
  31119. defer resp.Body.Close()
  31120. body, ioErr := ioutil.ReadAll(resp.Body)
  31121. if ioErr != nil {
  31122. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  31123. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31124. return
  31125. }
  31126. var respJSON map[string]interface{}
  31127. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  31128. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31129. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31130. return
  31131. }
  31132. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31133. userJSONBytes, _ := json.Marshal(respJSON)
  31134. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  31135. utils.ErrorLog("解析失败:%v", err)
  31136. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31137. return
  31138. }
  31139. }
  31140. if miConfig.MdtrtareaAdmvs == "420200" {
  31141. client := &http.Client{}
  31142. bytesData, _ := json.Marshal(data)
  31143. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/1608", bytes.NewReader(bytesData))
  31144. resp, _ := client.Do(req)
  31145. defer resp.Body.Close()
  31146. body, ioErr := ioutil.ReadAll(resp.Body)
  31147. if ioErr != nil {
  31148. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  31149. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31150. return
  31151. }
  31152. var respJSON map[string]interface{}
  31153. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  31154. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31155. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31156. return
  31157. }
  31158. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31159. userJSONBytes, _ := json.Marshal(respJSON)
  31160. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  31161. utils.ErrorLog("解析失败:%v", err)
  31162. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31163. return
  31164. }
  31165. }
  31166. if miConfig.MdtrtareaAdmvs == "421182" {
  31167. client := &http.Client{}
  31168. bytesData, _ := json.Marshal(data)
  31169. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/1608", bytes.NewReader(bytesData))
  31170. resp, _ := client.Do(req)
  31171. defer resp.Body.Close()
  31172. body, ioErr := ioutil.ReadAll(resp.Body)
  31173. if ioErr != nil {
  31174. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  31175. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31176. return
  31177. }
  31178. var respJSON map[string]interface{}
  31179. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  31180. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31181. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31182. return
  31183. }
  31184. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31185. userJSONBytes, _ := json.Marshal(respJSON)
  31186. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  31187. utils.ErrorLog("解析失败:%v", err)
  31188. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31189. return
  31190. }
  31191. }
  31192. if res.Infcode == 0 {
  31193. c.ServeSuccessJSON(map[string]interface{}{
  31194. "msg": "发起成功",
  31195. })
  31196. } else {
  31197. c.ServeSuccessJSON(map[string]interface{}{
  31198. "failed_code": -10,
  31199. "msg": res.ErrMsg,
  31200. })
  31201. }
  31202. }
  31203. }
  31204. // 5.11.1.1【5262】结算信息按时间段查询
  31205. func Post5262(c *HisApiController, bp models.BusinessParams5262, page int64, limit int64) {
  31206. admin_user_id, _ := c.GetInt64("admin_user_id")
  31207. adminUser := c.GetAdminUserInfo()
  31208. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  31209. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  31210. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  31211. var res Result5262
  31212. if config.IsOpen == 1 {
  31213. if miConfig.MdtrtareaAdmvs == "421300" {
  31214. data := make(map[string]interface{})
  31215. data["bps"] = bp
  31216. data["org_name"] = miConfig.OrgName
  31217. data["doctor"] = role.UserName
  31218. data["fixmedins_code"] = miConfig.Code
  31219. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  31220. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  31221. data["page"] = strconv.FormatInt(page, 10)
  31222. data["limit"] = strconv.FormatInt(limit, 10)
  31223. fmt.Println(data)
  31224. client := &http.Client{}
  31225. bytesData, _ := json.Marshal(data)
  31226. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/5262", bytes.NewReader(bytesData))
  31227. resp, _ := client.Do(req)
  31228. defer resp.Body.Close()
  31229. body, ioErr := ioutil.ReadAll(resp.Body)
  31230. if ioErr != nil {
  31231. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  31232. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31233. return
  31234. }
  31235. var respJSON map[string]interface{}
  31236. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  31237. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31238. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31239. return
  31240. }
  31241. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31242. userJSONBytes, _ := json.Marshal(respJSON)
  31243. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  31244. utils.ErrorLog("解析失败:%v", err)
  31245. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31246. return
  31247. }
  31248. }
  31249. if miConfig.MdtrtareaAdmvs == "420200" {
  31250. data := make(map[string]interface{})
  31251. data["bps"] = bp
  31252. data["org_name"] = miConfig.OrgName
  31253. data["doctor"] = role.UserName
  31254. data["fixmedins_code"] = miConfig.Code
  31255. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  31256. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  31257. data["page"] = strconv.FormatInt(page, 10)
  31258. data["limit"] = strconv.FormatInt(limit, 10)
  31259. fmt.Println(data)
  31260. client := &http.Client{}
  31261. bytesData, _ := json.Marshal(data)
  31262. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/5262", bytes.NewReader(bytesData))
  31263. resp, _ := client.Do(req)
  31264. defer resp.Body.Close()
  31265. body, ioErr := ioutil.ReadAll(resp.Body)
  31266. if ioErr != nil {
  31267. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  31268. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31269. return
  31270. }
  31271. var respJSON map[string]interface{}
  31272. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  31273. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31274. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31275. return
  31276. }
  31277. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31278. userJSONBytes, _ := json.Marshal(respJSON)
  31279. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  31280. utils.ErrorLog("解析失败:%v", err)
  31281. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31282. return
  31283. }
  31284. }
  31285. if miConfig.MdtrtareaAdmvs == "421182" {
  31286. data := make(map[string]interface{})
  31287. data["bps"] = bp
  31288. data["org_name"] = miConfig.OrgName
  31289. data["doctor"] = role.UserName
  31290. data["fixmedins_code"] = miConfig.Code
  31291. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  31292. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  31293. data["page"] = strconv.FormatInt(page, 10)
  31294. data["limit"] = strconv.FormatInt(limit, 10)
  31295. fmt.Println(data)
  31296. client := &http.Client{}
  31297. bytesData, _ := json.Marshal(data)
  31298. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/5262", bytes.NewReader(bytesData))
  31299. resp, _ := client.Do(req)
  31300. defer resp.Body.Close()
  31301. body, ioErr := ioutil.ReadAll(resp.Body)
  31302. if ioErr != nil {
  31303. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  31304. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31305. return
  31306. }
  31307. var respJSON map[string]interface{}
  31308. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  31309. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31310. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31311. return
  31312. }
  31313. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31314. userJSONBytes, _ := json.Marshal(respJSON)
  31315. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  31316. utils.ErrorLog("解析失败:%v", err)
  31317. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31318. return
  31319. }
  31320. }
  31321. if res.Infcode == 0 {
  31322. c.ServeSuccessJSON(map[string]interface{}{
  31323. "order": res.Output.Result,
  31324. "total": res.Output.PageInfo.RecordCounts,
  31325. })
  31326. } else {
  31327. c.ServeSuccessJSON(map[string]interface{}{
  31328. "failed_code": -10,
  31329. "msg": res.ErrMsg,
  31330. })
  31331. }
  31332. }
  31333. }
  31334. // 5.11.1.2【5267】异地结算信息时间段查询
  31335. func Post5267(c *HisApiController, bp models.BusinessParams5262, page int64, limit int64) {
  31336. admin_user_id, _ := c.GetInt64("admin_user_id")
  31337. adminUser := c.GetAdminUserInfo()
  31338. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  31339. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  31340. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  31341. var res Result5267
  31342. if config.IsOpen == 1 {
  31343. if miConfig.MdtrtareaAdmvs == "421300" {
  31344. data := make(map[string]interface{})
  31345. data["bps"] = bp
  31346. data["org_name"] = miConfig.OrgName
  31347. data["doctor"] = role.UserName
  31348. data["fixmedins_code"] = miConfig.Code
  31349. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  31350. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  31351. data["page"] = page
  31352. data["limit"] = limit
  31353. fmt.Println(data)
  31354. client := &http.Client{}
  31355. bytesData, _ := json.Marshal(data)
  31356. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/5267", bytes.NewReader(bytesData))
  31357. resp, _ := client.Do(req)
  31358. defer resp.Body.Close()
  31359. body, ioErr := ioutil.ReadAll(resp.Body)
  31360. if ioErr != nil {
  31361. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  31362. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31363. return
  31364. }
  31365. var respJSON map[string]interface{}
  31366. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  31367. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31368. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31369. return
  31370. }
  31371. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31372. userJSONBytes, _ := json.Marshal(respJSON)
  31373. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  31374. utils.ErrorLog("解析失败:%v", err)
  31375. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31376. return
  31377. }
  31378. }
  31379. if miConfig.MdtrtareaAdmvs == "420200" {
  31380. data := make(map[string]interface{})
  31381. data["bps"] = bp
  31382. data["org_name"] = miConfig.OrgName
  31383. data["doctor"] = role.UserName
  31384. data["fixmedins_code"] = miConfig.Code
  31385. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  31386. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  31387. data["page"] = page
  31388. data["limit"] = limit
  31389. fmt.Println(data)
  31390. client := &http.Client{}
  31391. bytesData, _ := json.Marshal(data)
  31392. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/5267", bytes.NewReader(bytesData))
  31393. resp, _ := client.Do(req)
  31394. defer resp.Body.Close()
  31395. body, ioErr := ioutil.ReadAll(resp.Body)
  31396. if ioErr != nil {
  31397. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  31398. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31399. return
  31400. }
  31401. var respJSON map[string]interface{}
  31402. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  31403. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31404. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31405. return
  31406. }
  31407. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31408. userJSONBytes, _ := json.Marshal(respJSON)
  31409. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  31410. utils.ErrorLog("解析失败:%v", err)
  31411. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31412. return
  31413. }
  31414. }
  31415. if miConfig.MdtrtareaAdmvs == "421182" {
  31416. data := make(map[string]interface{})
  31417. data["bps"] = bp
  31418. data["org_name"] = miConfig.OrgName
  31419. data["doctor"] = role.UserName
  31420. data["fixmedins_code"] = miConfig.Code
  31421. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  31422. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  31423. data["page"] = page
  31424. data["limit"] = limit
  31425. fmt.Println(data)
  31426. client := &http.Client{}
  31427. bytesData, _ := json.Marshal(data)
  31428. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/5267", bytes.NewReader(bytesData))
  31429. resp, _ := client.Do(req)
  31430. defer resp.Body.Close()
  31431. body, ioErr := ioutil.ReadAll(resp.Body)
  31432. if ioErr != nil {
  31433. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  31434. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31435. return
  31436. }
  31437. var respJSON map[string]interface{}
  31438. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  31439. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31440. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31441. return
  31442. }
  31443. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  31444. userJSONBytes, _ := json.Marshal(respJSON)
  31445. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  31446. utils.ErrorLog("解析失败:%v", err)
  31447. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31448. return
  31449. }
  31450. }
  31451. if res.Infcode == 0 {
  31452. c.ServeSuccessJSON(map[string]interface{}{
  31453. "order": res.Output.Result,
  31454. "total": res.Output.PageInfo.RecordCounts,
  31455. })
  31456. } else {
  31457. c.ServeSuccessJSON(map[string]interface{}{
  31458. "failed_code": -10,
  31459. "msg": res.ErrMsg,
  31460. })
  31461. }
  31462. }
  31463. }
  31464. func (c *HisApiController) Post3501() {
  31465. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  31466. data := make(map[string]interface{})
  31467. var struct3501s []models.Struct3501
  31468. var struct3501 models.Struct3501
  31469. struct3501.OrgName = miConfig.OrgName
  31470. struct3501.AccessKey = miConfig.AccessKey
  31471. struct3501.RequestUrl = miConfig.Url
  31472. struct3501.SecretKey = miConfig.SecretKey
  31473. struct3501.ManuDate = "2022-08-17"
  31474. struct3501.FixmedinsBchno = ""
  31475. struct3501.ManuLotnum = ""
  31476. struct3501.RxFlag = "0"
  31477. struct3501.ExpyEnd = "2022-08-17"
  31478. struct3501.Invdate = "2022-08-17"
  31479. struct3501.InvCnt = "20.25"
  31480. struct3501.Memo = ""
  31481. struct3501.MedListCodg = "XB01ABD056B002020200517"
  31482. struct3501.FixmedinsHilistId = miConfig.Code
  31483. struct3501.FixmedinsHilistName = miConfig.OrgName
  31484. struct3501s = append(struct3501s, struct3501)
  31485. data["struct_3501s"] = struct3501s
  31486. client := &http.Client{}
  31487. bytesData, _ := json.Marshal(data)
  31488. var req *http.Request
  31489. if miConfig.MdtrtareaAdmvs == "320921" {
  31490. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  31491. } else {
  31492. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  31493. }
  31494. resp, _ := client.Do(req)
  31495. defer resp.Body.Close()
  31496. body, ioErr := ioutil.ReadAll(resp.Body)
  31497. if ioErr != nil {
  31498. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  31499. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31500. return
  31501. }
  31502. var respJSON map[string]interface{}
  31503. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  31504. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31505. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31506. return
  31507. }
  31508. var res ResultSix
  31509. var resSix10265 ResultSix10265 //1101结果
  31510. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  31511. result, _ := json.Marshal(respJSON)
  31512. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  31513. utils.ErrorLog("解析失败:%v", err)
  31514. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31515. return
  31516. }
  31517. res.InfRefmsgid = resSix10265.InfRefmsgid
  31518. res.Output = resSix10265.Output
  31519. res.ErrMsg = resSix10265.ErrMsg
  31520. res.Cainfo = resSix10265.Cainfo
  31521. res.WarnMsg = resSix10265.WarnMsg
  31522. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  31523. res.Infcode = infocode
  31524. if infocode == 0 {
  31525. c.ServeSuccessJSON(map[string]interface{}{
  31526. "msg": "上传成功",
  31527. })
  31528. return
  31529. } else {
  31530. c.ServeSuccessJSON(map[string]interface{}{
  31531. "failed_code": -10,
  31532. "msg": res.ErrMsg,
  31533. })
  31534. return
  31535. }
  31536. }
  31537. func (c *HisApiController) Post3502() {
  31538. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  31539. data := make(map[string]interface{})
  31540. var struct3502s []models.Struct3502
  31541. var struct3502 models.Struct3502
  31542. struct3502.OrgName = miConfig.OrgName
  31543. struct3502.AccessKey = miConfig.AccessKey
  31544. struct3502.RequestUrl = miConfig.Url
  31545. struct3502.SecretKey = miConfig.SecretKey
  31546. struct3502.ManuDate = "2022-08-15"
  31547. struct3502.FixmedinsBchno = ""
  31548. struct3502.ManuLotnum = ""
  31549. struct3502.RxFlag = "0"
  31550. struct3502.ExpyEnd = "2022-08-15"
  31551. struct3502.Invdate = "2022-08-15"
  31552. struct3502.InvCnt = "20.25"
  31553. struct3502.Memo = ""
  31554. struct3502.MedListCodg = "XB01ABD056B002020200517"
  31555. struct3502.FixmedinsHilistId = miConfig.Code
  31556. struct3502.FixmedinsHilistName = miConfig.OrgName
  31557. struct3502s = append(struct3502s, struct3502)
  31558. data["struct_3502s"] = struct3502s
  31559. client := &http.Client{}
  31560. bytesData, _ := json.Marshal(data)
  31561. var req *http.Request
  31562. if miConfig.MdtrtareaAdmvs == "320921" {
  31563. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  31564. } else {
  31565. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  31566. }
  31567. resp, _ := client.Do(req)
  31568. defer resp.Body.Close()
  31569. body, ioErr := ioutil.ReadAll(resp.Body)
  31570. if ioErr != nil {
  31571. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  31572. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31573. return
  31574. }
  31575. var respJSON map[string]interface{}
  31576. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  31577. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31578. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31579. return
  31580. }
  31581. var res ResultSix
  31582. var resSix10265 ResultSix10265 //1101结果
  31583. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  31584. result, _ := json.Marshal(respJSON)
  31585. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  31586. utils.ErrorLog("解析失败:%v", err)
  31587. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31588. return
  31589. }
  31590. res.InfRefmsgid = resSix10265.InfRefmsgid
  31591. res.Output = resSix10265.Output
  31592. res.ErrMsg = resSix10265.ErrMsg
  31593. res.Cainfo = resSix10265.Cainfo
  31594. res.WarnMsg = resSix10265.WarnMsg
  31595. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  31596. res.Infcode = infocode
  31597. if infocode == 0 {
  31598. c.ServeSuccessJSON(map[string]interface{}{
  31599. "msg": "上传成功",
  31600. })
  31601. return
  31602. } else {
  31603. c.ServeSuccessJSON(map[string]interface{}{
  31604. "failed_code": -10,
  31605. "msg": res.ErrMsg,
  31606. })
  31607. return
  31608. }
  31609. }
  31610. func (c *HisApiController) Post3503() {
  31611. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  31612. data := make(map[string]interface{})
  31613. var struct3501s []models.Struct3501
  31614. var struct3501 models.Struct3501
  31615. struct3501.OrgName = miConfig.OrgName
  31616. struct3501.AccessKey = miConfig.AccessKey
  31617. struct3501.RequestUrl = miConfig.Url
  31618. struct3501.SecretKey = miConfig.SecretKey
  31619. struct3501.ManuDate = "2022-08-15"
  31620. struct3501.FixmedinsBchno = ""
  31621. struct3501.ManuLotnum = ""
  31622. struct3501.RxFlag = "0"
  31623. struct3501.ExpyEnd = "2022-08-15"
  31624. struct3501.Invdate = "2022-08-15"
  31625. struct3501.InvCnt = "20.25"
  31626. struct3501.Memo = ""
  31627. struct3501.MedListCodg = "XB01ABD056B002020200517"
  31628. struct3501.FixmedinsHilistId = miConfig.Code
  31629. struct3501.FixmedinsHilistName = miConfig.OrgName
  31630. struct3501s = append(struct3501s, struct3501)
  31631. data["struct_3501s"] = struct3501s
  31632. client := &http.Client{}
  31633. bytesData, _ := json.Marshal(data)
  31634. var req *http.Request
  31635. if miConfig.MdtrtareaAdmvs == "320921" {
  31636. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  31637. } else {
  31638. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  31639. }
  31640. resp, _ := client.Do(req)
  31641. defer resp.Body.Close()
  31642. body, ioErr := ioutil.ReadAll(resp.Body)
  31643. if ioErr != nil {
  31644. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  31645. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31646. return
  31647. }
  31648. var respJSON map[string]interface{}
  31649. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  31650. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31651. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31652. return
  31653. }
  31654. var res ResultSix
  31655. var resSix10265 ResultSix10265 //1101结果
  31656. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  31657. result, _ := json.Marshal(respJSON)
  31658. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  31659. utils.ErrorLog("解析失败:%v", err)
  31660. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31661. return
  31662. }
  31663. res.InfRefmsgid = resSix10265.InfRefmsgid
  31664. res.Output = resSix10265.Output
  31665. res.ErrMsg = resSix10265.ErrMsg
  31666. res.Cainfo = resSix10265.Cainfo
  31667. res.WarnMsg = resSix10265.WarnMsg
  31668. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  31669. res.Infcode = infocode
  31670. if infocode == 0 {
  31671. c.ServeSuccessJSON(map[string]interface{}{
  31672. "msg": "上传成功",
  31673. })
  31674. return
  31675. } else {
  31676. c.ServeSuccessJSON(map[string]interface{}{
  31677. "failed_code": -10,
  31678. "msg": res.ErrMsg,
  31679. })
  31680. return
  31681. }
  31682. }
  31683. func (c *HisApiController) Post3504() {
  31684. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  31685. data := make(map[string]interface{})
  31686. var struct3501s []models.Struct3501
  31687. var struct3501 models.Struct3501
  31688. struct3501.OrgName = miConfig.OrgName
  31689. struct3501.AccessKey = miConfig.AccessKey
  31690. struct3501.RequestUrl = miConfig.Url
  31691. struct3501.SecretKey = miConfig.SecretKey
  31692. struct3501.ManuDate = "2022-08-15"
  31693. struct3501.FixmedinsBchno = ""
  31694. struct3501.ManuLotnum = ""
  31695. struct3501.RxFlag = "0"
  31696. struct3501.ExpyEnd = "2022-08-15"
  31697. struct3501.Invdate = "2022-08-15"
  31698. struct3501.InvCnt = "20.25"
  31699. struct3501.Memo = ""
  31700. struct3501.MedListCodg = "XB01ABD056B002020200517"
  31701. struct3501.FixmedinsHilistId = miConfig.Code
  31702. struct3501.FixmedinsHilistName = miConfig.OrgName
  31703. struct3501s = append(struct3501s, struct3501)
  31704. data["struct_3501s"] = struct3501s
  31705. client := &http.Client{}
  31706. bytesData, _ := json.Marshal(data)
  31707. var req *http.Request
  31708. if miConfig.MdtrtareaAdmvs == "320921" {
  31709. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  31710. } else {
  31711. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  31712. }
  31713. resp, _ := client.Do(req)
  31714. defer resp.Body.Close()
  31715. body, ioErr := ioutil.ReadAll(resp.Body)
  31716. if ioErr != nil {
  31717. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  31718. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31719. return
  31720. }
  31721. var respJSON map[string]interface{}
  31722. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  31723. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31724. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31725. return
  31726. }
  31727. var res ResultSix
  31728. var resSix10265 ResultSix10265 //1101结果
  31729. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  31730. result, _ := json.Marshal(respJSON)
  31731. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  31732. utils.ErrorLog("解析失败:%v", err)
  31733. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31734. return
  31735. }
  31736. res.InfRefmsgid = resSix10265.InfRefmsgid
  31737. res.Output = resSix10265.Output
  31738. res.ErrMsg = resSix10265.ErrMsg
  31739. res.Cainfo = resSix10265.Cainfo
  31740. res.WarnMsg = resSix10265.WarnMsg
  31741. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  31742. res.Infcode = infocode
  31743. if infocode == 0 {
  31744. c.ServeSuccessJSON(map[string]interface{}{
  31745. "msg": "上传成功",
  31746. })
  31747. return
  31748. } else {
  31749. c.ServeSuccessJSON(map[string]interface{}{
  31750. "failed_code": -10,
  31751. "msg": res.ErrMsg,
  31752. })
  31753. return
  31754. }
  31755. }
  31756. func (c *HisApiController) Post3505() {
  31757. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  31758. data := make(map[string]interface{})
  31759. var struct3501s []models.Struct3501
  31760. var struct3501 models.Struct3501
  31761. struct3501.OrgName = miConfig.OrgName
  31762. struct3501.AccessKey = miConfig.AccessKey
  31763. struct3501.RequestUrl = miConfig.Url
  31764. struct3501.SecretKey = miConfig.SecretKey
  31765. struct3501.ManuDate = "2022-08-15"
  31766. struct3501.FixmedinsBchno = ""
  31767. struct3501.ManuLotnum = ""
  31768. struct3501.RxFlag = "0"
  31769. struct3501.ExpyEnd = "2022-08-15"
  31770. struct3501.Invdate = "2022-08-15"
  31771. struct3501.InvCnt = "20.25"
  31772. struct3501.Memo = ""
  31773. struct3501.MedListCodg = "XB01ABD056B002020200517"
  31774. struct3501.FixmedinsHilistId = miConfig.Code
  31775. struct3501.FixmedinsHilistName = miConfig.OrgName
  31776. struct3501s = append(struct3501s, struct3501)
  31777. data["struct_3501s"] = struct3501s
  31778. client := &http.Client{}
  31779. bytesData, _ := json.Marshal(data)
  31780. var req *http.Request
  31781. if miConfig.MdtrtareaAdmvs == "320921" {
  31782. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  31783. } else {
  31784. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  31785. }
  31786. resp, _ := client.Do(req)
  31787. defer resp.Body.Close()
  31788. body, ioErr := ioutil.ReadAll(resp.Body)
  31789. if ioErr != nil {
  31790. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  31791. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31792. return
  31793. }
  31794. var respJSON map[string]interface{}
  31795. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  31796. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31797. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31798. return
  31799. }
  31800. var res ResultSix
  31801. var resSix10265 ResultSix10265 //1101结果
  31802. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  31803. result, _ := json.Marshal(respJSON)
  31804. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  31805. utils.ErrorLog("解析失败:%v", err)
  31806. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31807. return
  31808. }
  31809. res.InfRefmsgid = resSix10265.InfRefmsgid
  31810. res.Output = resSix10265.Output
  31811. res.ErrMsg = resSix10265.ErrMsg
  31812. res.Cainfo = resSix10265.Cainfo
  31813. res.WarnMsg = resSix10265.WarnMsg
  31814. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  31815. res.Infcode = infocode
  31816. if infocode == 0 {
  31817. c.ServeSuccessJSON(map[string]interface{}{
  31818. "msg": "上传成功",
  31819. })
  31820. return
  31821. } else {
  31822. c.ServeSuccessJSON(map[string]interface{}{
  31823. "failed_code": -10,
  31824. "msg": res.ErrMsg,
  31825. })
  31826. return
  31827. }
  31828. }
  31829. func (c *HisApiController) Post3506() {
  31830. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  31831. data := make(map[string]interface{})
  31832. var struct3501s []models.Struct3501
  31833. var struct3501 models.Struct3501
  31834. struct3501.OrgName = miConfig.OrgName
  31835. struct3501.AccessKey = miConfig.AccessKey
  31836. struct3501.RequestUrl = miConfig.Url
  31837. struct3501.SecretKey = miConfig.SecretKey
  31838. struct3501.ManuDate = "2022-08-15"
  31839. struct3501.FixmedinsBchno = ""
  31840. struct3501.ManuLotnum = ""
  31841. struct3501.RxFlag = "0"
  31842. struct3501.ExpyEnd = "2022-08-15"
  31843. struct3501.Invdate = "2022-08-15"
  31844. struct3501.InvCnt = "20.25"
  31845. struct3501.Memo = ""
  31846. struct3501.MedListCodg = "XB01ABD056B002020200517"
  31847. struct3501.FixmedinsHilistId = miConfig.Code
  31848. struct3501.FixmedinsHilistName = miConfig.OrgName
  31849. struct3501s = append(struct3501s, struct3501)
  31850. data["struct_3501s"] = struct3501s
  31851. client := &http.Client{}
  31852. bytesData, _ := json.Marshal(data)
  31853. var req *http.Request
  31854. if miConfig.MdtrtareaAdmvs == "320921" {
  31855. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  31856. } else {
  31857. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  31858. }
  31859. resp, _ := client.Do(req)
  31860. defer resp.Body.Close()
  31861. body, ioErr := ioutil.ReadAll(resp.Body)
  31862. if ioErr != nil {
  31863. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  31864. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31865. return
  31866. }
  31867. var respJSON map[string]interface{}
  31868. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  31869. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31870. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31871. return
  31872. }
  31873. var res ResultSix
  31874. var resSix10265 ResultSix10265 //1101结果
  31875. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  31876. result, _ := json.Marshal(respJSON)
  31877. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  31878. utils.ErrorLog("解析失败:%v", err)
  31879. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31880. return
  31881. }
  31882. res.InfRefmsgid = resSix10265.InfRefmsgid
  31883. res.Output = resSix10265.Output
  31884. res.ErrMsg = resSix10265.ErrMsg
  31885. res.Cainfo = resSix10265.Cainfo
  31886. res.WarnMsg = resSix10265.WarnMsg
  31887. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  31888. res.Infcode = infocode
  31889. if infocode == 0 {
  31890. c.ServeSuccessJSON(map[string]interface{}{
  31891. "msg": "上传成功",
  31892. })
  31893. return
  31894. } else {
  31895. c.ServeSuccessJSON(map[string]interface{}{
  31896. "failed_code": -10,
  31897. "msg": res.ErrMsg,
  31898. })
  31899. return
  31900. }
  31901. }
  31902. func (c *HisApiController) Post3507() {
  31903. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  31904. data := make(map[string]interface{})
  31905. var struct3501s []models.Struct3501
  31906. var struct3501 models.Struct3501
  31907. struct3501.OrgName = miConfig.OrgName
  31908. struct3501.AccessKey = miConfig.AccessKey
  31909. struct3501.RequestUrl = miConfig.Url
  31910. struct3501.SecretKey = miConfig.SecretKey
  31911. struct3501.ManuDate = "2022-08-15"
  31912. struct3501.FixmedinsBchno = ""
  31913. struct3501.ManuLotnum = ""
  31914. struct3501.RxFlag = "0"
  31915. struct3501.ExpyEnd = "2022-08-15"
  31916. struct3501.Invdate = "2022-08-15"
  31917. struct3501.InvCnt = "20.25"
  31918. struct3501.Memo = ""
  31919. struct3501.MedListCodg = "XB01ABD056B002020200517"
  31920. struct3501.FixmedinsHilistId = miConfig.Code
  31921. struct3501.FixmedinsHilistName = miConfig.OrgName
  31922. struct3501s = append(struct3501s, struct3501)
  31923. data["struct_3501s"] = struct3501s
  31924. client := &http.Client{}
  31925. bytesData, _ := json.Marshal(data)
  31926. var req *http.Request
  31927. if miConfig.MdtrtareaAdmvs == "320921" {
  31928. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  31929. } else {
  31930. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  31931. }
  31932. resp, _ := client.Do(req)
  31933. defer resp.Body.Close()
  31934. body, ioErr := ioutil.ReadAll(resp.Body)
  31935. if ioErr != nil {
  31936. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  31937. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31938. return
  31939. }
  31940. var respJSON map[string]interface{}
  31941. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  31942. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  31943. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31944. return
  31945. }
  31946. var res ResultSix
  31947. var resSix10265 ResultSix10265 //1101结果
  31948. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  31949. result, _ := json.Marshal(respJSON)
  31950. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  31951. utils.ErrorLog("解析失败:%v", err)
  31952. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  31953. return
  31954. }
  31955. res.InfRefmsgid = resSix10265.InfRefmsgid
  31956. res.Output = resSix10265.Output
  31957. res.ErrMsg = resSix10265.ErrMsg
  31958. res.Cainfo = resSix10265.Cainfo
  31959. res.WarnMsg = resSix10265.WarnMsg
  31960. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  31961. res.Infcode = infocode
  31962. if infocode == 0 {
  31963. c.ServeSuccessJSON(map[string]interface{}{
  31964. "msg": "上传成功",
  31965. })
  31966. return
  31967. } else {
  31968. c.ServeSuccessJSON(map[string]interface{}{
  31969. "failed_code": -10,
  31970. "msg": res.ErrMsg,
  31971. })
  31972. return
  31973. }
  31974. }
  31975. func GetjxELeInfo(code string, operator_id string, operator_name string, md string) (string, string) {
  31976. // WebSocket服务器地址
  31977. serverURL := "ws://127.0.0.1:8899"
  31978. // 解析WebSocket服务器地址
  31979. u, err := url.Parse(serverURL)
  31980. if err != nil {
  31981. }
  31982. // 建立WebSocket连接
  31983. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  31984. if err != nil {
  31985. }
  31986. defer conn.Close()
  31987. input2 := make(map[string]interface{})
  31988. input := make(map[string]interface{})
  31989. inputData := make(map[string]interface{})
  31990. inputData["orgId"] = code
  31991. inputData["businessType"] = "01101"
  31992. inputData["operatorId"] = operator_id
  31993. inputData["operatorName"] = operator_name
  31994. inputData["officeId"] = "001"
  31995. inputData["officeName"] = "血透室"
  31996. inputData["deviceType"] = ""
  31997. input["data"] = inputData
  31998. input["orgId"] = code
  31999. input["transType"] = "ec.query"
  32000. //if md == ""
  32001. if md[:4] == "4403" {
  32002. input2["url"] = "http://hosp-sz.gd.hsip.gov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  32003. } else if md[:4] == "4401" {
  32004. input2["url"] = "http://hosp-sz.gd.hsip.gov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  32005. } else {
  32006. input2["url"] = "http://hosp.gd.hsip.gov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  32007. }
  32008. input2["indata"] = input
  32009. fmt.Println(input2)
  32010. bytesData, _ := json.Marshal(input2)
  32011. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  32012. if err != nil {
  32013. fmt.Println(err)
  32014. }
  32015. // 接收消息
  32016. _, receivedMessage, err := conn.ReadMessage()
  32017. if err != nil {
  32018. fmt.Println(err)
  32019. }
  32020. return "", string(receivedMessage)
  32021. }
  32022. func GetjxELeInfoaaa(code string, operator_id string, operator_name string) (string, string) {
  32023. // WebSocket服务器地址
  32024. serverURL := "ws://127.0.0.1:8899"
  32025. // 解析WebSocket服务器地址
  32026. u, err := url.Parse(serverURL)
  32027. if err != nil {
  32028. }
  32029. // 建立WebSocket连接
  32030. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  32031. if err != nil {
  32032. }
  32033. defer conn.Close()
  32034. input2 := make(map[string]interface{})
  32035. input := make(map[string]interface{})
  32036. inputData := make(map[string]interface{})
  32037. inputData["orgId"] = code
  32038. inputData["businessType"] = "01103"
  32039. inputData["operatorId"] = operator_id
  32040. inputData["operatorName"] = operator_name
  32041. inputData["officeId"] = "001"
  32042. inputData["officeName"] = "血透室"
  32043. inputData["deviceType"] = ""
  32044. input["data"] = inputData
  32045. input["orgId"] = code
  32046. input["transType"] = "ec.query"
  32047. //if md ==
  32048. input2["url"] = "http://10.77.211.236/1.0.0/localQrCodeQuery"
  32049. input2["indata"] = input
  32050. fmt.Println(input2)
  32051. bytesData, _ := json.Marshal(input2)
  32052. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  32053. if err != nil {
  32054. fmt.Println(err)
  32055. }
  32056. // 接收消息
  32057. _, receivedMessage, err := conn.ReadMessage()
  32058. if err != nil {
  32059. fmt.Println(err)
  32060. }
  32061. return "", string(receivedMessage)
  32062. }
  32063. func GetELeInfo(code string, operator_id string, operator_name string, md string) (string, string) {
  32064. // WebSocket服务器地址
  32065. serverURL := "ws://127.0.0.1:8899"
  32066. // 解析WebSocket服务器地址
  32067. u, err := url.Parse(serverURL)
  32068. if err != nil {
  32069. }
  32070. // 建立WebSocket连接
  32071. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  32072. if err != nil {
  32073. }
  32074. defer conn.Close()
  32075. input2 := make(map[string]interface{})
  32076. input := make(map[string]interface{})
  32077. inputData := make(map[string]interface{})
  32078. inputData["orgId"] = code
  32079. inputData["businessType"] = "01101"
  32080. inputData["operatorId"] = operator_id
  32081. inputData["operatorName"] = operator_name
  32082. inputData["officeId"] = "001"
  32083. inputData["officeName"] = "血透室"
  32084. inputData["deviceType"] = ""
  32085. input["data"] = inputData
  32086. input["orgId"] = code
  32087. input["transType"] = "ec.query"
  32088. //if md == ""
  32089. if md[:4] == "4403" {
  32090. input2["url"] = "http://igb.hsa.gdgov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  32091. } else if md[:4] == "4401" {
  32092. input2["url"] = "http://igb.hsa.gdgov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  32093. } else {
  32094. input2["url"] = "http://hosp.gd.hsip.gov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  32095. }
  32096. input2["indata"] = input
  32097. fmt.Println(input2)
  32098. bytesData, _ := json.Marshal(input2)
  32099. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  32100. if err != nil {
  32101. fmt.Println(err)
  32102. }
  32103. // 接收消息
  32104. _, receivedMessage, err := conn.ReadMessage()
  32105. if err != nil {
  32106. fmt.Println(err)
  32107. }
  32108. return "", string(receivedMessage)
  32109. }
  32110. func GetELeInfoThree(code string, operator_id string, operator_name string) (string, string) {
  32111. // WebSocket服务器地址
  32112. serverURL := "ws://127.0.0.1:8899"
  32113. // 解析WebSocket服务器地址
  32114. u, err := url.Parse(serverURL)
  32115. if err != nil {
  32116. }
  32117. // 建立WebSocket连接
  32118. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  32119. if err != nil {
  32120. }
  32121. defer conn.Close()
  32122. input2 := make(map[string]interface{})
  32123. input := make(map[string]interface{})
  32124. inputData := make(map[string]interface{})
  32125. inputData["orgId"] = code
  32126. inputData["businessType"] = "01301"
  32127. inputData["operatorId"] = operator_id
  32128. inputData["operatorName"] = operator_name
  32129. inputData["officeId"] = "001"
  32130. inputData["officeName"] = "血透室"
  32131. inputData["deviceType"] = ""
  32132. input["data"] = inputData
  32133. input["orgId"] = code
  32134. input["transType"] = "ec.query"
  32135. input2["url"] = "http://igb.hsa.gdgov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  32136. input2["indata"] = input
  32137. bytesData, _ := json.Marshal(input2)
  32138. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  32139. if err != nil {
  32140. fmt.Println(err)
  32141. }
  32142. // 接收消息
  32143. _, receivedMessage, err := conn.ReadMessage()
  32144. if err != nil {
  32145. fmt.Println(err)
  32146. }
  32147. return "", string(receivedMessage)
  32148. }
  32149. func RemoveRepeatedPurviewElement2(arr []string) (newArr []string) {
  32150. newArr = make([]string, 0)
  32151. for i := 0; i < len(arr); i++ {
  32152. repeat := false
  32153. for j := i + 1; j < len(arr); j++ {
  32154. if arr[i] == arr[j] {
  32155. repeat = true
  32156. break
  32157. }
  32158. }
  32159. if !repeat {
  32160. newArr = append(newArr, arr[i])
  32161. }
  32162. }
  32163. return
  32164. }
  32165. func getBirthdateAndAge(idNumber string) (string, int, error) {
  32166. if len(idNumber) != 18 {
  32167. return "", 0, fmt.Errorf("invalid ID number length. It should be 18 digits")
  32168. }
  32169. // 提取出生日期
  32170. year, err := strconv.Atoi(idNumber[6:10])
  32171. if err != nil {
  32172. return "", 0, err
  32173. }
  32174. month, err := strconv.Atoi(idNumber[10:12])
  32175. if err != nil {
  32176. return "", 0, err
  32177. }
  32178. day, err := strconv.Atoi(idNumber[12:14])
  32179. if err != nil {
  32180. return "", 0, err
  32181. }
  32182. // 格式化生日字符串
  32183. birthdate := time.Date(year, time.Month(month), day, 0, 0, 0, 0, time.UTC)
  32184. birthdateFormatted := birthdate.Format("2006-01-02")
  32185. // 计算年龄
  32186. today := time.Now()
  32187. age := today.Year() - birthdate.Year()
  32188. if today.YearDay() < birthdate.YearDay() {
  32189. age--
  32190. }
  32191. return birthdateFormatted, age, nil
  32192. }