his_api_controller.go 1.3MB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088190891909019091190921909319094190951909619097190981909919100191011910219103191041910519106191071910819109191101911119112191131911419115191161911719118191191912019121191221912319124191251912619127191281912919130191311913219133191341913519136191371913819139191401914119142191431914419145191461914719148191491915019151191521915319154191551915619157191581915919160191611916219163191641916519166191671916819169191701917119172191731917419175191761917719178191791918019181191821918319184191851918619187191881918919190191911919219193191941919519196191971919819199192001920119202192031920419205192061920719208192091921019211192121921319214192151921619217192181921919220192211922219223192241922519226192271922819229192301923119232192331923419235192361923719238192391924019241192421924319244192451924619247192481924919250192511925219253192541925519256192571925819259192601926119262192631926419265192661926719268192691927019271192721927319274192751927619277192781927919280192811928219283192841928519286192871928819289192901929119292192931929419295192961929719298192991930019301193021930319304193051930619307193081930919310193111931219313193141931519316193171931819319193201932119322193231932419325193261932719328193291933019331193321933319334193351933619337193381933919340193411934219343193441934519346193471934819349193501935119352193531935419355193561935719358193591936019361193621936319364193651936619367193681936919370193711937219373193741937519376193771937819379193801938119382193831938419385193861938719388193891939019391193921939319394193951939619397193981939919400194011940219403194041940519406194071940819409194101941119412194131941419415194161941719418194191942019421194221942319424194251942619427194281942919430194311943219433194341943519436194371943819439194401944119442194431944419445194461944719448194491945019451194521945319454194551945619457194581945919460194611946219463194641946519466194671946819469194701947119472194731947419475194761947719478194791948019481194821948319484194851948619487194881948919490194911949219493194941949519496194971949819499195001950119502195031950419505195061950719508195091951019511195121951319514195151951619517195181951919520195211952219523195241952519526195271952819529195301953119532195331953419535195361953719538195391954019541195421954319544195451954619547195481954919550195511955219553195541955519556195571955819559195601956119562195631956419565195661956719568195691957019571195721957319574195751957619577195781957919580195811958219583195841958519586195871958819589195901959119592195931959419595195961959719598195991960019601196021960319604196051960619607196081960919610196111961219613196141961519616196171961819619196201962119622196231962419625196261962719628196291963019631196321963319634196351963619637196381963919640196411964219643196441964519646196471964819649196501965119652196531965419655196561965719658196591966019661196621966319664196651966619667196681966919670196711967219673196741967519676196771967819679196801968119682196831968419685196861968719688196891969019691196921969319694196951969619697196981969919700197011970219703197041970519706197071970819709197101971119712197131971419715197161971719718197191972019721197221972319724197251972619727197281972919730197311973219733197341973519736197371973819739197401974119742197431974419745197461974719748197491975019751197521975319754197551975619757197581975919760197611976219763197641976519766197671976819769197701977119772197731977419775197761977719778197791978019781197821978319784197851978619787197881978919790197911979219793197941979519796197971979819799198001980119802198031980419805198061980719808198091981019811198121981319814198151981619817198181981919820198211982219823198241982519826198271982819829198301983119832198331983419835198361983719838198391984019841198421984319844198451984619847198481984919850198511985219853198541985519856198571985819859198601986119862198631986419865198661986719868198691987019871198721987319874198751987619877198781987919880198811988219883198841988519886198871988819889198901989119892198931989419895198961989719898198991990019901199021990319904199051990619907199081990919910199111991219913199141991519916199171991819919199201992119922199231992419925199261992719928199291993019931199321993319934199351993619937199381993919940199411994219943199441994519946199471994819949199501995119952199531995419955199561995719958199591996019961199621996319964199651996619967199681996919970199711997219973199741997519976199771997819979199801998119982199831998419985199861998719988199891999019991199921999319994199951999619997199981999920000200012000220003200042000520006200072000820009200102001120012200132001420015200162001720018200192002020021200222002320024200252002620027200282002920030200312003220033200342003520036200372003820039200402004120042200432004420045200462004720048200492005020051200522005320054200552005620057200582005920060200612006220063200642006520066200672006820069200702007120072200732007420075200762007720078200792008020081200822008320084200852008620087200882008920090200912009220093200942009520096200972009820099201002010120102201032010420105201062010720108201092011020111201122011320114201152011620117201182011920120201212012220123201242012520126201272012820129201302013120132201332013420135201362013720138201392014020141201422014320144201452014620147201482014920150201512015220153201542015520156201572015820159201602016120162201632016420165201662016720168201692017020171201722017320174201752017620177201782017920180201812018220183201842018520186201872018820189201902019120192201932019420195201962019720198201992020020201202022020320204202052020620207202082020920210202112021220213202142021520216202172021820219202202022120222202232022420225202262022720228202292023020231202322023320234202352023620237202382023920240202412024220243202442024520246202472024820249202502025120252202532025420255202562025720258202592026020261202622026320264202652026620267202682026920270202712027220273202742027520276202772027820279202802028120282202832028420285202862028720288202892029020291202922029320294202952029620297202982029920300203012030220303203042030520306203072030820309203102031120312203132031420315203162031720318203192032020321203222032320324203252032620327203282032920330203312033220333203342033520336203372033820339203402034120342203432034420345203462034720348203492035020351203522035320354203552035620357203582035920360203612036220363203642036520366203672036820369203702037120372203732037420375203762037720378203792038020381203822038320384203852038620387203882038920390203912039220393203942039520396203972039820399204002040120402204032040420405204062040720408204092041020411204122041320414204152041620417204182041920420204212042220423204242042520426204272042820429204302043120432204332043420435204362043720438204392044020441204422044320444204452044620447204482044920450204512045220453204542045520456204572045820459204602046120462204632046420465204662046720468204692047020471204722047320474204752047620477204782047920480204812048220483204842048520486204872048820489204902049120492204932049420495204962049720498204992050020501205022050320504205052050620507205082050920510205112051220513205142051520516205172051820519205202052120522205232052420525205262052720528205292053020531205322053320534205352053620537205382053920540205412054220543205442054520546205472054820549205502055120552205532055420555205562055720558205592056020561205622056320564205652056620567205682056920570205712057220573205742057520576205772057820579205802058120582205832058420585205862058720588205892059020591205922059320594205952059620597205982059920600206012060220603206042060520606206072060820609206102061120612206132061420615206162061720618206192062020621206222062320624206252062620627206282062920630206312063220633206342063520636206372063820639206402064120642206432064420645206462064720648206492065020651206522065320654206552065620657206582065920660206612066220663206642066520666206672066820669206702067120672206732067420675206762067720678206792068020681206822068320684206852068620687206882068920690206912069220693206942069520696206972069820699207002070120702207032070420705207062070720708207092071020711207122071320714207152071620717207182071920720207212072220723207242072520726207272072820729207302073120732207332073420735207362073720738207392074020741207422074320744207452074620747207482074920750207512075220753207542075520756207572075820759207602076120762207632076420765207662076720768207692077020771207722077320774207752077620777207782077920780207812078220783207842078520786207872078820789207902079120792207932079420795207962079720798207992080020801208022080320804208052080620807208082080920810208112081220813208142081520816208172081820819208202082120822208232082420825208262082720828208292083020831208322083320834208352083620837208382083920840208412084220843208442084520846208472084820849208502085120852208532085420855208562085720858208592086020861208622086320864208652086620867208682086920870208712087220873208742087520876208772087820879208802088120882208832088420885208862088720888208892089020891208922089320894208952089620897208982089920900209012090220903209042090520906209072090820909209102091120912209132091420915209162091720918209192092020921209222092320924209252092620927209282092920930209312093220933209342093520936209372093820939209402094120942209432094420945209462094720948209492095020951209522095320954209552095620957209582095920960209612096220963209642096520966209672096820969209702097120972209732097420975209762097720978209792098020981209822098320984209852098620987209882098920990209912099220993209942099520996209972099820999210002100121002210032100421005210062100721008210092101021011210122101321014210152101621017210182101921020210212102221023210242102521026210272102821029210302103121032210332103421035210362103721038210392104021041210422104321044210452104621047210482104921050210512105221053210542105521056210572105821059210602106121062210632106421065210662106721068210692107021071210722107321074210752107621077210782107921080210812108221083210842108521086210872108821089210902109121092210932109421095210962109721098210992110021101211022110321104211052110621107211082110921110211112111221113211142111521116211172111821119211202112121122211232112421125211262112721128211292113021131211322113321134211352113621137211382113921140211412114221143211442114521146211472114821149211502115121152211532115421155211562115721158211592116021161211622116321164211652116621167211682116921170211712117221173211742117521176211772117821179211802118121182211832118421185211862118721188211892119021191211922119321194211952119621197211982119921200212012120221203212042120521206212072120821209212102121121212212132121421215212162121721218212192122021221212222122321224212252122621227212282122921230212312123221233212342123521236212372123821239212402124121242212432124421245212462124721248212492125021251212522125321254212552125621257212582125921260212612126221263212642126521266212672126821269212702127121272212732127421275212762127721278212792128021281212822128321284212852128621287212882128921290212912129221293212942129521296212972129821299213002130121302213032130421305213062130721308213092131021311213122131321314213152131621317213182131921320213212132221323213242132521326213272132821329213302133121332213332133421335213362133721338213392134021341213422134321344213452134621347213482134921350213512135221353213542135521356213572135821359213602136121362213632136421365213662136721368213692137021371213722137321374213752137621377213782137921380213812138221383213842138521386213872138821389213902139121392213932139421395213962139721398213992140021401214022140321404214052140621407214082140921410214112141221413214142141521416214172141821419214202142121422214232142421425214262142721428214292143021431214322143321434214352143621437214382143921440214412144221443214442144521446214472144821449214502145121452214532145421455214562145721458214592146021461214622146321464214652146621467214682146921470214712147221473214742147521476214772147821479214802148121482214832148421485214862148721488214892149021491214922149321494214952149621497214982149921500215012150221503215042150521506215072150821509215102151121512215132151421515215162151721518215192152021521215222152321524215252152621527215282152921530215312153221533215342153521536215372153821539215402154121542215432154421545215462154721548215492155021551215522155321554215552155621557215582155921560215612156221563215642156521566215672156821569215702157121572215732157421575215762157721578215792158021581215822158321584215852158621587215882158921590215912159221593215942159521596215972159821599216002160121602216032160421605216062160721608216092161021611216122161321614216152161621617216182161921620216212162221623216242162521626216272162821629216302163121632216332163421635216362163721638216392164021641216422164321644216452164621647216482164921650216512165221653216542165521656216572165821659216602166121662216632166421665216662166721668216692167021671216722167321674216752167621677216782167921680216812168221683216842168521686216872168821689216902169121692216932169421695216962169721698216992170021701217022170321704217052170621707217082170921710217112171221713217142171521716217172171821719217202172121722217232172421725217262172721728217292173021731217322173321734217352173621737217382173921740217412174221743217442174521746217472174821749217502175121752217532175421755217562175721758217592176021761217622176321764217652176621767217682176921770217712177221773217742177521776217772177821779217802178121782217832178421785217862178721788217892179021791217922179321794217952179621797217982179921800218012180221803218042180521806218072180821809218102181121812218132181421815218162181721818218192182021821218222182321824218252182621827218282182921830218312183221833218342183521836218372183821839218402184121842218432184421845218462184721848218492185021851218522185321854218552185621857218582185921860218612186221863218642186521866218672186821869218702187121872218732187421875218762187721878218792188021881218822188321884218852188621887218882188921890218912189221893218942189521896218972189821899219002190121902219032190421905219062190721908219092191021911219122191321914219152191621917219182191921920219212192221923219242192521926219272192821929219302193121932219332193421935219362193721938219392194021941219422194321944219452194621947219482194921950219512195221953219542195521956219572195821959219602196121962219632196421965219662196721968219692197021971219722197321974219752197621977219782197921980219812198221983219842198521986219872198821989219902199121992219932199421995219962199721998219992200022001220022200322004220052200622007220082200922010220112201222013220142201522016220172201822019220202202122022220232202422025220262202722028220292203022031220322203322034220352203622037220382203922040220412204222043220442204522046220472204822049220502205122052220532205422055220562205722058220592206022061220622206322064220652206622067220682206922070220712207222073220742207522076220772207822079220802208122082220832208422085220862208722088220892209022091220922209322094220952209622097220982209922100221012210222103221042210522106221072210822109221102211122112221132211422115221162211722118221192212022121221222212322124221252212622127221282212922130221312213222133221342213522136221372213822139221402214122142221432214422145221462214722148221492215022151221522215322154221552215622157221582215922160221612216222163221642216522166221672216822169221702217122172221732217422175221762217722178221792218022181221822218322184221852218622187221882218922190221912219222193221942219522196221972219822199222002220122202222032220422205222062220722208222092221022211222122221322214222152221622217222182221922220222212222222223222242222522226222272222822229222302223122232222332223422235222362223722238222392224022241222422224322244222452224622247222482224922250222512225222253222542225522256222572225822259222602226122262222632226422265222662226722268222692227022271222722227322274222752227622277222782227922280222812228222283222842228522286222872228822289222902229122292222932229422295222962229722298222992230022301223022230322304223052230622307223082230922310223112231222313223142231522316223172231822319223202232122322223232232422325223262232722328223292233022331223322233322334223352233622337223382233922340223412234222343223442234522346223472234822349223502235122352223532235422355223562235722358223592236022361223622236322364223652236622367223682236922370223712237222373223742237522376223772237822379223802238122382223832238422385223862238722388223892239022391223922239322394223952239622397223982239922400224012240222403224042240522406224072240822409224102241122412224132241422415224162241722418224192242022421224222242322424224252242622427224282242922430224312243222433224342243522436224372243822439224402244122442224432244422445224462244722448224492245022451224522245322454224552245622457224582245922460224612246222463224642246522466224672246822469224702247122472224732247422475224762247722478224792248022481224822248322484224852248622487224882248922490224912249222493224942249522496224972249822499225002250122502225032250422505225062250722508225092251022511225122251322514225152251622517225182251922520225212252222523225242252522526225272252822529225302253122532225332253422535225362253722538225392254022541225422254322544225452254622547225482254922550225512255222553225542255522556225572255822559225602256122562225632256422565225662256722568225692257022571225722257322574225752257622577225782257922580225812258222583225842258522586225872258822589225902259122592225932259422595225962259722598225992260022601226022260322604226052260622607226082260922610226112261222613226142261522616226172261822619226202262122622226232262422625226262262722628226292263022631226322263322634226352263622637226382263922640226412264222643226442264522646226472264822649226502265122652226532265422655226562265722658226592266022661226622266322664226652266622667226682266922670226712267222673226742267522676226772267822679226802268122682226832268422685226862268722688226892269022691226922269322694226952269622697226982269922700227012270222703227042270522706227072270822709227102271122712227132271422715227162271722718227192272022721227222272322724227252272622727227282272922730227312273222733227342273522736227372273822739227402274122742227432274422745227462274722748227492275022751227522275322754227552275622757227582275922760227612276222763227642276522766227672276822769227702277122772227732277422775227762277722778227792278022781227822278322784227852278622787227882278922790227912279222793227942279522796227972279822799228002280122802228032280422805228062280722808228092281022811228122281322814228152281622817228182281922820228212282222823228242282522826228272282822829228302283122832228332283422835228362283722838228392284022841228422284322844228452284622847228482284922850228512285222853228542285522856228572285822859228602286122862228632286422865228662286722868228692287022871228722287322874228752287622877228782287922880228812288222883228842288522886228872288822889228902289122892228932289422895228962289722898228992290022901229022290322904229052290622907229082290922910229112291222913229142291522916229172291822919229202292122922229232292422925229262292722928229292293022931229322293322934229352293622937229382293922940229412294222943229442294522946229472294822949229502295122952229532295422955229562295722958229592296022961229622296322964229652296622967229682296922970229712297222973229742297522976229772297822979229802298122982229832298422985229862298722988229892299022991229922299322994229952299622997229982299923000230012300223003230042300523006230072300823009230102301123012230132301423015230162301723018230192302023021230222302323024230252302623027230282302923030230312303223033230342303523036230372303823039230402304123042230432304423045230462304723048230492305023051230522305323054230552305623057230582305923060230612306223063230642306523066230672306823069230702307123072230732307423075230762307723078230792308023081230822308323084230852308623087230882308923090230912309223093230942309523096230972309823099231002310123102231032310423105231062310723108231092311023111231122311323114231152311623117231182311923120231212312223123231242312523126231272312823129231302313123132231332313423135231362313723138231392314023141231422314323144231452314623147231482314923150231512315223153231542315523156231572315823159231602316123162231632316423165231662316723168231692317023171231722317323174231752317623177231782317923180231812318223183231842318523186231872318823189231902319123192231932319423195231962319723198231992320023201232022320323204232052320623207232082320923210232112321223213232142321523216232172321823219232202322123222232232322423225232262322723228232292323023231232322323323234232352323623237232382323923240232412324223243232442324523246232472324823249232502325123252232532325423255232562325723258232592326023261232622326323264232652326623267232682326923270232712327223273232742327523276232772327823279232802328123282232832328423285232862328723288232892329023291232922329323294232952329623297232982329923300233012330223303233042330523306233072330823309233102331123312233132331423315233162331723318233192332023321233222332323324233252332623327233282332923330233312333223333233342333523336233372333823339233402334123342233432334423345233462334723348233492335023351233522335323354233552335623357233582335923360233612336223363233642336523366233672336823369233702337123372233732337423375233762337723378233792338023381233822338323384233852338623387233882338923390233912339223393233942339523396233972339823399234002340123402234032340423405234062340723408234092341023411234122341323414234152341623417234182341923420234212342223423234242342523426234272342823429234302343123432234332343423435234362343723438234392344023441234422344323444234452344623447234482344923450234512345223453234542345523456234572345823459234602346123462234632346423465234662346723468234692347023471234722347323474234752347623477234782347923480234812348223483234842348523486234872348823489234902349123492234932349423495234962349723498234992350023501235022350323504235052350623507235082350923510235112351223513235142351523516235172351823519235202352123522235232352423525235262352723528235292353023531235322353323534235352353623537235382353923540235412354223543235442354523546235472354823549235502355123552235532355423555235562355723558235592356023561235622356323564235652356623567235682356923570235712357223573235742357523576235772357823579235802358123582235832358423585235862358723588235892359023591235922359323594235952359623597235982359923600236012360223603236042360523606236072360823609236102361123612236132361423615236162361723618236192362023621236222362323624236252362623627236282362923630236312363223633236342363523636236372363823639236402364123642236432364423645236462364723648236492365023651236522365323654236552365623657236582365923660236612366223663236642366523666236672366823669236702367123672236732367423675236762367723678236792368023681236822368323684236852368623687236882368923690236912369223693236942369523696236972369823699237002370123702237032370423705237062370723708237092371023711237122371323714237152371623717237182371923720237212372223723237242372523726237272372823729237302373123732237332373423735237362373723738237392374023741237422374323744237452374623747237482374923750237512375223753237542375523756237572375823759237602376123762237632376423765237662376723768237692377023771237722377323774237752377623777237782377923780237812378223783237842378523786237872378823789237902379123792237932379423795237962379723798237992380023801238022380323804238052380623807238082380923810238112381223813238142381523816238172381823819238202382123822238232382423825238262382723828238292383023831238322383323834238352383623837238382383923840238412384223843238442384523846238472384823849238502385123852238532385423855238562385723858238592386023861238622386323864238652386623867238682386923870238712387223873238742387523876238772387823879238802388123882238832388423885238862388723888238892389023891238922389323894238952389623897238982389923900239012390223903239042390523906239072390823909239102391123912239132391423915239162391723918239192392023921239222392323924239252392623927239282392923930239312393223933239342393523936239372393823939239402394123942239432394423945239462394723948239492395023951239522395323954239552395623957239582395923960239612396223963239642396523966239672396823969239702397123972239732397423975239762397723978239792398023981239822398323984239852398623987239882398923990239912399223993239942399523996239972399823999240002400124002240032400424005240062400724008240092401024011240122401324014240152401624017240182401924020240212402224023240242402524026240272402824029240302403124032240332403424035240362403724038240392404024041240422404324044240452404624047240482404924050240512405224053240542405524056240572405824059240602406124062240632406424065240662406724068240692407024071240722407324074240752407624077240782407924080240812408224083240842408524086240872408824089240902409124092240932409424095240962409724098240992410024101241022410324104241052410624107241082410924110241112411224113241142411524116241172411824119241202412124122241232412424125241262412724128241292413024131241322413324134241352413624137241382413924140241412414224143241442414524146241472414824149241502415124152241532415424155241562415724158241592416024161241622416324164241652416624167241682416924170241712417224173241742417524176241772417824179241802418124182241832418424185241862418724188241892419024191241922419324194241952419624197241982419924200242012420224203242042420524206242072420824209242102421124212242132421424215242162421724218242192422024221242222422324224242252422624227242282422924230242312423224233242342423524236242372423824239242402424124242242432424424245242462424724248242492425024251242522425324254242552425624257242582425924260242612426224263242642426524266242672426824269242702427124272242732427424275242762427724278242792428024281242822428324284242852428624287242882428924290242912429224293242942429524296242972429824299243002430124302243032430424305243062430724308243092431024311243122431324314243152431624317243182431924320243212432224323243242432524326243272432824329243302433124332243332433424335243362433724338243392434024341243422434324344243452434624347243482434924350243512435224353243542435524356243572435824359243602436124362243632436424365243662436724368243692437024371243722437324374243752437624377243782437924380243812438224383243842438524386243872438824389243902439124392243932439424395243962439724398243992440024401244022440324404244052440624407244082440924410244112441224413244142441524416244172441824419244202442124422244232442424425244262442724428244292443024431244322443324434244352443624437244382443924440244412444224443244442444524446244472444824449244502445124452244532445424455244562445724458244592446024461244622446324464244652446624467244682446924470244712447224473244742447524476244772447824479244802448124482244832448424485244862448724488244892449024491244922449324494244952449624497244982449924500245012450224503245042450524506245072450824509245102451124512245132451424515245162451724518245192452024521245222452324524245252452624527245282452924530245312453224533245342453524536245372453824539245402454124542245432454424545245462454724548245492455024551245522455324554245552455624557245582455924560245612456224563245642456524566245672456824569245702457124572245732457424575245762457724578245792458024581245822458324584245852458624587245882458924590245912459224593245942459524596245972459824599246002460124602246032460424605246062460724608246092461024611246122461324614246152461624617246182461924620246212462224623246242462524626246272462824629246302463124632246332463424635246362463724638246392464024641246422464324644246452464624647246482464924650246512465224653246542465524656246572465824659246602466124662246632466424665246662466724668246692467024671246722467324674246752467624677246782467924680246812468224683246842468524686246872468824689246902469124692246932469424695246962469724698246992470024701247022470324704247052470624707247082470924710247112471224713247142471524716247172471824719247202472124722247232472424725247262472724728247292473024731247322473324734247352473624737247382473924740247412474224743247442474524746247472474824749247502475124752247532475424755247562475724758247592476024761247622476324764247652476624767247682476924770247712477224773247742477524776247772477824779247802478124782247832478424785247862478724788247892479024791247922479324794247952479624797247982479924800248012480224803248042480524806248072480824809248102481124812248132481424815248162481724818248192482024821248222482324824248252482624827248282482924830248312483224833248342483524836248372483824839248402484124842248432484424845248462484724848248492485024851248522485324854248552485624857248582485924860248612486224863248642486524866248672486824869248702487124872248732487424875248762487724878248792488024881248822488324884248852488624887248882488924890248912489224893248942489524896248972489824899249002490124902249032490424905249062490724908249092491024911249122491324914249152491624917249182491924920249212492224923249242492524926249272492824929249302493124932249332493424935249362493724938249392494024941249422494324944249452494624947249482494924950249512495224953249542495524956249572495824959249602496124962249632496424965249662496724968249692497024971249722497324974249752497624977249782497924980249812498224983249842498524986249872498824989249902499124992249932499424995249962499724998249992500025001250022500325004250052500625007250082500925010250112501225013250142501525016250172501825019250202502125022250232502425025250262502725028250292503025031250322503325034250352503625037250382503925040250412504225043250442504525046250472504825049250502505125052250532505425055250562505725058250592506025061250622506325064250652506625067250682506925070250712507225073250742507525076250772507825079250802508125082250832508425085250862508725088250892509025091250922509325094250952509625097250982509925100251012510225103251042510525106251072510825109251102511125112251132511425115251162511725118251192512025121251222512325124251252512625127251282512925130251312513225133251342513525136251372513825139251402514125142251432514425145251462514725148251492515025151251522515325154251552515625157251582515925160251612516225163251642516525166251672516825169251702517125172251732517425175251762517725178251792518025181251822518325184251852518625187251882518925190251912519225193251942519525196251972519825199252002520125202252032520425205252062520725208252092521025211252122521325214252152521625217252182521925220252212522225223252242522525226252272522825229252302523125232252332523425235252362523725238252392524025241252422524325244252452524625247252482524925250252512525225253252542525525256252572525825259252602526125262252632526425265252662526725268252692527025271252722527325274252752527625277252782527925280252812528225283252842528525286252872528825289252902529125292252932529425295252962529725298252992530025301253022530325304253052530625307253082530925310253112531225313253142531525316253172531825319253202532125322253232532425325253262532725328253292533025331253322533325334253352533625337253382533925340253412534225343253442534525346253472534825349253502535125352253532535425355253562535725358253592536025361253622536325364253652536625367253682536925370253712537225373253742537525376253772537825379253802538125382253832538425385253862538725388253892539025391253922539325394253952539625397253982539925400254012540225403254042540525406254072540825409254102541125412254132541425415254162541725418254192542025421254222542325424254252542625427254282542925430254312543225433254342543525436254372543825439254402544125442254432544425445254462544725448254492545025451254522545325454254552545625457254582545925460254612546225463254642546525466254672546825469254702547125472254732547425475254762547725478254792548025481254822548325484254852548625487254882548925490254912549225493254942549525496254972549825499255002550125502255032550425505255062550725508255092551025511255122551325514255152551625517255182551925520255212552225523255242552525526255272552825529255302553125532255332553425535255362553725538255392554025541255422554325544255452554625547255482554925550255512555225553255542555525556255572555825559255602556125562255632556425565255662556725568255692557025571255722557325574255752557625577255782557925580255812558225583255842558525586255872558825589255902559125592255932559425595255962559725598255992560025601256022560325604256052560625607256082560925610256112561225613256142561525616256172561825619256202562125622256232562425625256262562725628256292563025631256322563325634256352563625637256382563925640256412564225643256442564525646256472564825649256502565125652256532565425655256562565725658256592566025661256622566325664256652566625667256682566925670256712567225673256742567525676256772567825679256802568125682256832568425685256862568725688256892569025691256922569325694256952569625697256982569925700257012570225703257042570525706257072570825709257102571125712257132571425715257162571725718257192572025721257222572325724257252572625727257282572925730257312573225733257342573525736257372573825739257402574125742257432574425745257462574725748257492575025751257522575325754257552575625757257582575925760257612576225763257642576525766257672576825769257702577125772257732577425775257762577725778257792578025781257822578325784257852578625787257882578925790257912579225793257942579525796257972579825799258002580125802258032580425805258062580725808258092581025811258122581325814258152581625817258182581925820258212582225823258242582525826258272582825829258302583125832258332583425835258362583725838258392584025841258422584325844258452584625847258482584925850258512585225853258542585525856258572585825859258602586125862258632586425865258662586725868258692587025871258722587325874258752587625877258782587925880258812588225883258842588525886258872588825889258902589125892258932589425895258962589725898258992590025901259022590325904259052590625907259082590925910259112591225913259142591525916259172591825919259202592125922259232592425925259262592725928259292593025931259322593325934259352593625937259382593925940259412594225943259442594525946259472594825949259502595125952259532595425955259562595725958259592596025961259622596325964259652596625967259682596925970259712597225973259742597525976259772597825979259802598125982259832598425985259862598725988259892599025991259922599325994259952599625997259982599926000260012600226003260042600526006260072600826009260102601126012260132601426015260162601726018260192602026021260222602326024260252602626027260282602926030260312603226033260342603526036260372603826039260402604126042260432604426045260462604726048260492605026051260522605326054260552605626057260582605926060260612606226063260642606526066260672606826069260702607126072260732607426075260762607726078260792608026081260822608326084260852608626087260882608926090260912609226093260942609526096260972609826099261002610126102261032610426105261062610726108261092611026111261122611326114261152611626117261182611926120261212612226123261242612526126261272612826129261302613126132261332613426135261362613726138261392614026141261422614326144261452614626147261482614926150261512615226153261542615526156261572615826159261602616126162261632616426165261662616726168261692617026171261722617326174261752617626177261782617926180261812618226183261842618526186261872618826189261902619126192261932619426195261962619726198261992620026201262022620326204262052620626207262082620926210262112621226213262142621526216262172621826219262202622126222262232622426225262262622726228262292623026231262322623326234262352623626237262382623926240262412624226243262442624526246262472624826249262502625126252262532625426255262562625726258262592626026261262622626326264262652626626267262682626926270262712627226273262742627526276262772627826279262802628126282262832628426285262862628726288262892629026291262922629326294262952629626297262982629926300263012630226303263042630526306263072630826309263102631126312263132631426315263162631726318263192632026321263222632326324263252632626327263282632926330263312633226333263342633526336263372633826339263402634126342263432634426345263462634726348263492635026351263522635326354263552635626357263582635926360263612636226363263642636526366263672636826369263702637126372263732637426375263762637726378263792638026381263822638326384263852638626387263882638926390263912639226393263942639526396263972639826399264002640126402264032640426405264062640726408264092641026411264122641326414264152641626417264182641926420264212642226423264242642526426264272642826429264302643126432264332643426435264362643726438264392644026441264422644326444264452644626447264482644926450264512645226453264542645526456264572645826459264602646126462264632646426465264662646726468264692647026471264722647326474264752647626477264782647926480264812648226483264842648526486264872648826489264902649126492264932649426495264962649726498264992650026501265022650326504265052650626507265082650926510265112651226513265142651526516265172651826519265202652126522265232652426525265262652726528265292653026531265322653326534265352653626537265382653926540265412654226543265442654526546265472654826549265502655126552265532655426555265562655726558265592656026561265622656326564265652656626567265682656926570265712657226573265742657526576265772657826579265802658126582265832658426585265862658726588265892659026591265922659326594265952659626597265982659926600266012660226603266042660526606266072660826609266102661126612266132661426615266162661726618266192662026621266222662326624266252662626627266282662926630266312663226633266342663526636266372663826639266402664126642266432664426645266462664726648266492665026651266522665326654266552665626657266582665926660266612666226663266642666526666266672666826669266702667126672266732667426675266762667726678266792668026681266822668326684266852668626687266882668926690266912669226693266942669526696266972669826699267002670126702267032670426705267062670726708267092671026711267122671326714267152671626717267182671926720267212672226723267242672526726267272672826729267302673126732267332673426735267362673726738267392674026741267422674326744267452674626747267482674926750267512675226753267542675526756267572675826759267602676126762267632676426765267662676726768267692677026771267722677326774267752677626777267782677926780267812678226783267842678526786267872678826789267902679126792267932679426795267962679726798267992680026801268022680326804268052680626807268082680926810268112681226813268142681526816268172681826819268202682126822268232682426825268262682726828268292683026831268322683326834268352683626837268382683926840268412684226843268442684526846268472684826849268502685126852268532685426855268562685726858268592686026861268622686326864268652686626867268682686926870268712687226873268742687526876268772687826879268802688126882268832688426885268862688726888268892689026891268922689326894268952689626897268982689926900269012690226903269042690526906269072690826909269102691126912269132691426915269162691726918269192692026921269222692326924269252692626927269282692926930269312693226933269342693526936269372693826939269402694126942269432694426945269462694726948269492695026951269522695326954269552695626957269582695926960269612696226963269642696526966269672696826969269702697126972269732697426975269762697726978269792698026981269822698326984269852698626987269882698926990269912699226993269942699526996269972699826999270002700127002270032700427005270062700727008270092701027011270122701327014270152701627017270182701927020270212702227023270242702527026270272702827029270302703127032270332703427035270362703727038270392704027041270422704327044270452704627047270482704927050270512705227053270542705527056270572705827059270602706127062270632706427065270662706727068270692707027071270722707327074270752707627077270782707927080270812708227083270842708527086270872708827089270902709127092270932709427095270962709727098270992710027101271022710327104271052710627107271082710927110271112711227113271142711527116271172711827119271202712127122271232712427125271262712727128271292713027131271322713327134271352713627137271382713927140271412714227143271442714527146271472714827149271502715127152271532715427155271562715727158271592716027161271622716327164271652716627167271682716927170271712717227173271742717527176271772717827179271802718127182271832718427185271862718727188271892719027191271922719327194271952719627197271982719927200272012720227203272042720527206272072720827209272102721127212272132721427215272162721727218272192722027221272222722327224272252722627227272282722927230272312723227233272342723527236272372723827239272402724127242272432724427245272462724727248272492725027251272522725327254272552725627257272582725927260272612726227263272642726527266272672726827269272702727127272272732727427275272762727727278272792728027281272822728327284272852728627287272882728927290272912729227293272942729527296272972729827299273002730127302273032730427305273062730727308273092731027311273122731327314273152731627317273182731927320273212732227323273242732527326273272732827329273302733127332273332733427335273362733727338273392734027341273422734327344273452734627347273482734927350273512735227353273542735527356273572735827359273602736127362273632736427365273662736727368273692737027371273722737327374273752737627377273782737927380273812738227383273842738527386273872738827389273902739127392273932739427395273962739727398273992740027401274022740327404274052740627407274082740927410274112741227413274142741527416274172741827419274202742127422274232742427425274262742727428274292743027431274322743327434274352743627437274382743927440274412744227443274442744527446274472744827449274502745127452274532745427455274562745727458274592746027461274622746327464274652746627467274682746927470274712747227473274742747527476274772747827479274802748127482274832748427485274862748727488274892749027491274922749327494274952749627497274982749927500275012750227503275042750527506275072750827509275102751127512275132751427515275162751727518275192752027521275222752327524275252752627527275282752927530275312753227533275342753527536275372753827539275402754127542275432754427545275462754727548275492755027551275522755327554275552755627557275582755927560275612756227563275642756527566275672756827569275702757127572275732757427575275762757727578275792758027581275822758327584275852758627587275882758927590275912759227593275942759527596275972759827599276002760127602276032760427605276062760727608276092761027611276122761327614276152761627617276182761927620276212762227623276242762527626276272762827629276302763127632276332763427635276362763727638276392764027641276422764327644276452764627647276482764927650276512765227653276542765527656276572765827659276602766127662276632766427665276662766727668276692767027671276722767327674276752767627677276782767927680276812768227683276842768527686276872768827689276902769127692276932769427695276962769727698276992770027701277022770327704277052770627707277082770927710277112771227713277142771527716277172771827719277202772127722277232772427725277262772727728277292773027731277322773327734277352773627737277382773927740277412774227743277442774527746277472774827749277502775127752277532775427755277562775727758277592776027761277622776327764277652776627767277682776927770277712777227773277742777527776277772777827779277802778127782277832778427785277862778727788277892779027791277922779327794277952779627797277982779927800278012780227803278042780527806278072780827809278102781127812278132781427815278162781727818278192782027821278222782327824278252782627827278282782927830278312783227833278342783527836278372783827839278402784127842278432784427845278462784727848278492785027851278522785327854278552785627857278582785927860278612786227863278642786527866278672786827869278702787127872278732787427875278762787727878278792788027881278822788327884278852788627887278882788927890278912789227893278942789527896278972789827899279002790127902279032790427905279062790727908279092791027911279122791327914279152791627917279182791927920279212792227923279242792527926279272792827929279302793127932279332793427935279362793727938279392794027941279422794327944279452794627947279482794927950279512795227953279542795527956279572795827959279602796127962279632796427965279662796727968279692797027971279722797327974279752797627977279782797927980279812798227983279842798527986279872798827989279902799127992279932799427995279962799727998279992800028001280022800328004280052800628007280082800928010280112801228013280142801528016280172801828019280202802128022280232802428025280262802728028280292803028031280322803328034280352803628037280382803928040280412804228043280442804528046280472804828049280502805128052280532805428055280562805728058280592806028061280622806328064280652806628067280682806928070280712807228073280742807528076280772807828079280802808128082280832808428085280862808728088280892809028091280922809328094280952809628097280982809928100281012810228103281042810528106281072810828109281102811128112281132811428115281162811728118281192812028121281222812328124281252812628127281282812928130281312813228133281342813528136281372813828139281402814128142281432814428145281462814728148281492815028151281522815328154281552815628157281582815928160281612816228163281642816528166281672816828169281702817128172281732817428175281762817728178281792818028181281822818328184281852818628187281882818928190281912819228193281942819528196281972819828199282002820128202282032820428205282062820728208282092821028211282122821328214282152821628217282182821928220282212822228223282242822528226282272822828229282302823128232282332823428235282362823728238282392824028241282422824328244282452824628247282482824928250282512825228253282542825528256282572825828259282602826128262282632826428265282662826728268282692827028271282722827328274282752827628277282782827928280282812828228283282842828528286282872828828289282902829128292282932829428295282962829728298282992830028301283022830328304283052830628307283082830928310283112831228313283142831528316283172831828319283202832128322283232832428325283262832728328283292833028331283322833328334283352833628337283382833928340283412834228343283442834528346283472834828349283502835128352283532835428355283562835728358283592836028361283622836328364283652836628367283682836928370283712837228373283742837528376283772837828379283802838128382283832838428385283862838728388283892839028391283922839328394283952839628397283982839928400284012840228403284042840528406284072840828409284102841128412284132841428415284162841728418284192842028421284222842328424284252842628427284282842928430284312843228433284342843528436284372843828439284402844128442284432844428445284462844728448284492845028451284522845328454284552845628457284582845928460284612846228463284642846528466284672846828469284702847128472284732847428475284762847728478284792848028481284822848328484284852848628487284882848928490284912849228493284942849528496284972849828499285002850128502285032850428505285062850728508285092851028511285122851328514285152851628517285182851928520285212852228523285242852528526285272852828529285302853128532285332853428535285362853728538285392854028541285422854328544285452854628547285482854928550285512855228553285542855528556285572855828559285602856128562285632856428565285662856728568285692857028571285722857328574285752857628577285782857928580285812858228583285842858528586285872858828589285902859128592285932859428595285962859728598285992860028601286022860328604286052860628607286082860928610286112861228613286142861528616286172861828619286202862128622286232862428625286262862728628286292863028631286322863328634286352863628637286382863928640286412864228643286442864528646286472864828649286502865128652286532865428655286562865728658286592866028661286622866328664286652866628667286682866928670286712867228673286742867528676286772867828679286802868128682286832868428685286862868728688286892869028691286922869328694286952869628697286982869928700287012870228703287042870528706287072870828709287102871128712287132871428715287162871728718287192872028721287222872328724287252872628727287282872928730287312873228733287342873528736287372873828739287402874128742287432874428745287462874728748287492875028751287522875328754287552875628757287582875928760287612876228763287642876528766287672876828769287702877128772287732877428775287762877728778287792878028781287822878328784287852878628787287882878928790287912879228793287942879528796287972879828799288002880128802288032880428805288062880728808288092881028811288122881328814288152881628817288182881928820288212882228823288242882528826288272882828829288302883128832288332883428835288362883728838288392884028841288422884328844288452884628847288482884928850288512885228853288542885528856288572885828859288602886128862288632886428865288662886728868288692887028871288722887328874288752887628877288782887928880288812888228883288842888528886288872888828889288902889128892288932889428895288962889728898288992890028901289022890328904289052890628907289082890928910289112891228913289142891528916289172891828919289202892128922289232892428925289262892728928289292893028931289322893328934289352893628937289382893928940289412894228943289442894528946289472894828949289502895128952289532895428955289562895728958289592896028961289622896328964289652896628967289682896928970289712897228973289742897528976289772897828979289802898128982289832898428985289862898728988289892899028991289922899328994289952899628997289982899929000290012900229003290042900529006290072900829009290102901129012290132901429015290162901729018290192902029021290222902329024290252902629027290282902929030290312903229033290342903529036290372903829039290402904129042290432904429045290462904729048290492905029051290522905329054290552905629057290582905929060290612906229063290642906529066290672906829069290702907129072290732907429075290762907729078290792908029081290822908329084290852908629087290882908929090290912909229093290942909529096290972909829099291002910129102291032910429105291062910729108291092911029111291122911329114291152911629117291182911929120291212912229123291242912529126291272912829129291302913129132291332913429135291362913729138291392914029141291422914329144291452914629147291482914929150291512915229153291542915529156291572915829159291602916129162291632916429165291662916729168291692917029171291722917329174291752917629177291782917929180291812918229183291842918529186291872918829189291902919129192291932919429195291962919729198291992920029201292022920329204292052920629207292082920929210292112921229213292142921529216292172921829219292202922129222292232922429225292262922729228292292923029231292322923329234292352923629237292382923929240292412924229243292442924529246292472924829249292502925129252292532925429255292562925729258292592926029261292622926329264292652926629267292682926929270292712927229273292742927529276292772927829279292802928129282292832928429285292862928729288292892929029291292922929329294292952929629297292982929929300293012930229303293042930529306293072930829309293102931129312293132931429315293162931729318293192932029321293222932329324293252932629327293282932929330293312933229333293342933529336293372933829339293402934129342293432934429345293462934729348293492935029351293522935329354293552935629357293582935929360293612936229363293642936529366293672936829369293702937129372293732937429375293762937729378293792938029381293822938329384293852938629387293882938929390293912939229393293942939529396293972939829399294002940129402294032940429405294062940729408294092941029411294122941329414294152941629417294182941929420294212942229423294242942529426294272942829429294302943129432294332943429435294362943729438294392944029441294422944329444294452944629447294482944929450294512945229453294542945529456294572945829459294602946129462294632946429465294662946729468294692947029471294722947329474294752947629477294782947929480294812948229483294842948529486294872948829489294902949129492294932949429495294962949729498294992950029501295022950329504295052950629507295082950929510295112951229513295142951529516295172951829519295202952129522295232952429525295262952729528295292953029531295322953329534295352953629537295382953929540295412954229543295442954529546295472954829549295502955129552295532955429555295562955729558295592956029561295622956329564295652956629567295682956929570295712957229573295742957529576295772957829579295802958129582295832958429585295862958729588295892959029591295922959329594295952959629597295982959929600296012960229603296042960529606296072960829609296102961129612296132961429615296162961729618296192962029621296222962329624296252962629627296282962929630296312963229633296342963529636296372963829639296402964129642296432964429645296462964729648296492965029651296522965329654296552965629657296582965929660296612966229663296642966529666296672966829669296702967129672296732967429675296762967729678296792968029681296822968329684296852968629687296882968929690296912969229693296942969529696296972969829699297002970129702297032970429705297062970729708297092971029711297122971329714297152971629717297182971929720297212972229723297242972529726297272972829729297302973129732297332973429735297362973729738297392974029741297422974329744297452974629747297482974929750297512975229753297542975529756297572975829759297602976129762297632976429765297662976729768297692977029771297722977329774297752977629777297782977929780297812978229783297842978529786297872978829789297902979129792297932979429795297962979729798297992980029801298022980329804298052980629807298082980929810298112981229813298142981529816298172981829819298202982129822298232982429825298262982729828298292983029831298322983329834298352983629837298382983929840298412984229843298442984529846298472984829849298502985129852298532985429855298562985729858298592986029861298622986329864298652986629867298682986929870298712987229873298742987529876298772987829879298802988129882298832988429885298862988729888298892989029891298922989329894298952989629897298982989929900299012990229903299042990529906299072990829909299102991129912299132991429915299162991729918299192992029921299222992329924299252992629927299282992929930299312993229933299342993529936299372993829939299402994129942299432994429945299462994729948299492995029951299522995329954299552995629957299582995929960299612996229963299642996529966299672996829969299702997129972299732997429975299762997729978299792998029981299822998329984299852998629987299882998929990299912999229993299942999529996299972999829999300003000130002300033000430005300063000730008300093001030011300123001330014300153001630017300183001930020300213002230023300243002530026300273002830029300303003130032300333003430035300363003730038300393004030041300423004330044300453004630047300483004930050300513005230053300543005530056300573005830059300603006130062300633006430065300663006730068300693007030071300723007330074300753007630077300783007930080300813008230083300843008530086300873008830089300903009130092300933009430095300963009730098300993010030101301023010330104301053010630107301083010930110301113011230113301143011530116301173011830119301203012130122301233012430125301263012730128301293013030131301323013330134301353013630137301383013930140301413014230143301443014530146301473014830149301503015130152301533015430155301563015730158301593016030161301623016330164301653016630167301683016930170301713017230173301743017530176301773017830179301803018130182301833018430185301863018730188301893019030191301923019330194301953019630197301983019930200302013020230203302043020530206302073020830209302103021130212302133021430215302163021730218302193022030221302223022330224302253022630227302283022930230302313023230233302343023530236302373023830239302403024130242302433024430245302463024730248302493025030251302523025330254302553025630257302583025930260302613026230263302643026530266302673026830269302703027130272302733027430275302763027730278302793028030281302823028330284302853028630287302883028930290302913029230293302943029530296302973029830299303003030130302303033030430305303063030730308303093031030311303123031330314303153031630317303183031930320303213032230323303243032530326303273032830329303303033130332303333033430335303363033730338303393034030341303423034330344303453034630347303483034930350303513035230353303543035530356303573035830359303603036130362303633036430365303663036730368303693037030371303723037330374303753037630377303783037930380303813038230383303843038530386303873038830389303903039130392303933039430395303963039730398303993040030401304023040330404304053040630407304083040930410304113041230413304143041530416304173041830419304203042130422304233042430425304263042730428304293043030431304323043330434304353043630437304383043930440304413044230443304443044530446304473044830449304503045130452304533045430455304563045730458304593046030461304623046330464304653046630467304683046930470304713047230473304743047530476304773047830479304803048130482304833048430485304863048730488304893049030491304923049330494304953049630497304983049930500305013050230503305043050530506305073050830509305103051130512305133051430515305163051730518305193052030521305223052330524305253052630527305283052930530305313053230533305343053530536305373053830539305403054130542305433054430545305463054730548305493055030551305523055330554305553055630557305583055930560305613056230563305643056530566305673056830569305703057130572305733057430575305763057730578305793058030581305823058330584305853058630587305883058930590305913059230593305943059530596305973059830599306003060130602306033060430605306063060730608306093061030611306123061330614306153061630617306183061930620306213062230623306243062530626306273062830629306303063130632306333063430635306363063730638306393064030641306423064330644306453064630647306483064930650306513065230653306543065530656306573065830659306603066130662306633066430665306663066730668306693067030671306723067330674306753067630677306783067930680306813068230683306843068530686306873068830689306903069130692306933069430695306963069730698306993070030701307023070330704307053070630707307083070930710307113071230713307143071530716307173071830719307203072130722307233072430725307263072730728307293073030731307323073330734307353073630737307383073930740307413074230743307443074530746307473074830749307503075130752307533075430755307563075730758307593076030761307623076330764307653076630767307683076930770307713077230773307743077530776307773077830779307803078130782307833078430785307863078730788307893079030791307923079330794307953079630797307983079930800308013080230803308043080530806308073080830809308103081130812308133081430815308163081730818308193082030821308223082330824308253082630827308283082930830308313083230833308343083530836308373083830839308403084130842308433084430845308463084730848308493085030851308523085330854308553085630857308583085930860308613086230863308643086530866308673086830869308703087130872308733087430875308763087730878308793088030881308823088330884308853088630887308883088930890308913089230893308943089530896308973089830899309003090130902309033090430905309063090730908309093091030911309123091330914309153091630917309183091930920309213092230923309243092530926309273092830929309303093130932309333093430935309363093730938309393094030941309423094330944309453094630947309483094930950309513095230953309543095530956309573095830959309603096130962309633096430965309663096730968309693097030971309723097330974309753097630977309783097930980309813098230983309843098530986309873098830989309903099130992309933099430995309963099730998309993100031001310023100331004310053100631007310083100931010310113101231013310143101531016310173101831019310203102131022310233102431025310263102731028310293103031031310323103331034310353103631037310383103931040310413104231043310443104531046310473104831049310503105131052310533105431055310563105731058310593106031061310623106331064310653106631067310683106931070310713107231073310743107531076310773107831079310803108131082310833108431085310863108731088310893109031091310923109331094310953109631097310983109931100311013110231103311043110531106311073110831109311103111131112311133111431115311163111731118311193112031121311223112331124311253112631127311283112931130311313113231133311343113531136311373113831139311403114131142311433114431145311463114731148311493115031151311523115331154311553115631157311583115931160311613116231163311643116531166311673116831169311703117131172311733117431175311763117731178311793118031181311823118331184311853118631187311883118931190311913119231193311943119531196311973119831199312003120131202312033120431205312063120731208312093121031211312123121331214312153121631217312183121931220312213122231223312243122531226312273122831229312303123131232312333123431235312363123731238312393124031241312423124331244312453124631247312483124931250312513125231253312543125531256312573125831259312603126131262312633126431265312663126731268312693127031271312723127331274312753127631277312783127931280312813128231283312843128531286312873128831289312903129131292312933129431295312963129731298312993130031301313023130331304313053130631307313083130931310313113131231313313143131531316313173131831319313203132131322313233132431325313263132731328313293133031331313323133331334313353133631337313383133931340313413134231343313443134531346313473134831349313503135131352313533135431355313563135731358313593136031361313623136331364313653136631367313683136931370313713137231373313743137531376313773137831379313803138131382313833138431385313863138731388313893139031391313923139331394313953139631397313983139931400314013140231403314043140531406314073140831409314103141131412314133141431415314163141731418314193142031421314223142331424314253142631427314283142931430314313143231433314343143531436314373143831439314403144131442314433144431445314463144731448314493145031451314523145331454314553145631457314583145931460314613146231463314643146531466314673146831469314703147131472314733147431475314763147731478314793148031481314823148331484314853148631487314883148931490314913149231493314943149531496314973149831499315003150131502315033150431505315063150731508315093151031511315123151331514315153151631517315183151931520315213152231523315243152531526315273152831529315303153131532315333153431535315363153731538315393154031541315423154331544315453154631547315483154931550315513155231553315543155531556315573155831559315603156131562315633156431565315663156731568315693157031571315723157331574315753157631577315783157931580315813158231583315843158531586315873158831589315903159131592315933159431595315963159731598315993160031601316023160331604316053160631607316083160931610316113161231613316143161531616316173161831619316203162131622316233162431625316263162731628316293163031631316323163331634316353163631637316383163931640316413164231643316443164531646316473164831649316503165131652316533165431655316563165731658316593166031661316623166331664316653166631667316683166931670316713167231673316743167531676316773167831679316803168131682316833168431685316863168731688316893169031691316923169331694316953169631697316983169931700317013170231703317043170531706317073170831709317103171131712317133171431715317163171731718317193172031721317223172331724317253172631727317283172931730317313173231733317343173531736317373173831739317403174131742317433174431745317463174731748317493175031751317523175331754317553175631757317583175931760317613176231763317643176531766317673176831769317703177131772317733177431775317763177731778317793178031781317823178331784317853178631787317883178931790317913179231793317943179531796317973179831799318003180131802318033180431805318063180731808318093181031811318123181331814318153181631817318183181931820318213182231823318243182531826318273182831829318303183131832318333183431835318363183731838318393184031841318423184331844318453184631847318483184931850318513185231853318543185531856318573185831859318603186131862318633186431865318663186731868318693187031871318723187331874318753187631877318783187931880318813188231883318843188531886318873188831889318903189131892318933189431895318963189731898318993190031901319023190331904319053190631907319083190931910319113191231913319143191531916319173191831919319203192131922319233192431925319263192731928319293193031931319323193331934319353193631937319383193931940319413194231943319443194531946319473194831949319503195131952319533195431955319563195731958319593196031961319623196331964319653196631967319683196931970319713197231973319743197531976319773197831979319803198131982319833198431985319863198731988319893199031991319923199331994319953199631997319983199932000320013200232003320043200532006320073200832009320103201132012320133201432015320163201732018320193202032021320223202332024320253202632027320283202932030320313203232033320343203532036320373203832039320403204132042320433204432045320463204732048320493205032051320523205332054320553205632057320583205932060320613206232063320643206532066320673206832069320703207132072320733207432075320763207732078320793208032081320823208332084320853208632087320883208932090320913209232093320943209532096320973209832099321003210132102321033210432105321063210732108321093211032111321123211332114321153211632117321183211932120321213212232123321243212532126321273212832129321303213132132321333213432135321363213732138321393214032141321423214332144321453214632147321483214932150321513215232153321543215532156321573215832159321603216132162321633216432165321663216732168321693217032171321723217332174321753217632177321783217932180321813218232183321843218532186321873218832189321903219132192321933219432195321963219732198321993220032201322023220332204322053220632207322083220932210322113221232213322143221532216322173221832219322203222132222322233222432225322263222732228322293223032231322323223332234322353223632237322383223932240322413224232243322443224532246322473224832249322503225132252322533225432255322563225732258322593226032261322623226332264322653226632267322683226932270322713227232273322743227532276322773227832279322803228132282322833228432285322863228732288322893229032291322923229332294322953229632297322983229932300323013230232303323043230532306323073230832309323103231132312323133231432315323163231732318323193232032321323223232332324323253232632327323283232932330323313233232333323343233532336323373233832339323403234132342323433234432345323463234732348323493235032351323523235332354323553235632357323583235932360323613236232363323643236532366323673236832369323703237132372323733237432375323763237732378323793238032381323823238332384323853238632387323883238932390323913239232393323943239532396323973239832399324003240132402324033240432405324063240732408324093241032411324123241332414324153241632417324183241932420324213242232423324243242532426324273242832429324303243132432324333243432435324363243732438324393244032441324423244332444324453244632447324483244932450324513245232453324543245532456324573245832459324603246132462324633246432465324663246732468324693247032471324723247332474324753247632477324783247932480324813248232483324843248532486324873248832489324903249132492324933249432495324963249732498324993250032501325023250332504325053250632507325083250932510325113251232513325143251532516325173251832519325203252132522325233252432525325263252732528325293253032531325323253332534325353253632537325383253932540325413254232543325443254532546325473254832549325503255132552325533255432555325563255732558325593256032561325623256332564325653256632567325683256932570325713257232573325743257532576325773257832579325803258132582325833258432585325863258732588325893259032591325923259332594325953259632597325983259932600326013260232603326043260532606326073260832609326103261132612326133261432615326163261732618326193262032621326223262332624326253262632627326283262932630326313263232633326343263532636326373263832639326403264132642326433264432645326463264732648326493265032651326523265332654326553265632657326583265932660326613266232663326643266532666326673266832669326703267132672326733267432675326763267732678326793268032681326823268332684326853268632687326883268932690326913269232693326943269532696326973269832699327003270132702327033270432705327063270732708327093271032711327123271332714327153271632717327183271932720327213272232723327243272532726327273272832729327303273132732327333273432735327363273732738327393274032741327423274332744327453274632747327483274932750327513275232753327543275532756327573275832759327603276132762327633276432765327663276732768327693277032771327723277332774327753277632777327783277932780327813278232783327843278532786327873278832789327903279132792327933279432795327963279732798327993280032801328023280332804328053280632807328083280932810328113281232813328143281532816328173281832819328203282132822328233282432825328263282732828328293283032831328323283332834328353283632837328383283932840328413284232843328443284532846328473284832849328503285132852328533285432855328563285732858328593286032861328623286332864328653286632867328683286932870328713287232873328743287532876328773287832879328803288132882328833288432885328863288732888328893289032891328923289332894328953289632897328983289932900329013290232903329043290532906329073290832909329103291132912329133291432915329163291732918329193292032921329223292332924329253292632927329283292932930329313293232933329343293532936329373293832939329403294132942329433294432945329463294732948329493295032951329523295332954329553295632957329583295932960329613296232963329643296532966329673296832969329703297132972329733297432975329763297732978329793298032981329823298332984329853298632987329883298932990329913299232993329943299532996329973299832999330003300133002330033300433005330063300733008330093301033011330123301333014330153301633017330183301933020330213302233023330243302533026330273302833029330303303133032330333303433035330363303733038330393304033041330423304333044330453304633047330483304933050330513305233053330543305533056330573305833059330603306133062330633306433065330663306733068330693307033071330723307333074330753307633077330783307933080330813308233083330843308533086330873308833089330903309133092330933309433095330963309733098330993310033101331023310333104331053310633107331083310933110331113311233113331143311533116331173311833119331203312133122331233312433125331263312733128331293313033131331323313333134331353313633137331383313933140331413314233143331443314533146331473314833149331503315133152331533315433155331563315733158331593316033161331623316333164331653316633167331683316933170331713317233173331743317533176331773317833179331803318133182331833318433185331863318733188331893319033191331923319333194331953319633197331983319933200332013320233203332043320533206332073320833209332103321133212332133321433215332163321733218332193322033221332223322333224332253322633227332283322933230332313323233233332343323533236332373323833239332403324133242332433324433245332463324733248332493325033251332523325333254332553325633257332583325933260332613326233263332643326533266332673326833269332703327133272332733327433275332763327733278332793328033281332823328333284332853328633287332883328933290332913329233293332943329533296332973329833299333003330133302333033330433305333063330733308333093331033311333123331333314333153331633317333183331933320333213332233323333243332533326333273332833329333303333133332333333333433335333363333733338333393334033341333423334333344333453334633347333483334933350333513335233353333543335533356333573335833359333603336133362333633336433365333663336733368333693337033371333723337333374333753337633377333783337933380333813338233383333843338533386333873338833389333903339133392333933339433395333963339733398333993340033401334023340333404334053340633407334083340933410334113341233413334143341533416334173341833419334203342133422334233342433425334263342733428334293343033431334323343333434334353343633437334383343933440334413344233443334443344533446334473344833449334503345133452334533345433455334563345733458334593346033461334623346333464334653346633467334683346933470334713347233473334743347533476334773347833479334803348133482334833348433485334863348733488334893349033491334923349333494334953349633497334983349933500335013350233503335043350533506335073350833509335103351133512335133351433515335163351733518335193352033521335223352333524335253352633527335283352933530335313353233533335343353533536335373353833539335403354133542335433354433545335463354733548335493355033551335523355333554335553355633557335583355933560335613356233563335643356533566335673356833569335703357133572335733357433575335763357733578335793358033581335823358333584335853358633587335883358933590335913359233593335943359533596335973359833599336003360133602336033360433605336063360733608336093361033611336123361333614336153361633617336183361933620336213362233623336243362533626336273362833629336303363133632336333363433635336363363733638336393364033641336423364333644336453364633647336483364933650336513365233653336543365533656336573365833659336603366133662336633366433665336663366733668336693367033671336723367333674336753367633677336783367933680336813368233683336843368533686336873368833689336903369133692336933369433695336963369733698336993370033701337023370333704337053370633707337083370933710337113371233713337143371533716337173371833719337203372133722337233372433725337263372733728337293373033731337323373333734337353373633737337383373933740337413374233743337443374533746337473374833749337503375133752337533375433755337563375733758337593376033761337623376333764337653376633767337683376933770337713377233773337743377533776337773377833779337803378133782337833378433785337863378733788337893379033791337923379333794337953379633797337983379933800338013380233803338043380533806338073380833809338103381133812338133381433815338163381733818338193382033821338223382333824338253382633827338283382933830338313383233833338343383533836338373383833839338403384133842338433384433845338463384733848338493385033851338523385333854338553385633857338583385933860338613386233863338643386533866338673386833869338703387133872338733387433875338763387733878338793388033881338823388333884338853388633887338883388933890338913389233893338943389533896338973389833899339003390133902339033390433905339063390733908339093391033911339123391333914339153391633917339183391933920339213392233923339243392533926339273392833929339303393133932339333393433935339363393733938339393394033941339423394333944339453394633947339483394933950339513395233953339543395533956339573395833959339603396133962339633396433965339663396733968339693397033971339723397333974339753397633977339783397933980339813398233983339843398533986339873398833989339903399133992339933399433995339963399733998339993400034001340023400334004340053400634007340083400934010340113401234013340143401534016340173401834019340203402134022340233402434025340263402734028340293403034031340323403334034340353403634037340383403934040340413404234043340443404534046340473404834049340503405134052340533405434055340563405734058340593406034061340623406334064340653406634067340683406934070340713407234073340743407534076340773407834079340803408134082340833408434085340863408734088340893409034091340923409334094340953409634097340983409934100341013410234103341043410534106341073410834109341103411134112341133411434115341163411734118341193412034121341223412334124341253412634127341283412934130341313413234133341343413534136341373413834139341403414134142341433414434145341463414734148341493415034151341523415334154341553415634157341583415934160341613416234163341643416534166341673416834169341703417134172341733417434175341763417734178341793418034181341823418334184341853418634187341883418934190341913419234193341943419534196341973419834199342003420134202342033420434205342063420734208342093421034211342123421334214342153421634217342183421934220342213422234223342243422534226342273422834229342303423134232342333423434235342363423734238342393424034241342423424334244342453424634247342483424934250342513425234253342543425534256342573425834259342603426134262342633426434265342663426734268342693427034271342723427334274342753427634277342783427934280342813428234283342843428534286342873428834289342903429134292342933429434295342963429734298342993430034301343023430334304343053430634307343083430934310343113431234313343143431534316343173431834319343203432134322343233432434325343263432734328343293433034331343323433334334343353433634337343383433934340343413434234343343443434534346343473434834349343503435134352343533435434355343563435734358343593436034361343623436334364343653436634367343683436934370343713437234373343743437534376343773437834379343803438134382343833438434385343863438734388343893439034391343923439334394343953439634397343983439934400344013440234403344043440534406344073440834409344103441134412344133441434415344163441734418344193442034421344223442334424344253442634427344283442934430344313443234433344343443534436344373443834439344403444134442344433444434445344463444734448344493445034451344523445334454344553445634457344583445934460344613446234463344643446534466344673446834469344703447134472344733447434475344763447734478344793448034481344823448334484344853448634487344883448934490344913449234493344943449534496344973449834499345003450134502345033450434505345063450734508345093451034511345123451334514345153451634517345183451934520345213452234523345243452534526345273452834529345303453134532345333453434535345363453734538345393454034541345423454334544345453454634547345483454934550345513455234553345543455534556345573455834559345603456134562345633456434565345663456734568345693457034571345723457334574345753457634577345783457934580345813458234583345843458534586345873458834589345903459134592345933459434595345963459734598345993460034601346023460334604346053460634607346083460934610346113461234613
  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. "io"
  23. "io/ioutil"
  24. //"math"
  25. "math/rand"
  26. "net/http"
  27. "net/url"
  28. "os"
  29. "path/filepath"
  30. "regexp"
  31. "strconv"
  32. "strings"
  33. "syscall"
  34. "time"
  35. "unsafe"
  36. "github.com/go-ole/go-ole/oleutil"
  37. )
  38. type HisApiController struct {
  39. controllers.BaseAuthAPIController
  40. }
  41. func HisManagerApiRegistRouters() {
  42. //挂号
  43. beego.Router("/api/register/get", &HisApiController{}, "get:GetRegisterInfo")
  44. //上传就诊信息-上传明细-结算
  45. beego.Router("/api/upload/get", &HisApiController{}, "get:GetUploadInfo")
  46. //查询
  47. beego.Router("/api/settle/query", &HisApiController{}, "get:GetSettleAccounts")
  48. //对总账
  49. beego.Router("/api/checkaccount/get", &HisApiController{}, "get:GetCheckAccount")
  50. //对明细
  51. beego.Router("/api/checkdetailaccount/get", &HisApiController{}, "get:GetCheckDetailAccount")
  52. //退费,退明细
  53. beego.Router("/api/refund/post", &HisApiController{}, "get:Refund")
  54. //退号
  55. beego.Router("/api/refundnumber/post", &HisApiController{}, "get:RefundNumber")
  56. //退明细
  57. beego.Router("/api/refunddetail/post", &HisApiController{}, "get:RefundDetail")
  58. //上传就诊信息-上传明细-预结算
  59. beego.Router("/api/presettle/get", &HisApiController{}, "get:GetPreUploadInfo")
  60. //beego.Router("/api/treatment/check", &HisApiController{}, "get:CheckTreatment")
  61. beego.Router("/api/org/info", &HisApiController{}, "get:GetOrgInfo")
  62. beego.Router("/api/readcard", &HisApiController{}, "get:ReadCard")
  63. beego.Router("/api/310", &HisApiController{}, "get:Check310")
  64. beego.Router("/api/390", &HisApiController{}, "get:Check390")
  65. beego.Router("/api/patient/info", &HisApiController{}, "get:GetPatientInfo")
  66. beego.Router("/api/checkcode/get", &HisApiController{}, "get:GetCheckCode")
  67. beego.Router("/api/uncheckcode/get", &HisApiController{}, "get:UnCheckCode")
  68. beego.Router("/api/psn/putonrecord", &HisApiController{}, "get:PsnPutOnRecord")
  69. beego.Router("/api/psn/unputonrecord", &HisApiController{}, "get:PsnUnPutOnRecord")
  70. beego.Router("/api/psn/ncds/putonrecord", &HisApiController{}, "get:PsnPutNCDSOnRecord")
  71. beego.Router("/api/psn/ncds/unputonrecord", &HisApiController{}, "get:PsnPutUnNCDSOnRecord")
  72. beego.Router("/api/reversal", &HisApiController{}, "get:ReversalData")
  73. beego.Router("/api/reversal/other", &HisApiController{}, "get:ReversalOtherData")
  74. beego.Router("/api/settlelist/get", &HisApiController{}, "get:GetSettleList")
  75. beego.Router("/api/settlelisthosptial/get", &HisApiController{}, "get:GetSettleListHospital")
  76. beego.Router("/api/pwd/check", &HisApiController{}, "get:CheckCardPWD")
  77. beego.Router("/api/insutype/check", &HisApiController{}, "get:CheckInsutype")
  78. //beego.Router("/api/batchsettlelist/get", &HisApiController{}, "get:GetBatchSettleList")
  79. beego.Router("/api/psn/info", &HisApiController{}, "get:GetPsnNcdsInfo")
  80. beego.Router("/api/allopatry/refund", &HisApiController{}, "post:RefundAllopatry")
  81. beego.Router("/api/check", &HisApiController{}, "get:Check")
  82. //beego.Router("/api/check3101", &HisApiController{}, "get:Check3101")
  83. //beego.Router("/api/check3102", &HisApiController{}, "get:Check3102")
  84. beego.Router("/90990", &HisApiController{}, "get:CheckCardPWDTwo")
  85. beego.Router("/9001", &HisApiController{}, "get:Get9001")
  86. //beego.Router("/api/readelecard", &HisApiController{}, "get:ReadEleCard")
  87. beego.Router("/api/3202", &HisApiController{}, "get:Post3202")
  88. beego.Router("/api/3202b", &HisApiController{}, "get:Post3202b")
  89. beego.Router("/api/1608", &HisApiController{}, "get:Post1608")
  90. beego.Router("/api/5302", &HisApiController{}, "get:Post5302")
  91. beego.Router("/api/3501", &HisApiController{}, "post:Post3501")
  92. beego.Router("/api/readele", &HisApiController{}, "get:ReadEleToken")
  93. beego.Router("/api/2505", &HisApiController{}, "get:Get2505")
  94. beego.Router("/api/4201A", &HisApiController{}, "get:Get4201A")
  95. beego.Router("/api/4202", &HisApiController{}, "get:Get4202")
  96. beego.Router("/api/4203", &HisApiController{}, "get:Get4203")
  97. beego.Router("/api/4205", &HisApiController{}, "get:Get4205")
  98. beego.Router("/api/4207", &HisApiController{}, "get:Get4207")
  99. beego.Router("/api/4208", &HisApiController{}, "get:Get4208")
  100. beego.Router("/api/4209", &HisApiController{}, "get:Get4209")
  101. beego.Router("/api/allopatry/get", &HisApiController{}, "get:GetAllopatry")
  102. //beego.Router("/api/comfirmallopatry/post", &HisApiController{}, "post:ComfirmAllopatry")
  103. beego.Router("/api/allopatry/refund", &HisApiController{}, "get:RefundAllopatry")
  104. beego.Router("/api/settle/query/batch", &HisApiController{}, "get:GetBatchSettleAccounts")
  105. beego.Router("/api/bl4201A", &HisApiController{}, "get:GetBL4201A")
  106. beego.Router("/api/bl4201A", &HisApiController{}, "get:GetBL4201A")
  107. beego.Router("/api/CFYLJG001", &HisApiController{}, "get:GetCFYLJG001")
  108. beego.Router("/api/CFYLJG002", &HisApiController{}, "get:GetCFYLJG002")
  109. beego.Router("/api/CFYLJG003", &HisApiController{}, "get:GetCFYLJG003")
  110. beego.Router("/api/CFYLJG004", &HisApiController{}, "get:GetCFYLJG004")
  111. beego.Router("/api/CFYLJG005", &HisApiController{}, "get:GetCFYLJG005")
  112. beego.Router("/api/CFYLJG006", &HisApiController{}, "get:GetCFYLJG006")
  113. beego.Router("/api/CFYLJG007", &HisApiController{}, "get:GetCFYLJG007")
  114. beego.Router("/api/CFYLJG008", &HisApiController{}, "get:GetCFYLJG008")
  115. //beego.Router("/api/CFYLJG009", &HisApiController{}, "get:GetCFYLJG009")
  116. //beego.Router("/api/2205", &HisApiController{}, "get:Get2205")
  117. beego.Router("/api/3260", &HisApiController{}, "get:Get3260")
  118. beego.Router("/api/3261", &HisApiController{}, "get:Get3261")
  119. beego.Router("/api/3262", &HisApiController{}, "get:Get3262")
  120. beego.Router("/api/3263", &HisApiController{}, "get:Get3263")
  121. beego.Router("/api/3264", &HisApiController{}, "get:Get3264")
  122. beego.Router("/api/3265", &HisApiController{}, "get:Get3265")
  123. beego.Router("/api/3266", &HisApiController{}, "get:Get3266")
  124. beego.Router("/api/3267", &HisApiController{}, "get:Get3267")
  125. beego.Router("/api/3268", &HisApiController{}, "get:Get3268")
  126. beego.Router("/api/3269", &HisApiController{}, "get:Get3269")
  127. beego.Router("/api/3270", &HisApiController{}, "get:Get3270")
  128. beego.Router("/api/3271", &HisApiController{}, "get:Get3271")
  129. beego.Router("/api/3272", &HisApiController{}, "get:Get3272")
  130. beego.Router("/api/3273", &HisApiController{}, "get:Get3273")
  131. beego.Router("/api/3274", &HisApiController{}, "get:Get3274")
  132. beego.Router("/api/3275", &HisApiController{}, "get:Get3275")
  133. beego.Router("/api/3276", &HisApiController{}, "get:Get3276")
  134. beego.Router("/api/3277", &HisApiController{}, "get:Get3277")
  135. beego.Router("/api/comfirm/upload", &HisApiController{}, "get:Get4102")
  136. beego.Router("/api/batch/check_drug", &HisApiController{}, "get:Drugscheck")
  137. beego.Router("/api/batch/check_good", &HisApiController{}, "get:Goodcheck")
  138. beego.Router("/api/batch/check_project", &HisApiController{}, "get:Projectcheck")
  139. beego.Router("/api/querydata", &HisApiController{}, "get:Getquerydata")
  140. //beego.Router("/api/5267", &HisApiController{}, "get:Get5267")
  141. //beego.Router("/api/1312a", &HisApiController{}, "get:Get1312a")
  142. //beego.Router("/api/cancledia/get", &HisApiController{}, "get:CancleDia")
  143. beego.Router("/api/4105", &HisApiController{}, "get:Get4105")
  144. beego.Router("/api/4104", &HisApiController{}, "get:Get4104")
  145. beego.Router("/api/2406", &HisApiController{}, "get:Get2406")
  146. beego.Router("/api/2503", &HisApiController{}, "get:Get2503")
  147. beego.Router("/api/1318", &HisApiController{}, "get:Get1318")
  148. beego.Router("/api/readelebyface", &HisApiController{}, "get:ReadEleFace")
  149. beego.Router("/api/settlelist/get/batch", &HisApiController{}, "get:GetbatchSettleList")
  150. //库盘和变更
  151. beego.Router("/api/pc_bg", &HisApiController{}, "get:FJ3501AND3502")
  152. //删除库盘和变更
  153. beego.Router("/api/delete_pc_bg", &HisApiController{}, "get:DeletePCandBG")
  154. beego.Router("/api/delete_xs_bg", &HisApiController{}, "get:DeleteXSandBG")
  155. //药品变更
  156. beego.Router("/api/changedrug", &HisApiController{}, "get:ChangeDrug")
  157. }
  158. func (c *HisApiController) FJ3501AND3502() {
  159. ids := c.getString("ids")
  160. admin_user_id, _ := c.GetInt64("admin_user_id")
  161. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  162. id_arr := strings.Split(ids, ",")
  163. drugs, _ := service.GetNewDrugWarehouseInfo(id_arr)
  164. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  165. //库盘
  166. for _, drug := range drugs {
  167. if drug.IsPc == 0 && drug.IsBg == 0 {
  168. var struct3501 models.Struct3501
  169. struct3501.OrgName = miConfig.OrgName
  170. struct3501.AccessKey = miConfig.AccessKey
  171. struct3501.Opter = roles.UserName
  172. struct3501.RequestUrl = miConfig.Url
  173. struct3501.Url = miConfig.Url
  174. struct3501.AppId = miConfig.Cainfo
  175. struct3501.AppSecret = miConfig.AppSecret
  176. struct3501.Enckey = miConfig.EncKey
  177. struct3501.SignKey = miConfig.SignKey
  178. struct3501.SecretKey = miConfig.SecretKey
  179. struct3501.MedListCodg = drug.BaseDrugLib.MedicalInsuranceNumber
  180. struct3501.FixmedinsHilistId = miConfig.Code
  181. struct3501.FixmedinsHilistName = miConfig.OrgName
  182. struct3501.RxFlag = "0"
  183. struct3501.Invdate = time.Unix(drug.Ctime, 0).Format("2006-01-02 15:04:05")
  184. struct3501.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  185. struct3501.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  186. struct3501.InvCnt = strconv.FormatInt(drug.StockMaxNumber, 10)
  187. struct3501.ExpyEnd = time.Unix(drug.ExpiryDate, 0).Format("2006-01-02 15:04:05")
  188. struct3501.FixmedinsBchno = strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(drug.ID, 10) + "-" + "3501"
  189. memo := make(map[string]interface{})
  190. memo["pric"] = drug.Price
  191. bytesData, _ := json.Marshal(memo)
  192. struct3501.Memo = string(bytesData)
  193. result1, result2, result3 := service.FJyb3501(struct3501)
  194. fmt.Println(result1)
  195. fmt.Println(result2)
  196. fmt.Println(result3)
  197. var struct3502 models.Struct3502
  198. struct3502.MedListCodg = drug.BaseDrugLib.MedicalInsuranceNumber
  199. struct3502.FixmedinsHilistId = miConfig.Code
  200. struct3502.FixmedinsHilistName = miConfig.OrgName
  201. struct3502.FixmedinsCode = miConfig.Code
  202. struct3502.RxFlag = "0"
  203. struct3502.InvChgTime = time.Now().Format("2006-01-02")
  204. struct3502.OrgName = miConfig.OrgName
  205. struct3502.AccessKey = miConfig.AccessKey
  206. struct3502.RequestUrl = miConfig.Url
  207. struct3502.SecretKey = miConfig.SecretKey
  208. struct3502.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  209. struct3502.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  210. struct3502.Url = miConfig.Url
  211. struct3502.AppId = miConfig.Cainfo
  212. struct3502.AppSecret = miConfig.AppSecret
  213. struct3502.Enckey = miConfig.EncKey
  214. struct3502.SignKey = miConfig.SignKey
  215. struct3502.SecretKey = miConfig.SecretKey
  216. struct3502.Memo = ""
  217. struct3502.InvChgType = "108"
  218. struct3501.FixmedinsBchno = strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(drug.ID, 10) + "-" + "3502"
  219. struct3502.Cnt = strconv.FormatInt(drug.WarehousingCount, 10)
  220. struct3502.Pric = fmt.Sprintf("%.2f", drug.BaseDrugLib.RetailPrice)
  221. result11, result22, result33 := service.FJyb3502(struct3502)
  222. fmt.Println(result11)
  223. fmt.Println(result22)
  224. fmt.Println(result33)
  225. }
  226. //变更
  227. if drug.IsPc == 1 && drug.IsBg == 0 {
  228. var struct3502 models.Struct3502
  229. struct3502.MedListCodg = drug.BaseDrugLib.MedicalInsuranceNumber
  230. struct3502.FixmedinsHilistId = miConfig.Code
  231. struct3502.FixmedinsHilistName = miConfig.OrgName
  232. struct3502.FixmedinsCode = miConfig.Code
  233. struct3502.RxFlag = "0"
  234. struct3502.InvChgTime = time.Unix(drug.Ctime, 0).Format("2006-01-02 15:04:05")
  235. struct3502.OrgName = miConfig.OrgName
  236. struct3502.AccessKey = miConfig.AccessKey
  237. struct3502.RequestUrl = miConfig.Url
  238. struct3502.SecretKey = miConfig.SecretKey
  239. struct3502.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  240. struct3502.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  241. struct3502.InvChgType = "108"
  242. struct3502.Url = miConfig.Url
  243. struct3502.AppId = miConfig.Cainfo
  244. struct3502.AppSecret = miConfig.AppSecret
  245. struct3502.Enckey = miConfig.EncKey
  246. struct3502.SignKey = miConfig.SignKey
  247. struct3502.SecretKey = miConfig.SecretKey
  248. struct3502.FixmedinsBchno = ""
  249. struct3502.Cnt = strconv.FormatInt(drug.WarehousingCount, 10)
  250. struct3502.Pric = fmt.Sprintf("%.2f", drug.BaseDrugLib.RetailPrice)
  251. result1, result2, result3 := service.FJyb3502(struct3502)
  252. fmt.Println(result1)
  253. fmt.Println(result2)
  254. fmt.Println(result3)
  255. }
  256. }
  257. }
  258. func (c *HisApiController) DeletePCandBG() {
  259. ids := c.getString("ids")
  260. id_arr := strings.Split(ids, ",")
  261. admin_user_id, _ := c.GetInt64("admin_user_id")
  262. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  263. drugs, _ := service.GetNewDrugWarehouseInfo(id_arr)
  264. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  265. for _, item := range drugs {
  266. if item.IsPc == 1 && item.IsBg == 1 {
  267. var struct3507 models.Struct3507
  268. struct3507.FixmedinsBchno = ""
  269. struct3507.InvDataType = "1"
  270. struct3507.Opter = roles.UserName
  271. struct3507.OrgName = miConfig.OrgName
  272. struct3507.AccessKey = miConfig.AccessKey
  273. struct3507.RequestUrl = miConfig.Url
  274. struct3507.SecretKey = miConfig.SecretKey
  275. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  276. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  277. struct3507.Url = miConfig.Url
  278. struct3507.AppId = miConfig.Cainfo
  279. struct3507.AppSecret = miConfig.AppSecret
  280. struct3507.Enckey = miConfig.EncKey
  281. struct3507.SignKey = miConfig.SignKey
  282. struct3507.SecretKey = miConfig.SecretKey
  283. service.FJyb3507(struct3507)
  284. var struct3507_2 models.Struct3507
  285. struct3507_2.OrgName = miConfig.OrgName
  286. struct3507_2.AccessKey = miConfig.AccessKey
  287. struct3507_2.RequestUrl = miConfig.Url
  288. struct3507_2.SecretKey = miConfig.SecretKey
  289. struct3507_2.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  290. struct3507_2.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  291. struct3507_2.Url = miConfig.Url
  292. struct3507_2.AppId = miConfig.Cainfo
  293. struct3507_2.AppSecret = miConfig.AppSecret
  294. struct3507_2.Enckey = miConfig.EncKey
  295. struct3507_2.SignKey = miConfig.SignKey
  296. struct3507_2.SecretKey = miConfig.SecretKey
  297. struct3507_2.FixmedinsBchno = ""
  298. struct3507_2.InvDataType = "2"
  299. service.FJyb3507(struct3507_2)
  300. }
  301. if item.IsPc == 1 && item.IsBg == 0 {
  302. var struct3507 models.Struct3507
  303. struct3507.OrgName = miConfig.OrgName
  304. struct3507.AccessKey = miConfig.AccessKey
  305. struct3507.RequestUrl = miConfig.Url
  306. struct3507.SecretKey = miConfig.SecretKey
  307. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  308. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  309. struct3507.Url = miConfig.Url
  310. struct3507.AppId = miConfig.Cainfo
  311. struct3507.AppSecret = miConfig.AppSecret
  312. struct3507.Enckey = miConfig.EncKey
  313. struct3507.SignKey = miConfig.SignKey
  314. struct3507.SecretKey = miConfig.SecretKey
  315. struct3507.FixmedinsBchno = ""
  316. struct3507.InvDataType = "1"
  317. service.FJyb3507(struct3507)
  318. }
  319. }
  320. }
  321. func (c *HisApiController) DeleteXSandBG() {
  322. ids := c.getString("ids")
  323. id_arr := strings.Split(ids, ",")
  324. admin_user_id, _ := c.GetInt64("admin_user_id")
  325. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  326. drugs, _ := service.GetNewDrugWarehouseInfo(id_arr)
  327. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  328. for _, item := range drugs {
  329. if item.IsPc == 1 && item.IsBg == 1 {
  330. var struct3507 models.Struct3507
  331. struct3507.FixmedinsBchno = ""
  332. struct3507.InvDataType = "1"
  333. struct3507.Opter = roles.UserName
  334. struct3507.OrgName = miConfig.OrgName
  335. struct3507.AccessKey = miConfig.AccessKey
  336. struct3507.RequestUrl = miConfig.Url
  337. struct3507.SecretKey = miConfig.SecretKey
  338. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  339. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  340. struct3507.Url = miConfig.Url
  341. struct3507.AppId = miConfig.Cainfo
  342. struct3507.AppSecret = miConfig.AppSecret
  343. struct3507.Enckey = miConfig.EncKey
  344. struct3507.SignKey = miConfig.SignKey
  345. struct3507.SecretKey = miConfig.SecretKey
  346. struct3507.FixmedinsBchno = ""
  347. struct3507.InvDataType = "1"
  348. service.FJyb3507(struct3507)
  349. var struct3507_2 models.Struct3507
  350. struct3507_2.OrgName = miConfig.OrgName
  351. struct3507_2.AccessKey = miConfig.AccessKey
  352. struct3507_2.RequestUrl = miConfig.Url
  353. struct3507_2.SecretKey = miConfig.SecretKey
  354. struct3507_2.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  355. struct3507_2.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  356. struct3507_2.FixmedinsBchno = ""
  357. struct3507_2.InvDataType = "2"
  358. struct3507_2.Url = miConfig.Url
  359. struct3507_2.AppId = miConfig.Cainfo
  360. struct3507_2.AppSecret = miConfig.AppSecret
  361. struct3507_2.Enckey = miConfig.EncKey
  362. struct3507_2.SignKey = miConfig.SignKey
  363. struct3507_2.SecretKey = miConfig.SecretKey
  364. struct3507_2.FixmedinsBchno = ""
  365. struct3507_2.InvDataType = "1"
  366. service.FJyb3507(struct3507_2)
  367. }
  368. if item.IsPc == 1 && item.IsBg == 0 {
  369. var struct3507 models.Struct3507
  370. struct3507.OrgName = miConfig.OrgName
  371. struct3507.AccessKey = miConfig.AccessKey
  372. struct3507.RequestUrl = miConfig.Url
  373. struct3507.SecretKey = miConfig.SecretKey
  374. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  375. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  376. struct3507.FixmedinsBchno = ""
  377. struct3507.InvDataType = "1"
  378. service.FJyb3507(struct3507)
  379. }
  380. }
  381. }
  382. func (c *HisApiController) ChangeDrug() {
  383. ids := c.getString("ids")
  384. id_arr := strings.Split(ids, ",")
  385. flows, _ := service.GetNewDrugFlowInfo(id_arr)
  386. admin_user_id, _ := c.GetInt64("admin_user_id")
  387. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  388. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  389. for _, item := range flows {
  390. if item.ConsumableType == 3 { //3为自动出库 7为自动退库
  391. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  392. if prescription.OrderStatus == 2 { //已经结算
  393. //判断是否已经销售
  394. if item.IsSale == 1 { //是否已经销售,1是 0否
  395. //是否已经变更 1是 0否
  396. if item.IsChange == 0 { //没变更,进行变更操作
  397. ChangeStock(item.Count, item.HisDoctorAdviceInfo, miConfig, "102", roles)
  398. }
  399. } else { //没销售,
  400. //进行商品销售接口
  401. SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item.HisDoctorAdviceInfo, miConfig, "", roles)
  402. if item.IsChange == 0 { //没变更,进行变更操作
  403. ChangeStock(item.Count, item.HisDoctorAdviceInfo, miConfig, "102", roles)
  404. }
  405. }
  406. } else { //还没结算
  407. if item.IsChange == 0 { //没变更,进行变更操作
  408. ChangeStock(item.Count, item.HisDoctorAdviceInfo, miConfig, "102", roles)
  409. }
  410. }
  411. } else if item.ConsumableType == 7 {
  412. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  413. order := service.GetHisOrderByNumber(prescription.BatchNumber)
  414. if order.OrderStatus == 2 || order.OrderStatus == 1 { //已经结算
  415. //判断是否已经销售
  416. if item.IsSale == 1 { //是否已经销售,1是 0否
  417. //是否已经变更 1是 0否
  418. if item.IsChange == 0 { //没变更,进行变更操作
  419. ChangeStock(item.Count, item.HisDoctorAdviceInfo, miConfig, "102", roles)
  420. }
  421. } else { //没销售,
  422. //进行商品销售退货接口
  423. CancleSaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item.HisDoctorAdviceInfo, miConfig, "")
  424. if item.IsChange == 0 { //没变更,进行变更操作
  425. ChangeStock(item.Count, item.HisDoctorAdviceInfo, miConfig, "102", roles)
  426. }
  427. }
  428. } else { //还没结算
  429. if item.IsChange == 0 { //没变更,进行变更操作
  430. ChangeStock(item.Count, item.HisDoctorAdviceInfo, miConfig, "102", roles)
  431. }
  432. }
  433. } else { //其他方式
  434. if item.IsChange == 0 { //没变更,进行变更操作
  435. ChangeStock(item.Count, item.HisDoctorAdviceInfo, miConfig, "102", roles)
  436. }
  437. }
  438. }
  439. }
  440. func ChangeStock(count int64, drug models.HisDoctorAdviceInfo, miConfig models.MedicalInsuranceOrgConfig, chgType string, role models.UserAdminRole) {
  441. var struct3502 models.Struct3502
  442. struct3502.MedListCodg = drug.BaseDrugLib.MedicalInsuranceNumber
  443. struct3502.FixmedinsHilistId = miConfig.Code
  444. struct3502.FixmedinsHilistName = miConfig.OrgName
  445. struct3502.FixmedinsCode = miConfig.Code
  446. struct3502.Opter = role.UserName
  447. struct3502.RxFlag = "0"
  448. struct3502.InvChgTime = time.Unix(drug.CreatedTime, 0).Format("2006-01-02 15:04:05")
  449. struct3502.OrgName = miConfig.OrgName
  450. struct3502.AccessKey = miConfig.AccessKey
  451. struct3502.RequestUrl = miConfig.Url
  452. struct3502.SecretKey = miConfig.SecretKey
  453. struct3502.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  454. struct3502.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  455. struct3502.Url = miConfig.Url
  456. struct3502.AppId = miConfig.Cainfo
  457. struct3502.AppSecret = miConfig.AppSecret
  458. struct3502.Enckey = miConfig.EncKey
  459. struct3502.SignKey = miConfig.SignKey
  460. struct3502.SecretKey = miConfig.SecretKey
  461. struct3502.InvChgType = chgType
  462. struct3502.FixmedinsBchno = ""
  463. struct3502.Cnt = strconv.FormatInt(count, 10)
  464. struct3502.Pric = fmt.Sprintf("%.2f", drug.Price)
  465. result1, result2, result3 := service.FJyb3502(struct3502)
  466. fmt.Println(result1)
  467. fmt.Println(result2)
  468. fmt.Println(result3)
  469. }
  470. func SaleStock(org_id int64, pre models.HisPrescription, drug models.HisDoctorAdviceInfo, miConfig models.MedicalInsuranceOrgConfig, chgType string, role models.UserAdminRole) {
  471. var struct3505 models.Struct3505
  472. struct3505.MedListCodg = drug.BaseDrugLib.MedicalInsuranceNumber
  473. struct3505.FixmedinsHilistId = miConfig.Code
  474. struct3505.FixmedinsHilistName = miConfig.OrgName
  475. struct3505.FixmedinsCode = miConfig.Code
  476. struct3505.FixmedinsBchno = ""
  477. roles, _ := service.GetAdminUserInfoByID(org_id, pre.Creator)
  478. struct3505.PrscDrName = roles.UserName
  479. struct3505.PharName = ""
  480. struct3505.PharPracCertNo = ""
  481. order := service.GetHisOrderByNumber(pre.BatchNumber)
  482. struct3505.SetlId = order.SetlId
  483. struct3505.MdtrtSn = order.MdtrtId
  484. struct3505.ManuLotnum = ""
  485. struct3505.ManuDate = ""
  486. struct3505.ExpyEnd = ""
  487. struct3505.RxFlag = "0"
  488. struct3505.TrdnFlag = "1"
  489. struct3505.Url = miConfig.Url
  490. struct3505.AppId = miConfig.Cainfo
  491. struct3505.AppSecret = miConfig.AppSecret
  492. struct3505.Enckey = miConfig.EncKey
  493. struct3505.SignKey = miConfig.SignKey
  494. struct3505.SecretKey = miConfig.SecretKey
  495. struct3505.RtalDocno = order.Number
  496. strValue := fmt.Sprintf("%.2f", drug.PrescribingNumber)
  497. struct3505.SelRetnCnt = strValue
  498. struct3505.SelRetnTime = time.Unix(drug.CreatedTime, 0).Format("2006-01-02 15:04:05")
  499. roles_two, _ := service.GetAdminUserInfoByID(org_id, order.Creator)
  500. struct3505.SelRetnOpterName = roles_two.UserName
  501. if order.IsMedicineInsurance == 1 {
  502. struct3505.MdtrtSetlType = "1"
  503. } else {
  504. struct3505.MdtrtSetlType = "2"
  505. }
  506. struct3505.OrgName = miConfig.OrgName
  507. struct3505.AccessKey = miConfig.AccessKey
  508. struct3505.RequestUrl = miConfig.Url
  509. struct3505.SecretKey = miConfig.SecretKey
  510. struct3505.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  511. struct3505.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  512. result1, result2, result3 := service.FJyb3505(struct3505)
  513. fmt.Println(result1)
  514. fmt.Println(result2)
  515. fmt.Println(result3)
  516. }
  517. func CancleSaleStock(org_id int64, pre models.HisPrescription, drug models.HisDoctorAdviceInfo, miConfig models.MedicalInsuranceOrgConfig, chgType string) {
  518. var struct3506 models.Struct3506
  519. struct3506.MedListCodg = drug.BaseDrugLib.MedicalInsuranceNumber
  520. struct3506.FixmedinsHilistId = miConfig.Code
  521. struct3506.FixmedinsHilistName = miConfig.OrgName
  522. struct3506.FixmedinsCode = miConfig.Code
  523. struct3506.FixmedinsBchno = ""
  524. order := service.GetHisOrderByNumber(pre.BatchNumber)
  525. //roles, _ := service.GetAdminUserInfoByID(org_id, pre.Creator)
  526. struct3506.ManuLotnum = ""
  527. struct3506.ManuDate = ""
  528. struct3506.MdtrtSn = order.MdtrtId
  529. struct3506.ExpyEnd = ""
  530. struct3506.RxFlag = "0"
  531. struct3506.TrdnFlag = "1"
  532. strValue := fmt.Sprintf("%.2f", drug.PrescribingNumber)
  533. struct3506.SelRetnCnt = strValue
  534. struct3506.SelRetnTime = time.Unix(drug.CreatedTime, 0).Format("2006-01-02 15:04:05")
  535. roles_two, _ := service.GetAdminUserInfoByID(org_id, order.Creator)
  536. struct3506.SelRetnOpterName = roles_two.UserName
  537. struct3506.OrgName = miConfig.OrgName
  538. struct3506.AccessKey = miConfig.AccessKey
  539. struct3506.RequestUrl = miConfig.Url
  540. struct3506.SecretKey = miConfig.SecretKey
  541. struct3506.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  542. struct3506.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  543. struct3506.Url = miConfig.Url
  544. struct3506.AppId = miConfig.Cainfo
  545. struct3506.AppSecret = miConfig.AppSecret
  546. struct3506.Enckey = miConfig.EncKey
  547. struct3506.SignKey = miConfig.SignKey
  548. struct3506.SecretKey = miConfig.SecretKey
  549. result1, result2, result3 := service.FJyb3506(struct3506)
  550. fmt.Println(result1)
  551. fmt.Println(result2)
  552. fmt.Println(result3)
  553. }
  554. func (c *HisApiController) Get1318() {
  555. adminUser := c.GetAdminUserInfo()
  556. admin_user_id, _ := c.GetInt64("admin_user_id")
  557. code := c.GetString("code")
  558. code = ""
  559. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  560. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  561. api := ""
  562. if miConfig.MdtrtareaAdmvs == "320921" {
  563. api = "http://192.168.2.3:9532/" + "jsyb/1318?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  564. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&h_code=" + code
  565. } else {
  566. api = "http://192.168.5.251:9532/" + "jsyb/1318?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  567. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&h_code=" + code
  568. }
  569. resp, requestErr := http.Get(api)
  570. if requestErr != nil {
  571. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  572. return
  573. }
  574. body, ioErr := ioutil.ReadAll(resp.Body)
  575. if ioErr != nil {
  576. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  577. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  578. return
  579. }
  580. var respJSON map[string]interface{}
  581. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  582. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  583. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  584. return
  585. }
  586. //var res Result2406
  587. /*respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  588. result, _ := json.Marshal(respJSON)
  589. if err := json.Unmarshal([]byte(result), &res); err != nil {
  590. utils.ErrorLog("解析失败:%v", err)
  591. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  592. return
  593. }
  594. if res.Infcode == "0" {
  595. c.ServeSuccessJSON(map[string]interface{}{
  596. "result": "",
  597. })
  598. } else {
  599. c.ServeSuccessJSON(map[string]interface{}{
  600. "failed_code": -10,
  601. "msg": res.ErrMsg,
  602. })
  603. */return
  604. //}
  605. }
  606. func (c *HisApiController) Get2503() {
  607. adminUser := c.GetAdminUserInfo()
  608. admin_user_id, _ := c.GetInt64("admin_user_id")
  609. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  610. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  611. service.Gxyb2503(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.MdtrtareaAdmvs, miConfig.InsuplcAdmdvs, "", admin_user_id)
  612. }
  613. func (c *HisApiController) Get2406() {
  614. id, _ := c.GetInt64("id")
  615. record_time := c.GetString("record_time")
  616. his_patient_id, _ := c.GetInt64("his_patient_id")
  617. admin_user_id, _ := c.GetInt64("admin_user_id")
  618. diagnosis_id := c.GetString("diagnosis")
  619. timeLayout := "2006-01-02"
  620. loc, _ := time.LoadLocation("Local")
  621. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  622. if err != nil {
  623. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  624. return
  625. }
  626. recordDateTime := theTime.Unix()
  627. adminUser := c.GetAdminUserInfo()
  628. diagnosis_ids := strings.Split(diagnosis_id, ",")
  629. var config []*models.HisXtDiagnoseConfig
  630. for _, item := range diagnosis_ids {
  631. id, _ := strconv.ParseInt(item, 10, 64)
  632. diagnosisConfig, _ := service.FindDiagnoseById(id)
  633. config = append(config, &diagnosisConfig)
  634. }
  635. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  636. fmt.Println(his_patient_id)
  637. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  638. //timestamp := time.Now().Unix()
  639. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  640. var patientPrescription models.HisPrescriptionInfo
  641. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  642. if patientPrescription.ID == 0 {
  643. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  644. }
  645. var res2 Result2406
  646. if miConfig.MdtrtareaAdmvs == "341203" {
  647. data := make(map[string]interface{})
  648. client := &http.Client{}
  649. data["psn_no"] = his.PsnNo
  650. data["mdtrt_id"] = his.Number
  651. data["operator"] = roles.UserName
  652. data["cert_no"] = his.IdCardNo
  653. data["org_name"] = miConfig.OrgName
  654. data["psn_name"] = his.Name
  655. data["ipt_otp_no"] = his.IptOtpNo
  656. data["ipt_psn_sp_flag_type"] = "0901"
  657. data["ipt_psn_sp_flag"] = "1"
  658. data["fixmedins_code"] = miConfig.Code
  659. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  660. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  661. data["url"] = miConfig.Url
  662. utils.ErrorLog("接口返回数据解析JSON失败: %v", data)
  663. bytesData, _ := json.Marshal(data)
  664. var req *http.Request
  665. utils.ErrorLog("接口返回数据解析JSON失败: %v", miConfig.SecretKey)
  666. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2406", bytes.NewReader(bytesData))
  667. resp, _ := client.Do(req)
  668. defer resp.Body.Close()
  669. body, ioErr := ioutil.ReadAll(resp.Body)
  670. if ioErr != nil {
  671. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  672. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  673. return
  674. }
  675. var respJSON map[string]interface{}
  676. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  677. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  678. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  679. return
  680. }
  681. status := respJSON["data"].(map[string]interface{})["status"].(string)
  682. if status == "0" {
  683. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  684. c.ServeSuccessJSON(map[string]interface{}{
  685. "failed_code": -10,
  686. "msg": err_msg,
  687. })
  688. return
  689. }
  690. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  691. userJSONBytes, _ := json.Marshal(respJSON)
  692. fmt.Println("log")
  693. fmt.Println(string(userJSONBytes))
  694. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  695. utils.ErrorLog("解析失败:%v", err)
  696. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  697. return
  698. }
  699. }
  700. if res2.Infcode != 0 {
  701. adminUser := c.GetAdminUserInfo()
  702. errlog := &models.HisOrderError{
  703. UserOrgId: adminUser.CurrentOrgId,
  704. Ctime: time.Now().Unix(),
  705. Mtime: time.Now().Unix(),
  706. ErrMsg: res2.ErrMsg,
  707. Status: 1,
  708. PatientId: id,
  709. RecordTime: recordDateTime,
  710. Stage: 3,
  711. }
  712. service.CreateErrMsgLog(errlog)
  713. c.ServeSuccessJSON(map[string]interface{}{
  714. "failed_code": -10,
  715. "msg": res2.ErrMsg,
  716. })
  717. return
  718. } else {
  719. c.ServeSuccessJSON(map[string]interface{}{
  720. "msg": "上传成功",
  721. })
  722. return
  723. }
  724. }
  725. func (c *HisApiController) Get4105() {
  726. }
  727. func (c *HisApiController) Post5302() {
  728. patient_id, _ := c.GetInt64("id")
  729. admin_user_id, _ := c.GetInt64("admin_user_id")
  730. p, _ := service.GetHisPatientById(patient_id)
  731. adminUser := c.GetAdminUserInfo()
  732. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  733. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  734. service.Gxyb5302(p.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  735. }
  736. func (c *HisApiController) Get4104() {
  737. }
  738. type Output struct {
  739. CertNo string `json:"certno"`
  740. PsnName string `json:"psn_name"`
  741. CardNo string `json:"card_no"`
  742. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  743. CardSN string `json:"card_sn"`
  744. PsnCertType string `json:"psn_cert_type"`
  745. MdtrtCertNo string `json:"mdtrt_cert_no"`
  746. MdtrtCertType string `json:"mdtrt_cert_type"`
  747. QRCode string `json:"qrCode"`
  748. EcToken string `json:"ecToken"`
  749. }
  750. type AHResponse struct {
  751. Body AHBody `json:"body"`
  752. Code int `json:"code"`
  753. CSBCode int `json:"csbCode"`
  754. Message string `json:"message"`
  755. RequestID string `json:"requestId"`
  756. State struct{} `json:"state"`
  757. }
  758. type AHBody struct {
  759. ErrMsg string `json:"err_msg"`
  760. InfRefMsgID string `json:"inf_refmsgid"`
  761. InfCode int `json:"infcode"`
  762. Output struct {
  763. Result []struct {
  764. BasMednFlag string `json:"bas_medn_flag"`
  765. ChldMedcFlag string `json:"chld_medc_flag"`
  766. ChrgitmLv string `json:"chrgitm_lv"`
  767. Cnt float64 `json:"cnt"`
  768. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  769. DrtReimFlag string `json:"drt_reim_flag"`
  770. FeedetlSn string `json:"feedetl_sn"`
  771. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  772. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  773. InscpScpAmt float64 `json:"inscp_scp_amt"`
  774. ListSpItemFlag string `json:"list_sp_item_flag"`
  775. LmtUsedFlag string `json:"lmt_used_flag"`
  776. MedChrgitmType string `json:"med_chrgitm_type"`
  777. Memo string `json:"memo"`
  778. OverlmtAmt float64 `json:"overlmt_amt"`
  779. PreselfpayAmt float64 `json:"preselfpay_amt"`
  780. Pric float64 `json:"pric"`
  781. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  782. SelfpayProp float64 `json:"selfpay_prop"`
  783. } `json:"result"`
  784. } `json:"output"`
  785. }
  786. type Response struct {
  787. Output Output `json:"output"`
  788. Infcode int `json:"infcode"`
  789. InfRefMsgID string `json:"inf_refmsgid"`
  790. RefMsgTime string `json:"refmsg_time"`
  791. RespondTime string `json:"respond_time"`
  792. ErrMsg string `json:"err_msg"`
  793. WarnMsg string `json:"warn_msg"`
  794. SignType string `json:"signtype"`
  795. CAInfo string `json:"cainfo"`
  796. }
  797. func (c *HisApiController) Getquerydata() {
  798. query_type, _ := c.GetInt64("type")
  799. refd_setl_flag := c.GetString("refd_setl_flag")
  800. med_type := c.GetString("med_type")
  801. //admin_user_id,_ := c.GetInt64("admin_user_id")
  802. cert_no := c.GetString("cert_no")
  803. psn_no := c.GetString("psn_no")
  804. start_time := c.GetString("start_time")
  805. end_time := c.GetString("end_time")
  806. page, _ := c.GetInt64("page")
  807. limit, _ := c.GetInt64("limit")
  808. var bp models.BusinessParams5262
  809. bp.RefdSetlFlag = refd_setl_flag
  810. bp.MedType = med_type
  811. bp.Certno = cert_no
  812. bp.Psnno = psn_no
  813. bp.QBegntime = start_time
  814. bp.QEndtime = end_time
  815. if query_type == 1 { //本地
  816. Post5262(c, bp, page, limit)
  817. } else { //异地
  818. Post5267(c, bp, page, limit)
  819. }
  820. }
  821. func (c *HisApiController) Drugscheck() {
  822. admin_user_id, _ := c.GetInt64("admin_user_id")
  823. adminUser := c.GetAdminUserInfo()
  824. var queryResult []QueryResult
  825. drugs, _ := service.GetBatchDrugListtw(adminUser.CurrentOrgId)
  826. for _, item := range drugs {
  827. result := QueryResult{
  828. ID: item.ID,
  829. Name: item.DrugName,
  830. Code: item.MedicalInsuranceNumber,
  831. List_type_code: "101",
  832. }
  833. queryResult = append(queryResult, result)
  834. }
  835. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  836. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  837. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  838. for _, item := range queryResult {
  839. 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)
  840. }
  841. }
  842. func (c *HisApiController) Goodcheck() {
  843. admin_user_id, _ := c.GetInt64("admin_user_id")
  844. adminUser := c.GetAdminUserInfo()
  845. var queryResult []QueryResult
  846. goods, _ := service.GetBatchGoodInformationListtwo(adminUser.CurrentOrgId)
  847. for _, item := range goods {
  848. result := QueryResult{
  849. ID: item.ID,
  850. Name: item.GoodName,
  851. Code: item.SocialSecurityDirectoryCode,
  852. List_type_code: "301",
  853. }
  854. queryResult = append(queryResult, result)
  855. }
  856. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  857. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  858. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  859. for _, item := range queryResult {
  860. 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)
  861. //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)
  862. }
  863. }
  864. func (c *HisApiController) Projectcheck() {
  865. admin_user_id, _ := c.GetInt64("admin_user_id")
  866. adminUser := c.GetAdminUserInfo()
  867. var queryResult []QueryResult
  868. projects, _ := service.GetBathchMyPorjecgListtwo(adminUser.CurrentOrgId)
  869. for _, item := range projects {
  870. result := QueryResult{
  871. ID: item.ID,
  872. Name: item.ProjectName,
  873. Code: item.MedicalCode,
  874. List_type_code: "201",
  875. }
  876. queryResult = append(queryResult, result)
  877. }
  878. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  879. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  880. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  881. for _, item := range queryResult {
  882. 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)
  883. }
  884. }
  885. //func (c *HisApiController)CancleDia(){
  886. //
  887. // id, _ := c.GetInt64("id")
  888. // record_time := c.GetString("record_time")
  889. // his_patient_id, _ := c.GetInt64("his_patient_id")
  890. //
  891. // admin_user_id, _ := c.GetInt64("admin_user_id")
  892. //
  893. // diagnosis_id := c.GetString("diagnosis")
  894. // sick_type, _ := c.GetInt64("sick_type")
  895. // reg_type, _ := c.GetInt64("p_type")
  896. // begin_time := c.GetString("begin_time")
  897. // acct_used_flag_num, _ := c.GetInt64("acct_used_flag")
  898. //
  899. //
  900. // acct_used_flag := strconv.FormatInt(acct_used_flag_num, 10)
  901. //
  902. // fmt.Println(acct_used_flag)
  903. //
  904. //
  905. // timeLayout := "2006-01-02"
  906. // loc, _ := time.LoadLocation("Local")
  907. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  908. // if err != nil {
  909. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  910. // return
  911. // }
  912. // recordDateTime := theTime.Unix()
  913. // adminUser := c.GetAdminUserInfo()
  914. //
  915. //
  916. //
  917. //
  918. //
  919. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  920. // his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  921. // var patientPrescription models.HisPrescriptionInfo
  922. // patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  923. // if patientPrescription.ID == 0 {
  924. // patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  925. // }
  926. // //if patientPrescription.Do
  927. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  928. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  929. //
  930. // doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  931. //
  932. // diagnosis_ids := strings.Split(diagnosis_id, ",")
  933. //
  934. // var config []*models.HisXtDiagnoseConfig
  935. // for _, item := range diagnosis_ids {
  936. // id, _ := strconv.ParseInt(item, 10, 64)
  937. // diagnosisConfig, _ := service.FindDiagnoseById(id)
  938. // config = append(config, &diagnosisConfig)
  939. // }
  940. //
  941. // sickConfig, _ := service.FindSickById(sick_type)
  942. //
  943. //
  944. // data := make(map[string]interface{})
  945. // client := &http.Client{}
  946. // data["psn_no"] = his.PsnNo
  947. // data["mdtrt_id"] = his.Number
  948. // data["doctor"] = roles.UserName
  949. // data["department"] = department.Name
  950. // data["org_name"] = miConfig.OrgName
  951. // data["med_type"] = strconv.FormatInt(reg_type, 10)
  952. // data["doctor_id"] = doctor_info.DoctorNumber
  953. // data["new_doctor_name"] = doctor_info.UserName
  954. // data["fixmedins_code"] = miConfig.Code
  955. // data["insuplc_admdvs"] = his.InsuplcAdmdvs
  956. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  957. // data["secret_key"] = miConfig.SecretKey
  958. // data["sick_code"] = sickConfig.CountryCode
  959. // data["sick_name"] = sickConfig.ClassName
  960. // data["url"] = miConfig.Url
  961. // data["ak"] = miConfig.AccessKey
  962. // data["begin_time"] = begin_time
  963. // data["cainfo"] = miConfig.Cainfo
  964. // data["is_vaild"] = "0"
  965. //
  966. // data["dept"] = strconv.FormatInt(department.ID, 10)
  967. // data["config"] = config
  968. // bytesData, _ := json.Marshal(data)
  969. //
  970. // var req *http.Request
  971. // req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2203C", bytes.NewReader(bytesData))
  972. // resp, _ := client.Do(req)
  973. // defer resp.Body.Close()
  974. // body, ioErr := ioutil.ReadAll(resp.Body)
  975. // if ioErr != nil {
  976. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  977. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  978. // return
  979. // }
  980. // var respJSON map[string]interface{}
  981. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  982. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  983. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  984. // return
  985. // }
  986. //
  987. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  988. // userJSONBytes, _ := json.Marshal(respJSON)
  989. // fmt.Println("log")
  990. // fmt.Println(string(userJSONBytes))
  991. //
  992. // if err := json.Unmarshal(userJSONBytes, &ressix10265); err != nil {
  993. // utils.ErrorLog("解析失败:%v", err)
  994. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  995. // return
  996. // }
  997. // res2.InfRefmsgid = ressix10265.InfRefmsgid
  998. // res2.Output = ressix10265.Output
  999. // res2.ErrMsg = ressix10265.ErrMsg
  1000. // res2.Cainfo = ressix10265.Cainfo
  1001. // res2.WarnMsg = ressix10265.WarnMsg
  1002. // infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  1003. // res2.Infcode = infocode
  1004. //
  1005. //}
  1006. func (c *HisApiController) Get4102() {
  1007. order_id, _ := c.GetInt64("order_id")
  1008. admin_user_id, _ := c.GetInt64("admin_user_id")
  1009. stas_type := c.GetString("stas_type")
  1010. order, _ := service.GetHisOrderByIDTwo(order_id)
  1011. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1012. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1013. var pp models.PublicParams
  1014. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1015. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1016. pp.FixmedinsName = miConfig.OrgName
  1017. pp.FixmedinsCode = miConfig.Code
  1018. pp.RequestUrl = miConfig.Url
  1019. pp.Cainfo = miConfig.Cainfo
  1020. pp.SecretKey = miConfig.SecretKey
  1021. pp.AccessKey = miConfig.AccessKey
  1022. pp.OpterName = curRoles.UserName
  1023. if miConfig.MdtrtareaAdmvs == "350500" {
  1024. result, request, _ := service.Fjyb4102(order.PsnNo, order.SetlId, pp, stas_type)
  1025. //result, request := service.Jxyb4103(order.PsnNo,order.SetlId,pp)
  1026. saveLog(result, request, "4102", "清单确认")
  1027. var dat map[string]interface{}
  1028. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1029. fmt.Println(dat)
  1030. } else {
  1031. fmt.Println(err)
  1032. }
  1033. var empty ResultFourteen
  1034. userJSONBytes, _ := json.Marshal(dat)
  1035. if err := json.Unmarshal(userJSONBytes, &empty); err != nil {
  1036. utils.ErrorLog("解析失败:%v", err)
  1037. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1038. return
  1039. }
  1040. if empty.Infcode == 0 {
  1041. c.ServeSuccessJSON(map[string]interface{}{
  1042. "msg": "确认成功",
  1043. })
  1044. return
  1045. }
  1046. } else {
  1047. result, request := service.Jxyb4102(order.PsnNo, order.SetlId, pp, stas_type)
  1048. result2, request2 := service.Jxyb4103(order.PsnNo, order.SetlId, pp)
  1049. result3, request3 := service.Jxyb4105(pp)
  1050. saveLog(result, request, "4102", "清单确认")
  1051. saveLog(result2, request2, "4103", "清单确认")
  1052. saveLog(result3, request3, "4105", "清单统计")
  1053. var dat map[string]interface{}
  1054. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1055. fmt.Println(dat)
  1056. } else {
  1057. fmt.Println(err)
  1058. }
  1059. var empty ResultFourteen
  1060. userJSONBytes, _ := json.Marshal(dat)
  1061. if err := json.Unmarshal(userJSONBytes, &empty); err != nil {
  1062. utils.ErrorLog("解析失败:%v", err)
  1063. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1064. return
  1065. }
  1066. if empty.Infcode == 0 {
  1067. c.ServeSuccessJSON(map[string]interface{}{
  1068. "msg": "确认成功",
  1069. })
  1070. return
  1071. }
  1072. }
  1073. }
  1074. // 对账权限查询
  1075. func (c *HisApiController) Get3260() {
  1076. admin_user_id, _ := c.GetInt64("admin_user_id")
  1077. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1078. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1079. var api string
  1080. var res models.JSResult3260
  1081. if miConfig.MdtrtareaAdmvs == "320921" {
  1082. api = "http://192.168.2.3:9532/" + "jsyb/3260?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  1083. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  1084. } else {
  1085. api = "http://192.168.5.251:9532/" + "jsyb/3260?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  1086. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  1087. }
  1088. resp, requestErr := http.Get(api)
  1089. if requestErr != nil {
  1090. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1091. return
  1092. }
  1093. body, ioErr := ioutil.ReadAll(resp.Body)
  1094. if ioErr != nil {
  1095. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1096. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1097. return
  1098. }
  1099. var respJSON map[string]interface{}
  1100. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  1101. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1102. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1103. return
  1104. }
  1105. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1106. result, _ := json.Marshal(respJSON)
  1107. if err := json.Unmarshal([]byte(result), &res); err != nil {
  1108. utils.ErrorLog("解析失败:%v", err)
  1109. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1110. return
  1111. }
  1112. if res.Infcode == "0" {
  1113. c.ServeSuccessJSON(map[string]interface{}{
  1114. "result": res.Output.Data,
  1115. })
  1116. } else {
  1117. c.ServeSuccessJSON(map[string]interface{}{
  1118. "failed_code": -10,
  1119. "msg": res.ErrMsg,
  1120. })
  1121. return
  1122. }
  1123. }
  1124. func (c *HisApiController) Get3261() {
  1125. admin_user_id, _ := c.GetInt64("admin_user_id")
  1126. //month := c.GetString("month")
  1127. startTime := c.GetString("start_time")
  1128. //endTime, _ := c.GetString("end_time")
  1129. times := strings.Split(startTime, "-")
  1130. stmt_mon := times[0] + times[1]
  1131. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1132. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1133. var api string
  1134. var res models.JSResult3261
  1135. //var res10265 Result5301For10265
  1136. if miConfig.MdtrtareaAdmvs == "320921" {
  1137. api = "http://192.168.2.3:9532/" + "jsyb/3261?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  1138. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + stmt_mon
  1139. } else {
  1140. api = "http://192.168.5.251:9532/" + "jsyb/3261?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  1141. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + stmt_mon
  1142. }
  1143. resp, requestErr := http.Get(api)
  1144. if requestErr != nil {
  1145. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1146. return
  1147. }
  1148. body, ioErr := ioutil.ReadAll(resp.Body)
  1149. if ioErr != nil {
  1150. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1151. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1152. return
  1153. }
  1154. var respJSON map[string]interface{}
  1155. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  1156. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1157. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1158. return
  1159. }
  1160. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1161. result, _ := json.Marshal(respJSON)
  1162. if err := json.Unmarshal([]byte(result), &res); err != nil {
  1163. utils.ErrorLog("解析失败:%v", err)
  1164. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1165. return
  1166. }
  1167. if res.Infcode == "0" {
  1168. c.ServeSuccessJSON(map[string]interface{}{
  1169. "result": res.Output,
  1170. })
  1171. } else {
  1172. c.ServeSuccessJSON(map[string]interface{}{
  1173. "failed_code": -10,
  1174. "msg": res.ErrMsg,
  1175. })
  1176. return
  1177. }
  1178. }
  1179. type TempFun struct {
  1180. FundKey string
  1181. FundCode string
  1182. }
  1183. func (c *HisApiController) Get3262() {
  1184. admin_user_id, _ := c.GetInt64("admin_user_id")
  1185. startTime := c.GetString("start_time")
  1186. endTime := c.GetString("end_time")
  1187. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1188. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1189. //timeLayout := "2006-01-02"
  1190. //loc, _ := time.LoadLocation("Local")
  1191. //var theStartTIme int64
  1192. //if len(startTime) > 0 {
  1193. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", startTime+" 00:00:00", loc)
  1194. // if err != nil {
  1195. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1196. // return
  1197. // }
  1198. // theStartTIme = theTime.Unix()
  1199. //}
  1200. //var theEndtTIme int64
  1201. //if len(endTime) > 0 {
  1202. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", endTime+" 23:59:59", loc)
  1203. // if err != nil {
  1204. // utils.ErrorLog(err.Error())
  1205. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1206. // return
  1207. // }
  1208. // theEndtTIme = theTime.Unix()
  1209. //}
  1210. datas, _ := service.GetOrderByTimeTen(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId)
  1211. datas_two, _ := service.GetOrderByTimeTentwo(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId)
  1212. for _, team := range datas {
  1213. fmt.Println(team.PsnTime)
  1214. for _, team_two := range datas_two {
  1215. fmt.Println(team_two.PsnTime)
  1216. if team.FundKey == team_two.FundKey {
  1217. fmt.Println(team_two.PsnTime)
  1218. team.PsnTime = team.PsnTime + team_two.PsnTime*2
  1219. fmt.Println(team.PsnTime)
  1220. }
  1221. }
  1222. }
  1223. fmt.Println("1111")
  1224. fmt.Println(datas)
  1225. fmt.Println("1111")
  1226. var twos []models.FixMonRecDetailFileInTwo
  1227. for _, team := range datas {
  1228. var two models.FixMonRecDetailFileInTwo
  1229. two.MedType = team.MedType
  1230. two.Insutype = team.Insutype
  1231. two.PsnType = team.PsnType
  1232. two.MedType = team.MedType
  1233. two.FixBlngAdmdvs = "999999"
  1234. two.InsuAdmdvs = "555555"
  1235. two.PsnTime = team.PsnTime
  1236. two.PsnCnt = team.PsnCnt
  1237. two.FundKey = team.FundKey
  1238. ms, _ := strconv.ParseFloat(team.Sumamt, 64)
  1239. fps, _ := strconv.ParseFloat(team.Fund, 64)
  1240. ia, _ := strconv.ParseFloat(team.Amt, 64)
  1241. two.MedfeeSumAmt = ms
  1242. two.InscpAmt = ia
  1243. two.FundPaySumAmt = fps
  1244. twos = append(twos, two)
  1245. }
  1246. //startTime := c.GetString("start_time")
  1247. //endTime, _ := c.GetString("end_time")
  1248. times := strings.Split(startTime, "-")
  1249. stmt_mon := times[0] + times[1]
  1250. var funs []models.FundDetail
  1251. for _, item := range datas {
  1252. fun, _ := service.GetOrderDetailByTimeTen(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId, item.FundKey)
  1253. funs = append(funs, fun...)
  1254. }
  1255. var funInfos []models.Fund
  1256. //for _, item := range funs {
  1257. // var rf []models.FundInfo
  1258. // json.Unmarshal([]byte(item.SetlDetail), &rf)
  1259. // for _, subitem := range rf {
  1260. // var fund models.Fund
  1261. // fund.FundCode = subitem.FundPayType
  1262. // fund.FundName = subitem.FundPayTypeName
  1263. // fund.FundAmt = subitem.FundPayAmt
  1264. // fund.FundKey = item.FundKey
  1265. // fund.InsuAdmdvs = "555555"
  1266. // fund.FixBlngAdmdvs = "999999"
  1267. // funInfos = append(funInfos, fund)
  1268. // }
  1269. //}
  1270. var tempFuns []TempFun
  1271. for _, funInfo := range funInfos {
  1272. var tempFun TempFun
  1273. tempFun.FundKey = funInfo.FundKey
  1274. tempFun.FundCode = funInfo.FundCode
  1275. tempFuns = append(tempFuns, tempFun)
  1276. }
  1277. tempFuns = RemoveRepeatedFunElement(tempFuns)
  1278. fmt.Println(tempFuns)
  1279. var funInfosTwo []models.Fund
  1280. decimal.DivisionPrecision = 2
  1281. for _, item := range tempFuns {
  1282. var fund models.Fund
  1283. for _, subItem := range funInfos {
  1284. if item.FundKey == subItem.FundKey && item.FundCode == subItem.FundCode {
  1285. fund.FundKey = subItem.FundKey
  1286. fund.InsuAdmdvs = subItem.InsuAdmdvs
  1287. fund.FixBlngAdmdvs = subItem.FixBlngAdmdvs
  1288. fund.FundName = subItem.FundName
  1289. fund.FundCode = subItem.FundCode
  1290. fund.FundAmt, _ = decimal.NewFromFloat(fund.FundAmt).Add(decimal.NewFromFloat(subItem.FundAmt)).Float64()
  1291. }
  1292. }
  1293. funInfosTwo = append(funInfosTwo, fund)
  1294. }
  1295. fmt.Println("funInfosTwo")
  1296. fmt.Println(funInfosTwo)
  1297. var upld_btch string
  1298. var empty models.JSResultEmpty
  1299. data := make(map[string]interface{})
  1300. data["org_name"] = miConfig.OrgName
  1301. data["doctor"] = curRoles.UserName
  1302. data["doctor_name"] = curRoles.UserName
  1303. data["fixmedins_code"] = miConfig.Code
  1304. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  1305. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  1306. data["secret_key"] = miConfig.SecretKey
  1307. data["url"] = miConfig.Url
  1308. data["ak"] = miConfig.AccessKey
  1309. data["cainfo"] = miConfig.Cainfo
  1310. data["datas"] = twos
  1311. data["fund"] = funInfosTwo
  1312. fmt.Println(twos)
  1313. month := time.Unix(1557042972, 0).Format("1")
  1314. year := time.Now().Format("2006")
  1315. month = time.Now().Format("01")
  1316. day := time.Now().Format("02")
  1317. hour := time.Now().Format("15")
  1318. min := time.Now().Format("04")
  1319. sec := time.Now().Format("05")
  1320. fix_fill_date := year + month + day + hour + min + sec
  1321. data["fix_fill_dept"] = miConfig.OrgName
  1322. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  1323. data["fix_fill_psn"] = curRoles.UserName
  1324. data["fix_fill_date"] = fix_fill_date
  1325. data["stmt_loc"] = "2"
  1326. data["setl_mon"] = stmt_mon
  1327. upld_btch = "0"
  1328. data["upld_btch"] = upld_btch
  1329. //fmt.Println(data)
  1330. client := &http.Client{}
  1331. bytesData, _ := json.Marshal(data)
  1332. var req *http.Request
  1333. if miConfig.MdtrtareaAdmvs == "320921" {
  1334. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3262", bytes.NewReader(bytesData))
  1335. } else {
  1336. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3262", bytes.NewReader(bytesData))
  1337. }
  1338. resp, _ := client.Do(req)
  1339. defer resp.Body.Close()
  1340. body, ioErr := ioutil.ReadAll(resp.Body)
  1341. if ioErr != nil {
  1342. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1343. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1344. }
  1345. var respJSON map[string]interface{}
  1346. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1347. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1348. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1349. }
  1350. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1351. //fmt.Println(respJSON)
  1352. result, _ := json.Marshal(respJSON)
  1353. //fmt.Println(result)
  1354. if err := json.Unmarshal([]byte(result), &empty); err != nil {
  1355. utils.ErrorLog("解析失败:%v", err)
  1356. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1357. }
  1358. if empty.Infcode != "0" {
  1359. c.ServeSuccessJSON(map[string]interface{}{
  1360. "failed_code": -10,
  1361. "msg": empty.ErrMsg,
  1362. })
  1363. return
  1364. } else {
  1365. c.ServeSuccessJSON(map[string]interface{}{
  1366. "msg": "上传成功",
  1367. })
  1368. return
  1369. }
  1370. }
  1371. func RemoveRepeatedFunElement(arr []TempFun) (newArr []TempFun) {
  1372. newArr = make([]TempFun, 0)
  1373. for i := 0; i < len(arr); i++ {
  1374. repeat := false
  1375. for j := i + 1; j < len(arr); j++ {
  1376. if arr[i].FundKey == arr[j].FundKey && arr[i].FundCode == arr[j].FundCode {
  1377. repeat = true
  1378. break
  1379. }
  1380. }
  1381. if !repeat {
  1382. newArr = append(newArr, arr[i])
  1383. }
  1384. }
  1385. return
  1386. }
  1387. func (c *HisApiController) Get3263() {
  1388. admin_user_id, _ := c.GetInt64("admin_user_id")
  1389. startTime := c.GetString("start_time")
  1390. //endTime, _ := c.GetString("end_time")
  1391. times := strings.Split(startTime, "-")
  1392. setl_mon := times[0] + times[1]
  1393. upld_btch := "0"
  1394. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1395. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1396. var result3263 models.JSResult3263
  1397. data := make(map[string]interface{})
  1398. data["org_name"] = miConfig.OrgName
  1399. data["doctor"] = curRoles.UserName
  1400. data["doctor_name"] = curRoles.UserName
  1401. data["fixmedins_code"] = miConfig.Code
  1402. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  1403. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  1404. data["secret_key"] = miConfig.SecretKey
  1405. data["url"] = miConfig.Url
  1406. data["ak"] = miConfig.AccessKey
  1407. data["cainfo"] = miConfig.Cainfo
  1408. data["setl_mon"] = setl_mon
  1409. data["stmt_loc"] = "2"
  1410. data["upld_btch"] = upld_btch
  1411. client := &http.Client{}
  1412. bytesData, _ := json.Marshal(data)
  1413. var req *http.Request
  1414. if miConfig.MdtrtareaAdmvs == "320921" {
  1415. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3263", bytes.NewReader(bytesData))
  1416. } else {
  1417. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3263", bytes.NewReader(bytesData))
  1418. }
  1419. resp, _ := client.Do(req)
  1420. defer resp.Body.Close()
  1421. body, ioErr := ioutil.ReadAll(resp.Body)
  1422. if ioErr != nil {
  1423. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1424. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1425. }
  1426. var respJSON map[string]interface{}
  1427. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1428. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1429. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1430. }
  1431. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1432. fmt.Println(respJSON)
  1433. result, _ := json.Marshal(respJSON)
  1434. fmt.Println(result)
  1435. if err := json.Unmarshal([]byte(result), &result3263); err != nil {
  1436. utils.ErrorLog("解析失败:%v", err)
  1437. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1438. }
  1439. if result3263.Infcode != "0" {
  1440. c.ServeSuccessJSON(map[string]interface{}{
  1441. "failed_code": -10,
  1442. "msg": result3263.ErrMsg,
  1443. })
  1444. return
  1445. } else {
  1446. c.ServeSuccessJSON(map[string]interface{}{
  1447. "list": result3263.Output,
  1448. })
  1449. return
  1450. }
  1451. }
  1452. func (c *HisApiController) Get3264() {
  1453. admin_user_id, _ := c.GetInt64("admin_user_id")
  1454. startTime := c.GetString("start_time")
  1455. //endTime, _ := c.GetString("end_time")
  1456. times := strings.Split(startTime, "-")
  1457. setl_mon := times[0] + times[1]
  1458. upld_btch := "0"
  1459. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1460. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1461. //solidify_id := []
  1462. var result3263 models.JSResult3263
  1463. data := make(map[string]interface{})
  1464. data["org_name"] = miConfig.OrgName
  1465. data["doctor"] = curRoles.UserName
  1466. data["doctor_name"] = curRoles.UserName
  1467. data["fixmedins_code"] = miConfig.Code
  1468. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  1469. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  1470. data["secret_key"] = miConfig.SecretKey
  1471. data["url"] = miConfig.Url
  1472. data["ak"] = miConfig.AccessKey
  1473. data["cainfo"] = miConfig.Cainfo
  1474. data["setl_mon"] = setl_mon
  1475. data["stmt_loc"] = "2"
  1476. data["upld_btch"] = upld_btch
  1477. client := &http.Client{}
  1478. bytesData, _ := json.Marshal(data)
  1479. var req3263 *http.Request
  1480. if miConfig.MdtrtareaAdmvs == "320921" {
  1481. req3263, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3263", bytes.NewReader(bytesData))
  1482. } else {
  1483. req3263, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3263", bytes.NewReader(bytesData))
  1484. }
  1485. resp, _ := client.Do(req3263)
  1486. defer resp.Body.Close()
  1487. body, ioErr := ioutil.ReadAll(resp.Body)
  1488. if ioErr != nil {
  1489. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1490. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1491. }
  1492. var respJSON3263 map[string]interface{}
  1493. if err := json.Unmarshal([]byte(body), &respJSON3263); err != nil {
  1494. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1495. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1496. }
  1497. respJSON3263 = respJSON3263["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1498. fmt.Println(respJSON3263)
  1499. result, _ := json.Marshal(respJSON3263)
  1500. fmt.Println(result)
  1501. if err := json.Unmarshal([]byte(result), &result3263); err != nil {
  1502. utils.ErrorLog("解析失败:%v", err)
  1503. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1504. }
  1505. var ids []string
  1506. for _, item := range result3263.Output {
  1507. ids = append(ids, item.SolidifyID)
  1508. }
  1509. var empty models.JSResultEmpty
  1510. data2 := make(map[string]interface{})
  1511. data2["org_name"] = miConfig.OrgName
  1512. data2["doctor"] = curRoles.UserName
  1513. data2["doctor_name"] = curRoles.UserName
  1514. data2["fixmedins_code"] = miConfig.Code
  1515. data2["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  1516. data2["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  1517. data2["secret_key"] = miConfig.SecretKey
  1518. data2["url"] = miConfig.Url
  1519. data2["ak"] = miConfig.AccessKey
  1520. data2["cainfo"] = miConfig.Cainfo
  1521. data2["setl_mon"] = setl_mon
  1522. data2["stmt_loc"] = "2"
  1523. data2["upld_btch"] = upld_btch
  1524. data2["solidify_id"] = ids
  1525. client2 := &http.Client{}
  1526. bytesData2, _ := json.Marshal(data2)
  1527. var req *http.Request
  1528. if miConfig.MdtrtareaAdmvs == "320921" {
  1529. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3264", bytes.NewReader(bytesData2))
  1530. } else {
  1531. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3264", bytes.NewReader(bytesData2))
  1532. }
  1533. resp2, _ := client2.Do(req)
  1534. defer resp.Body.Close()
  1535. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  1536. if ioErr2 != nil {
  1537. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  1538. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1539. }
  1540. var respJSON map[string]interface{}
  1541. if err := json.Unmarshal([]byte(body2), &respJSON); err != nil {
  1542. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1543. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1544. }
  1545. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  1546. fmt.Println(respJSON)
  1547. result2, _ := json.Marshal(respJSON)
  1548. fmt.Println(result2)
  1549. if err := json.Unmarshal([]byte(result2), &empty); err != nil {
  1550. utils.ErrorLog("解析失败:%v", err)
  1551. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1552. }
  1553. if empty.Infcode != "0" {
  1554. c.ServeSuccessJSON(map[string]interface{}{
  1555. "failed_code": -10,
  1556. "msg": empty.ErrMsg,
  1557. })
  1558. return
  1559. } else {
  1560. c.ServeSuccessJSON(map[string]interface{}{
  1561. "msg": "",
  1562. })
  1563. return
  1564. }
  1565. }
  1566. func (c *HisApiController) Get3265() {
  1567. admin_user_id, _ := c.GetInt64("admin_user_id")
  1568. startTime := c.GetString("start_time")
  1569. //endTime, _ := c.GetString("end_time")
  1570. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1571. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1572. times := strings.Split(startTime, "-")
  1573. setl_mon := times[0] + times[1]
  1574. var upld_btch string
  1575. upld_btch = "0"
  1576. //var empty models.JSResultEmpty
  1577. var result3265 models.JSResult3264
  1578. var result3263 models.JSResult3263
  1579. data2 := make(map[string]interface{})
  1580. data2["org_name"] = miConfig.OrgName
  1581. data2["doctor"] = curRoles.UserName
  1582. data2["doctor_name"] = curRoles.UserName
  1583. data2["fixmedins_code"] = miConfig.Code
  1584. data2["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  1585. data2["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  1586. data2["secret_key"] = miConfig.SecretKey
  1587. data2["url"] = miConfig.Url
  1588. data2["ak"] = miConfig.AccessKey
  1589. data2["cainfo"] = miConfig.Cainfo
  1590. data2["setl_mon"] = setl_mon
  1591. data2["stmt_loc"] = "2"
  1592. data2["upld_btch"] = upld_btch
  1593. client2 := &http.Client{}
  1594. bytesData2, _ := json.Marshal(data2)
  1595. var req3263 *http.Request
  1596. if miConfig.MdtrtareaAdmvs == "320921" {
  1597. req3263, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3263", bytes.NewReader(bytesData2))
  1598. } else {
  1599. req3263, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3263", bytes.NewReader(bytesData2))
  1600. }
  1601. resp2, _ := client2.Do(req3263)
  1602. defer resp2.Body.Close()
  1603. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  1604. if ioErr2 != nil {
  1605. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  1606. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1607. }
  1608. var respJSON3263 map[string]interface{}
  1609. if err := json.Unmarshal([]byte(body2), &respJSON3263); err != nil {
  1610. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1611. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1612. }
  1613. respJSON3263 = respJSON3263["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1614. fmt.Println(respJSON3263)
  1615. result2, _ := json.Marshal(respJSON3263)
  1616. fmt.Println(result2)
  1617. if err := json.Unmarshal([]byte(result2), &result3263); err != nil {
  1618. utils.ErrorLog("解析失败:%v", err)
  1619. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1620. }
  1621. var ids []string
  1622. for _, item := range result3263.Output {
  1623. ids = append(ids, item.SolidifyID)
  1624. }
  1625. data := make(map[string]interface{})
  1626. data["org_name"] = miConfig.OrgName
  1627. data["doctor"] = curRoles.UserName
  1628. data["doctor_name"] = curRoles.UserName
  1629. data["fixmedins_code"] = miConfig.Code
  1630. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  1631. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  1632. data["secret_key"] = miConfig.SecretKey
  1633. data["url"] = miConfig.Url
  1634. data["ak"] = miConfig.AccessKey
  1635. data["cainfo"] = miConfig.Cainfo
  1636. data["setl_mon"] = setl_mon
  1637. data["solidify_id"] = ids
  1638. month := time.Unix(1557042972, 0).Format("1")
  1639. year := time.Now().Format("2006")
  1640. month = time.Now().Format("01")
  1641. day := time.Now().Format("02")
  1642. hour := time.Now().Format("15")
  1643. min := time.Now().Format("04")
  1644. sec := time.Now().Format("05")
  1645. fix_fill_date := year + month + day + hour + min + sec
  1646. data["fix_fill_dept"] = miConfig.OrgName
  1647. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  1648. data["fix_fill_psn"] = curRoles.UserName
  1649. data["fix_fill_date"] = fix_fill_date
  1650. data["stmt_loc"] = "2"
  1651. data["upld_btch"] = upld_btch
  1652. client := &http.Client{}
  1653. bytesData, _ := json.Marshal(data)
  1654. var req *http.Request
  1655. if miConfig.MdtrtareaAdmvs == "320921" {
  1656. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3265", bytes.NewReader(bytesData))
  1657. } else {
  1658. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3265", bytes.NewReader(bytesData))
  1659. }
  1660. resp, _ := client.Do(req)
  1661. defer resp.Body.Close()
  1662. body, ioErr := ioutil.ReadAll(resp.Body)
  1663. if ioErr != nil {
  1664. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1665. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1666. }
  1667. var respJSON map[string]interface{}
  1668. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1669. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1670. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1671. }
  1672. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1673. fmt.Println(respJSON)
  1674. result, _ := json.Marshal(respJSON)
  1675. fmt.Println(result)
  1676. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  1677. utils.ErrorLog("解析失败:%v", err)
  1678. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1679. }
  1680. if result3265.Infcode != "0" {
  1681. c.ServeSuccessJSON(map[string]interface{}{
  1682. "failed_code": -10,
  1683. "msg": result3265.ErrMsg,
  1684. })
  1685. return
  1686. } else {
  1687. c.ServeSuccessJSON(map[string]interface{}{
  1688. "info": result3265.Output,
  1689. })
  1690. return
  1691. }
  1692. }
  1693. func (c *HisApiController) Get3266() {
  1694. admin_user_id, _ := c.GetInt64("admin_user_id")
  1695. startTime := c.GetString("start_time")
  1696. //endTime, _ := c.GetString("end_time")
  1697. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1698. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1699. times := strings.Split(startTime, "-")
  1700. stmt_mon := times[0] + times[1]
  1701. var upld_btch string
  1702. //var empty models.JSResultEmpty
  1703. var result3265 models.JSResult3264
  1704. data := make(map[string]interface{})
  1705. data["org_name"] = miConfig.OrgName
  1706. data["doctor"] = curRoles.UserName
  1707. data["doctor_name"] = curRoles.UserName
  1708. data["fixmedins_code"] = miConfig.Code
  1709. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  1710. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  1711. data["secret_key"] = miConfig.SecretKey
  1712. data["url"] = miConfig.Url
  1713. data["ak"] = miConfig.AccessKey
  1714. data["cainfo"] = miConfig.Cainfo
  1715. data["setl_mon"] = stmt_mon
  1716. month := time.Unix(1557042972, 0).Format("1")
  1717. year := time.Now().Format("2006")
  1718. month = time.Now().Format("01")
  1719. day := time.Now().Format("02")
  1720. hour := time.Now().Format("15")
  1721. min := time.Now().Format("04")
  1722. sec := time.Now().Format("05")
  1723. fix_fill_date := year + month + day + hour + min + sec
  1724. data["fix_fill_dept"] = miConfig.OrgName
  1725. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  1726. data["fix_fill_psn"] = curRoles.UserName
  1727. data["fix_fill_date"] = fix_fill_date
  1728. data["stmt_loc"] = "2"
  1729. upld_btch = "0"
  1730. data["upld_btch"] = upld_btch
  1731. client := &http.Client{}
  1732. bytesData, _ := json.Marshal(data)
  1733. var req *http.Request
  1734. if miConfig.MdtrtareaAdmvs == "320921" {
  1735. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3266", bytes.NewReader(bytesData))
  1736. } else {
  1737. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3266", bytes.NewReader(bytesData))
  1738. }
  1739. resp, _ := client.Do(req)
  1740. defer resp.Body.Close()
  1741. body, ioErr := ioutil.ReadAll(resp.Body)
  1742. if ioErr != nil {
  1743. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1744. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1745. }
  1746. var respJSON map[string]interface{}
  1747. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1748. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1749. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1750. }
  1751. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1752. fmt.Println(respJSON)
  1753. result, _ := json.Marshal(respJSON)
  1754. fmt.Println(result)
  1755. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  1756. utils.ErrorLog("解析失败:%v", err)
  1757. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1758. }
  1759. if result3265.Infcode != "0" {
  1760. c.ServeSuccessJSON(map[string]interface{}{
  1761. "failed_code": -10,
  1762. "msg": result3265.ErrMsg,
  1763. })
  1764. return
  1765. } else {
  1766. c.ServeSuccessJSON(map[string]interface{}{
  1767. "info": result3265.Output,
  1768. })
  1769. return
  1770. }
  1771. }
  1772. func (c *HisApiController) Get3267() {
  1773. admin_user_id, _ := c.GetInt64("admin_user_id")
  1774. startTime := c.GetString("start_time")
  1775. //endTime, _ := c.GetString("end_time")
  1776. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1777. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1778. times := strings.Split(startTime, "-")
  1779. setl_mon := times[0] + times[1]
  1780. var upld_btch string
  1781. //var empty models.JSResultEmpty
  1782. var result3265 models.JSResult3264
  1783. upld_btch = "0"
  1784. data := make(map[string]interface{})
  1785. data["org_name"] = miConfig.OrgName
  1786. data["doctor"] = curRoles.UserName
  1787. data["doctor_name"] = curRoles.UserName
  1788. data["fixmedins_code"] = miConfig.Code
  1789. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  1790. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  1791. data["secret_key"] = miConfig.SecretKey
  1792. data["url"] = miConfig.Url
  1793. data["ak"] = miConfig.AccessKey
  1794. data["cainfo"] = miConfig.Cainfo
  1795. data["setl_mon"] = setl_mon
  1796. data["stmt_loc"] = "2"
  1797. data["upld_btch"] = upld_btch
  1798. client := &http.Client{}
  1799. bytesData, _ := json.Marshal(data)
  1800. var req *http.Request
  1801. if miConfig.MdtrtareaAdmvs == "320921" {
  1802. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3267", bytes.NewReader(bytesData))
  1803. } else {
  1804. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3267", bytes.NewReader(bytesData))
  1805. }
  1806. resp, _ := client.Do(req)
  1807. defer resp.Body.Close()
  1808. body, ioErr := ioutil.ReadAll(resp.Body)
  1809. if ioErr != nil {
  1810. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1811. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1812. }
  1813. var respJSON map[string]interface{}
  1814. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1815. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1816. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1817. }
  1818. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1819. fmt.Println(respJSON)
  1820. result, _ := json.Marshal(respJSON)
  1821. fmt.Println(result)
  1822. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  1823. utils.ErrorLog("解析失败:%v", err)
  1824. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1825. }
  1826. if result3265.Infcode != "0" {
  1827. c.ServeSuccessJSON(map[string]interface{}{
  1828. "failed_code": -10,
  1829. "msg": result3265.ErrMsg,
  1830. })
  1831. return
  1832. } else {
  1833. c.ServeSuccessJSON(map[string]interface{}{
  1834. "info": result3265.Output.Data,
  1835. })
  1836. return
  1837. }
  1838. }
  1839. func (c *HisApiController) Get3268() {
  1840. admin_user_id, _ := c.GetInt64("admin_user_id")
  1841. startTime := c.GetString("start_time")
  1842. endTime := c.GetString("end_time")
  1843. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1844. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1845. times := strings.Split(startTime, "-")
  1846. setl_mon := times[0] + times[1]
  1847. datas, _ := service.GetOrderByTimeTen(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId)
  1848. var twos []models.FixMonRecDetailFileInTwo
  1849. var funs []models.FundDetail
  1850. for _, item := range datas {
  1851. fun, _ := service.GetOrderDetailByTimeTen(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId, item.FundKey)
  1852. funs = append(funs, fun...)
  1853. }
  1854. var funInfos []models.Fund
  1855. //for _, item := range funs {
  1856. // var rf []models.FundInfo
  1857. // json.Unmarshal([]byte(item.SetlDetail), &rf)
  1858. // for _, subitem := range rf {
  1859. // var fund models.Fund
  1860. // fund.FundCode = subitem.FundPayType
  1861. // fund.FundName = subitem.FundPayTypeName
  1862. // fund.FundAmt = subitem.FundPayAmt
  1863. // fund.FundKey = item.FundKey
  1864. // fund.InsuAdmdvs = "555555"
  1865. // fund.FixBlngAdmdvs = miConfig.MdtrtareaAdmvs
  1866. // funInfos = append(funInfos, fund)
  1867. // }
  1868. //}
  1869. for _, team := range datas {
  1870. var two models.FixMonRecDetailFileInTwo
  1871. two.SetlDate = time.Now().Format("2006-01-02")
  1872. two.MedType = team.MedType
  1873. two.Insutype = team.Insutype
  1874. two.PsnType = team.PsnType
  1875. two.MedType = team.MedType
  1876. two.FixBlngAdmdvs = team.FixBlngAdmdvs
  1877. two.InsuAdmdvs = team.InsuAdmdvs
  1878. two.PsnTime = team.PsnTime
  1879. two.PsnCnt = team.PsnCnt
  1880. two.FundKey = team.FundKey
  1881. ms, _ := strconv.ParseFloat(team.Sumamt, 64)
  1882. fps, _ := strconv.ParseFloat(team.Fund, 64)
  1883. ia, _ := strconv.ParseFloat(team.Amt, 64)
  1884. two.MedfeeSumAmt = ms
  1885. two.InscpAmt = ia
  1886. two.FundPaySumAmt = fps
  1887. twos = append(twos, two)
  1888. }
  1889. var upld_btch string
  1890. upld_btch = "0"
  1891. var empty models.JSResultEmpty
  1892. data := make(map[string]interface{})
  1893. data["org_name"] = miConfig.OrgName
  1894. data["doctor"] = curRoles.UserName
  1895. data["doctor_name"] = curRoles.UserName
  1896. data["fixmedins_code"] = miConfig.Code
  1897. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  1898. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  1899. data["secret_key"] = miConfig.SecretKey
  1900. data["url"] = miConfig.Url
  1901. data["ak"] = miConfig.AccessKey
  1902. data["cainfo"] = miConfig.Cainfo
  1903. data["datas"] = twos
  1904. data["fund"] = funInfos
  1905. data["setl_mon"] = setl_mon
  1906. month := time.Unix(1557042972, 0).Format("1")
  1907. year := time.Now().Format("2006")
  1908. month = time.Now().Format("01")
  1909. day := time.Now().Format("02")
  1910. hour := time.Now().Format("15")
  1911. min := time.Now().Format("04")
  1912. sec := time.Now().Format("05")
  1913. fix_fill_date := year + month + day + hour + min + sec
  1914. data["fix_fill_dept"] = miConfig.OrgName
  1915. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  1916. data["fix_fill_psn"] = curRoles.UserName
  1917. data["fix_fill_date"] = fix_fill_date
  1918. data["stmt_loc"] = "2"
  1919. data["upld_btch"] = upld_btch
  1920. client := &http.Client{}
  1921. bytesData, _ := json.Marshal(data)
  1922. var req *http.Request
  1923. if miConfig.MdtrtareaAdmvs == "320921" {
  1924. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3268", bytes.NewReader(bytesData))
  1925. } else {
  1926. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3268", bytes.NewReader(bytesData))
  1927. }
  1928. resp, _ := client.Do(req)
  1929. defer resp.Body.Close()
  1930. body, ioErr := ioutil.ReadAll(resp.Body)
  1931. if ioErr != nil {
  1932. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1933. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1934. }
  1935. var respJSON map[string]interface{}
  1936. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1937. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1938. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1939. }
  1940. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1941. fmt.Println(respJSON)
  1942. result, _ := json.Marshal(respJSON)
  1943. fmt.Println(result)
  1944. if err := json.Unmarshal([]byte(result), &empty); err != nil {
  1945. utils.ErrorLog("解析失败:%v", err)
  1946. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1947. }
  1948. if empty.Infcode != "0" {
  1949. c.ServeSuccessJSON(map[string]interface{}{
  1950. "failed_code": -10,
  1951. "msg": empty.ErrMsg,
  1952. })
  1953. return
  1954. } else {
  1955. c.ServeSuccessJSON(map[string]interface{}{
  1956. "msg": "上传成功",
  1957. })
  1958. return
  1959. }
  1960. }
  1961. func (c *HisApiController) Get3269() {
  1962. admin_user_id, _ := c.GetInt64("admin_user_id")
  1963. startTime := c.GetString("start_time")
  1964. //endTime, _ := c.GetString("end_time")
  1965. times := strings.Split(startTime, "-")
  1966. setl_mon := times[0] + times[1]
  1967. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1968. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1969. var result3263 models.JSResult3263
  1970. data := make(map[string]interface{})
  1971. data["org_name"] = miConfig.OrgName
  1972. data["doctor"] = curRoles.UserName
  1973. data["doctor_name"] = curRoles.UserName
  1974. data["fixmedins_code"] = miConfig.Code
  1975. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  1976. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  1977. data["secret_key"] = miConfig.SecretKey
  1978. data["url"] = miConfig.Url
  1979. data["ak"] = miConfig.AccessKey
  1980. data["cainfo"] = miConfig.Cainfo
  1981. data["setl_mon"] = setl_mon
  1982. data["stmt_loc"] = "2"
  1983. client := &http.Client{}
  1984. bytesData, _ := json.Marshal(data)
  1985. var req *http.Request
  1986. if miConfig.MdtrtareaAdmvs == "320921" {
  1987. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3269", bytes.NewReader(bytesData))
  1988. } else {
  1989. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3269", bytes.NewReader(bytesData))
  1990. }
  1991. resp, _ := client.Do(req)
  1992. defer resp.Body.Close()
  1993. body, ioErr := ioutil.ReadAll(resp.Body)
  1994. if ioErr != nil {
  1995. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1996. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1997. }
  1998. var respJSON map[string]interface{}
  1999. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2000. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2001. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2002. }
  2003. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2004. fmt.Println(respJSON)
  2005. result, _ := json.Marshal(respJSON)
  2006. fmt.Println(result)
  2007. if err := json.Unmarshal([]byte(result), &result3263); err != nil {
  2008. utils.ErrorLog("解析失败:%v", err)
  2009. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2010. }
  2011. if result3263.Infcode != "0" {
  2012. c.ServeSuccessJSON(map[string]interface{}{
  2013. "failed_code": -10,
  2014. "msg": result3263.ErrMsg,
  2015. })
  2016. return
  2017. } else {
  2018. c.ServeSuccessJSON(map[string]interface{}{
  2019. "msg": "上传成功",
  2020. })
  2021. return
  2022. }
  2023. }
  2024. func (c *HisApiController) Get3270() {
  2025. admin_user_id, _ := c.GetInt64("admin_user_id")
  2026. startTime := c.GetString("start_time")
  2027. //endTime, _ := c.GetString("end_time")
  2028. times := strings.Split(startTime, "-")
  2029. setl_mon := times[0] + times[1]
  2030. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2031. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2032. var result3263 models.JSResult3263
  2033. data2 := make(map[string]interface{})
  2034. data2["org_name"] = miConfig.OrgName
  2035. data2["doctor"] = curRoles.UserName
  2036. data2["doctor_name"] = curRoles.UserName
  2037. data2["fixmedins_code"] = miConfig.Code
  2038. data2["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  2039. data2["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  2040. data2["secret_key"] = miConfig.SecretKey
  2041. data2["url"] = miConfig.Url
  2042. data2["ak"] = miConfig.AccessKey
  2043. data2["cainfo"] = miConfig.Cainfo
  2044. data2["setl_mon"] = setl_mon
  2045. data2["stmt_loc"] = "2"
  2046. client2 := &http.Client{}
  2047. bytesData2, _ := json.Marshal(data2)
  2048. var req3263 *http.Request
  2049. if miConfig.MdtrtareaAdmvs == "320921" {
  2050. req3263, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3269", bytes.NewReader(bytesData2))
  2051. } else {
  2052. req3263, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3269", bytes.NewReader(bytesData2))
  2053. }
  2054. resp2, _ := client2.Do(req3263)
  2055. defer resp2.Body.Close()
  2056. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  2057. if ioErr2 != nil {
  2058. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  2059. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2060. }
  2061. var respJSON3263 map[string]interface{}
  2062. if err := json.Unmarshal([]byte(body2), &respJSON3263); err != nil {
  2063. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2064. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2065. }
  2066. respJSON3263 = respJSON3263["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2067. fmt.Println(respJSON3263)
  2068. result2, _ := json.Marshal(respJSON3263)
  2069. fmt.Println(result2)
  2070. if err := json.Unmarshal([]byte(result2), &result3263); err != nil {
  2071. utils.ErrorLog("解析失败:%v", err)
  2072. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2073. }
  2074. var ids []string
  2075. for _, item := range result3263.Output {
  2076. ids = append(ids, item.SolidifyID)
  2077. }
  2078. var result3264 models.JSResult3264
  2079. data := make(map[string]interface{})
  2080. data["org_name"] = miConfig.OrgName
  2081. data["doctor"] = curRoles.UserName
  2082. data["doctor_name"] = curRoles.UserName
  2083. data["fixmedins_code"] = miConfig.Code
  2084. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  2085. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  2086. data["secret_key"] = miConfig.SecretKey
  2087. data["url"] = miConfig.Url
  2088. data["ak"] = miConfig.AccessKey
  2089. data["cainfo"] = miConfig.Cainfo
  2090. data["setl_mon"] = setl_mon
  2091. data["stmt_loc"] = "2"
  2092. data["solidify_id"] = ids
  2093. client := &http.Client{}
  2094. bytesData, _ := json.Marshal(data)
  2095. var req *http.Request
  2096. if miConfig.MdtrtareaAdmvs == "320921" {
  2097. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3270", bytes.NewReader(bytesData))
  2098. } else {
  2099. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3270", bytes.NewReader(bytesData))
  2100. }
  2101. resp, _ := client.Do(req)
  2102. defer resp.Body.Close()
  2103. body, ioErr := ioutil.ReadAll(resp.Body)
  2104. if ioErr != nil {
  2105. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2106. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2107. }
  2108. var respJSON map[string]interface{}
  2109. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2110. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2111. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2112. }
  2113. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2114. fmt.Println(respJSON)
  2115. result, _ := json.Marshal(respJSON)
  2116. fmt.Println(result)
  2117. if err := json.Unmarshal([]byte(result), &result3264); err != nil {
  2118. utils.ErrorLog("解析失败:%v", err)
  2119. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2120. }
  2121. if result3264.Infcode != "0" {
  2122. c.ServeSuccessJSON(map[string]interface{}{
  2123. "failed_code": -10,
  2124. "msg": result3264.ErrMsg,
  2125. })
  2126. return
  2127. } else {
  2128. c.ServeSuccessJSON(map[string]interface{}{
  2129. "info": result3264.Output,
  2130. })
  2131. return
  2132. }
  2133. }
  2134. func (c *HisApiController) Get3271() {
  2135. admin_user_id, _ := c.GetInt64("admin_user_id")
  2136. startTime := c.GetString("start_time")
  2137. //endTime, _ := c.GetString("end_time")
  2138. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2139. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2140. times := strings.Split(startTime, "-")
  2141. setl_mon := times[0] + times[1]
  2142. //var empty models.JSResultEmpty
  2143. var result3265 models.JSResult3264
  2144. var result3263 models.JSResult3263
  2145. data2 := make(map[string]interface{})
  2146. data2["org_name"] = miConfig.OrgName
  2147. data2["doctor"] = curRoles.UserName
  2148. data2["doctor_name"] = curRoles.UserName
  2149. data2["fixmedins_code"] = miConfig.Code
  2150. data2["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  2151. data2["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  2152. data2["secret_key"] = miConfig.SecretKey
  2153. data2["url"] = miConfig.Url
  2154. data2["ak"] = miConfig.AccessKey
  2155. data2["cainfo"] = miConfig.Cainfo
  2156. data2["setl_mon"] = setl_mon
  2157. data2["stmt_loc"] = "2"
  2158. client2 := &http.Client{}
  2159. bytesData2, _ := json.Marshal(data2)
  2160. var req3263 *http.Request
  2161. if miConfig.MdtrtareaAdmvs == "320921" {
  2162. req3263, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3269", bytes.NewReader(bytesData2))
  2163. } else {
  2164. req3263, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3269", bytes.NewReader(bytesData2))
  2165. }
  2166. resp2, _ := client2.Do(req3263)
  2167. defer resp2.Body.Close()
  2168. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  2169. if ioErr2 != nil {
  2170. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  2171. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2172. }
  2173. var respJSON3263 map[string]interface{}
  2174. if err := json.Unmarshal([]byte(body2), &respJSON3263); err != nil {
  2175. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2176. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2177. }
  2178. respJSON3263 = respJSON3263["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2179. fmt.Println(respJSON3263)
  2180. result2, _ := json.Marshal(respJSON3263)
  2181. fmt.Println(result2)
  2182. if err := json.Unmarshal([]byte(result2), &result3263); err != nil {
  2183. utils.ErrorLog("解析失败:%v", err)
  2184. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2185. }
  2186. var ids []string
  2187. for _, item := range result3263.Output {
  2188. ids = append(ids, item.SolidifyID)
  2189. }
  2190. data := make(map[string]interface{})
  2191. data["org_name"] = miConfig.OrgName
  2192. data["doctor"] = curRoles.UserName
  2193. data["doctor_name"] = curRoles.UserName
  2194. data["fixmedins_code"] = miConfig.Code
  2195. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  2196. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  2197. data["secret_key"] = miConfig.SecretKey
  2198. data["url"] = miConfig.Url
  2199. data["ak"] = miConfig.AccessKey
  2200. data["cainfo"] = miConfig.Cainfo
  2201. data["setl_mon"] = setl_mon
  2202. data["solidify_id"] = ids
  2203. month := time.Unix(1557042972, 0).Format("1")
  2204. year := time.Now().Format("2006")
  2205. month = time.Now().Format("01")
  2206. day := time.Now().Format("02")
  2207. hour := time.Now().Format("15")
  2208. min := time.Now().Format("04")
  2209. sec := time.Now().Format("05")
  2210. fix_fill_date := year + month + day + hour + min + sec
  2211. data["fix_fill_dept"] = miConfig.OrgName
  2212. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  2213. data["fix_fill_psn"] = curRoles.UserName
  2214. data["fix_fill_date"] = fix_fill_date
  2215. data["stmt_loc"] = "2"
  2216. client := &http.Client{}
  2217. bytesData, _ := json.Marshal(data)
  2218. var req *http.Request
  2219. if miConfig.MdtrtareaAdmvs == "320921" {
  2220. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3271", bytes.NewReader(bytesData))
  2221. } else {
  2222. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3271", bytes.NewReader(bytesData))
  2223. }
  2224. resp, _ := client.Do(req)
  2225. defer resp.Body.Close()
  2226. body, ioErr := ioutil.ReadAll(resp.Body)
  2227. if ioErr != nil {
  2228. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2229. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2230. }
  2231. var respJSON map[string]interface{}
  2232. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2233. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2234. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2235. }
  2236. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2237. fmt.Println(respJSON)
  2238. result, _ := json.Marshal(respJSON)
  2239. fmt.Println(result)
  2240. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  2241. utils.ErrorLog("解析失败:%v", err)
  2242. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2243. }
  2244. if result3265.Infcode != "0" {
  2245. c.ServeSuccessJSON(map[string]interface{}{
  2246. "failed_code": -10,
  2247. "msg": result3265.ErrMsg,
  2248. })
  2249. return
  2250. } else {
  2251. c.ServeSuccessJSON(map[string]interface{}{
  2252. "info": result3265.Output.Data,
  2253. })
  2254. return
  2255. }
  2256. }
  2257. func (c *HisApiController) Get3272() {
  2258. admin_user_id, _ := c.GetInt64("admin_user_id")
  2259. startTime := c.GetString("start_time")
  2260. //endTime, _ := c.GetString("end_time")
  2261. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2262. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2263. times := strings.Split(startTime, "-")
  2264. setl_mon := times[0] + times[1]
  2265. var upld_btch string
  2266. //var empty models.JSResultEmpty
  2267. var result3265 models.JSResult3264
  2268. data := make(map[string]interface{})
  2269. data["org_name"] = miConfig.OrgName
  2270. data["doctor"] = curRoles.UserName
  2271. data["doctor_name"] = curRoles.UserName
  2272. data["fixmedins_code"] = miConfig.Code
  2273. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  2274. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  2275. data["secret_key"] = miConfig.SecretKey
  2276. data["url"] = miConfig.Url
  2277. data["ak"] = miConfig.AccessKey
  2278. data["cainfo"] = miConfig.Cainfo
  2279. data["setl_mon"] = setl_mon
  2280. month := time.Unix(1557042972, 0).Format("1")
  2281. year := time.Now().Format("2006")
  2282. month = time.Now().Format("01")
  2283. day := time.Now().Format("02")
  2284. hour := time.Now().Format("15")
  2285. min := time.Now().Format("04")
  2286. sec := time.Now().Format("05")
  2287. fix_fill_date := year + month + day + hour + min + sec
  2288. data["fix_fill_dept"] = miConfig.OrgName
  2289. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  2290. data["fix_fill_psn"] = curRoles.UserName
  2291. data["fix_fill_date"] = fix_fill_date
  2292. data["stmt_loc"] = "2"
  2293. data["upld_btch"] = upld_btch
  2294. client := &http.Client{}
  2295. bytesData, _ := json.Marshal(data)
  2296. var req *http.Request
  2297. if miConfig.MdtrtareaAdmvs == "320921" {
  2298. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3272", bytes.NewReader(bytesData))
  2299. } else {
  2300. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3272", bytes.NewReader(bytesData))
  2301. }
  2302. resp, _ := client.Do(req)
  2303. defer resp.Body.Close()
  2304. body, ioErr := ioutil.ReadAll(resp.Body)
  2305. if ioErr != nil {
  2306. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2307. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2308. }
  2309. var respJSON map[string]interface{}
  2310. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2311. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2312. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2313. }
  2314. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2315. fmt.Println(respJSON)
  2316. result, _ := json.Marshal(respJSON)
  2317. fmt.Println(result)
  2318. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  2319. utils.ErrorLog("解析失败:%v", err)
  2320. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2321. }
  2322. if result3265.Infcode != "0" {
  2323. c.ServeSuccessJSON(map[string]interface{}{
  2324. "failed_code": -10,
  2325. "msg": result3265.ErrMsg,
  2326. })
  2327. return
  2328. } else {
  2329. c.ServeSuccessJSON(map[string]interface{}{
  2330. "info": result3265.Output,
  2331. })
  2332. return
  2333. }
  2334. }
  2335. func (c *HisApiController) Get3273() {
  2336. admin_user_id, _ := c.GetInt64("admin_user_id")
  2337. startTime := c.GetString("start_time")
  2338. //endTime, _ := c.GetString("end_time")
  2339. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2340. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2341. times := strings.Split(startTime, "-")
  2342. setl_mon := times[0] + times[1]
  2343. var result3265 models.JSResult3264
  2344. data := make(map[string]interface{})
  2345. data["org_name"] = miConfig.OrgName
  2346. data["doctor"] = curRoles.UserName
  2347. data["doctor_name"] = curRoles.UserName
  2348. data["fixmedins_code"] = miConfig.Code
  2349. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  2350. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  2351. data["secret_key"] = miConfig.SecretKey
  2352. data["url"] = miConfig.Url
  2353. data["ak"] = miConfig.AccessKey
  2354. data["cainfo"] = miConfig.Cainfo
  2355. data["setl_mon"] = setl_mon
  2356. data["stmt_loc"] = "2"
  2357. client := &http.Client{}
  2358. bytesData, _ := json.Marshal(data)
  2359. var req *http.Request
  2360. if miConfig.MdtrtareaAdmvs == "320921" {
  2361. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3273", bytes.NewReader(bytesData))
  2362. } else {
  2363. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3273", bytes.NewReader(bytesData))
  2364. }
  2365. resp, _ := client.Do(req)
  2366. defer resp.Body.Close()
  2367. body, ioErr := ioutil.ReadAll(resp.Body)
  2368. if ioErr != nil {
  2369. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2370. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2371. }
  2372. var respJSON map[string]interface{}
  2373. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2374. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2375. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2376. }
  2377. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  2378. fmt.Println(respJSON)
  2379. result, _ := json.Marshal(respJSON)
  2380. fmt.Println(result)
  2381. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  2382. utils.ErrorLog("解析失败:%v", err)
  2383. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2384. }
  2385. if result3265.Infcode != "0" {
  2386. c.ServeSuccessJSON(map[string]interface{}{
  2387. "failed_code": -10,
  2388. "msg": result3265.ErrMsg,
  2389. })
  2390. return
  2391. } else {
  2392. c.ServeSuccessJSON(map[string]interface{}{
  2393. "info": result3265.Output.Data,
  2394. })
  2395. return
  2396. }
  2397. }
  2398. func (c *HisApiController) Get3274() {
  2399. //if miConfig.MdtrtareaAdmvs == "320921" {
  2400. // api = "http://192.168.2.3:9532/" + "jsyb/3274?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  2401. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  2402. // "&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
  2403. //
  2404. //} else {
  2405. // api = "http://192.168.5.251:9532/" + "jsyb/3274?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  2406. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  2407. // "&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
  2408. //
  2409. //}
  2410. }
  2411. func (c *HisApiController) Get3275() {
  2412. //if miConfig.MdtrtareaAdmvs == "320921" {
  2413. // api = "http://192.168.2.3:9532/" + "jsyb/3275?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  2414. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  2415. // "&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
  2416. //
  2417. //} else {
  2418. // api = "http://192.168.5.251:9532/" + "jsyb/3275?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  2419. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  2420. // "&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
  2421. //
  2422. //}
  2423. }
  2424. func (c *HisApiController) Get3276() {
  2425. //admin_user_id, _ := c.GetInt64("admin_user_id")
  2426. //month := c.GetString("month")
  2427. //
  2428. //curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2429. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2430. //var api string
  2431. //var res Result5301
  2432. //
  2433. //if miConfig.MdtrtareaAdmvs == "320921" {
  2434. // api = "http://192.168.2.3:9532/" + "jsyb/3276?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  2435. // "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + month
  2436. //} else {
  2437. // api = "http://192.168.5.251:9532/" + "jsyb/3264?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  2438. // "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + month
  2439. //}
  2440. //
  2441. //resp, requestErr := http.Get(api)
  2442. //if requestErr != nil {
  2443. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2444. // return
  2445. //}
  2446. //
  2447. //body, ioErr := ioutil.ReadAll(resp.Body)
  2448. //if ioErr != nil {
  2449. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2450. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2451. // return
  2452. //}
  2453. //var respJSON map[string]interface{}
  2454. //if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  2455. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2456. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2457. // return
  2458. //}
  2459. //
  2460. //respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2461. //result, _ := json.Marshal(respJSON)
  2462. //if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  2463. // utils.ErrorLog("解析失败:%v", err)
  2464. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2465. // return
  2466. //}
  2467. }
  2468. func (c *HisApiController) Get3277() {
  2469. //admin_user_id, _ := c.GetInt64("admin_user_id")
  2470. //month := c.GetString("month")
  2471. //
  2472. //curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2473. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2474. //var api string
  2475. //var res Result5301
  2476. //
  2477. //if miConfig.MdtrtareaAdmvs == "320921" {
  2478. // api = "http://192.168.2.3:9532/" + "jsyb/3264?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  2479. // "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + month
  2480. //} else {
  2481. // api = "http://192.168.5.251:9532/" + "jsyb/3264?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  2482. // "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + month
  2483. //}
  2484. //
  2485. //resp, requestErr := http.Get(api)
  2486. //if requestErr != nil {
  2487. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2488. // return
  2489. //}
  2490. //
  2491. //body, ioErr := ioutil.ReadAll(resp.Body)
  2492. //if ioErr != nil {
  2493. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2494. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2495. // return
  2496. //}
  2497. //var respJSON map[string]interface{}
  2498. //if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  2499. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2500. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2501. // return
  2502. //}
  2503. //
  2504. //respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2505. //result, _ := json.Marshal(respJSON)
  2506. //if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  2507. // utils.ErrorLog("解析失败:%v", err)
  2508. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2509. // return
  2510. //}
  2511. }
  2512. func (c *HisApiController) GetCFYLJG001() {
  2513. admin_user_id, _ := c.GetInt64("admin_user_id")
  2514. patient_id, _ := c.GetInt64("patient_id")
  2515. his_patient_id, _ := c.GetInt64("his_patient_id")
  2516. record_time := c.GetString("record_time")
  2517. admin_user_id = 3626
  2518. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  2519. psn, _ := service.GetPsnByPatientId(patient_id)
  2520. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2521. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2522. var cFYLJG001 models.CFYLJG001
  2523. timeLayout := "2006-01-02"
  2524. loc, _ := time.LoadLocation("Local")
  2525. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  2526. if err != nil {
  2527. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  2528. return
  2529. }
  2530. recordDateTime := theTime.Unix()
  2531. prescriptions, _ := service.GetHisPrescriptionForMedType(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  2532. info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  2533. //info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  2534. doctor_info, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, info.DoctorId)
  2535. //dept, _ := service.GetDepartMentDetail(info.Departments)
  2536. for _, item := range prescriptions {
  2537. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, item.Creator)
  2538. if his.IdCardType == 1 {
  2539. bas := strings.Split(psn.CardInfo, "|")
  2540. basNumber := bas[1]
  2541. fmt.Println(basNumber)
  2542. card_sn := bas[3]
  2543. card_no := bas[2]
  2544. cFYLJG001.MdtrtCertType = "03"
  2545. cFYLJG001.CardSn = card_sn
  2546. cFYLJG001.MdtrtCertNo = card_no
  2547. cFYLJG001.EcToken = ""
  2548. cFYLJG001.AuthNo = ""
  2549. } else if his.IdCardType == 2 {
  2550. cFYLJG001.MdtrtCertType = "02"
  2551. cFYLJG001.CardSn = ""
  2552. cFYLJG001.MdtrtCertNo = his.IdCardNo
  2553. cFYLJG001.EcToken = ""
  2554. cFYLJG001.AuthNo = ""
  2555. } else if his.IdCardType == 4 {
  2556. cFYLJG001.MdtrtCertType = "01"
  2557. cFYLJG001.CardSn = ""
  2558. cFYLJG001.MdtrtCertNo = psn.VerifyNumber
  2559. cFYLJG001.EcToken = psn.VerifyNumber
  2560. cFYLJG001.AuthNo = ""
  2561. }
  2562. cFYLJG001.BizTypeCode = "01"
  2563. cFYLJG001.InsuAdmdvs = psn.InsuplcAdmdvs
  2564. cFYLJG001.HospRxno = strconv.FormatInt(item.ID, 10)
  2565. cFYLJG001.RxTypeCode = "1"
  2566. tempTime := time.Unix(item.PreTime, 0)
  2567. timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  2568. cFYLJG001.PrscTime = timeFormatOne
  2569. var count float64
  2570. if item.Type == 1 {
  2571. for _, sumItem := range item.HisDoctorAdviceInfo {
  2572. count = count + sumItem.PrescribingNumber
  2573. }
  2574. }
  2575. cFYLJG001.RxDrugCnt = count
  2576. cFYLJG001.ValiDays = "5"
  2577. ts := time.Unix(item.PreTime, 0)
  2578. record_time2 := ts.AddDate(0, 0, int(5)).Unix()
  2579. tempTime3 := time.Unix(record_time2, 0)
  2580. timeFormat3 := tempTime3.Format("2006-01-02 15:04:05")
  2581. cFYLJG001.ValiEndTime = timeFormat3
  2582. cFYLJG001.RxCotnFlag = "0"
  2583. for _, subItem := range item.HisDoctorAdviceInfo {
  2584. var drug models.RxDrug
  2585. drug.MedListCodg = subItem.BaseDrugLib.MedicalInsuranceNumber
  2586. drug.MedinsListCodg = subItem.BaseDrugLib.MedicalInsuranceNumber
  2587. drug.RxItemTypeCode = "11"
  2588. drug.DrugDosform = "乳膏剂" //TODO
  2589. if subItem.BaseDrugLib.MinUnit != subItem.BaseDrugLib.DoseUnit {
  2590. drug.DrugSpec = subItem.BaseDrugLib.Dose + subItem.BaseDrugLib.DoseUnit + "*" + strconv.FormatInt(subItem.BaseDrugLib.MinNumber, 10) + subItem.BaseDrugLib.MinUnit + "/" + subItem.BaseDrugLib.MaxUnit
  2591. }
  2592. drug.MedcWayDscr = subItem.DeliveryWay
  2593. tempTime2 := time.Unix(subItem.StartTime, 0)
  2594. timeFormatTwo := tempTime2.Format("2006-01-02 15:04:05")
  2595. drug.MedcBegntime = timeFormatTwo
  2596. if subItem.Day > 0 {
  2597. ts := time.Unix(subItem.StartTime, 0)
  2598. record_time := ts.AddDate(0, 0, int(subItem.Day)).Unix()
  2599. tempTime4 := time.Unix(record_time, 0)
  2600. timeFormat5 := tempTime4.Format("2006-01-02 15:04:05")
  2601. drug.MedcEndtime = timeFormat5
  2602. } else {
  2603. tempTime2 := time.Unix(subItem.StartTime, 0)
  2604. timeFormatTwo := tempTime2.Format("2006-01-02 15:04:05")
  2605. drug.MedcEndtime = timeFormatTwo
  2606. }
  2607. drug.MedcDays = strconv.FormatInt(subItem.Day, 10)
  2608. drug.DrugPric = fmt.Sprintf("%.2f", subItem.Price)
  2609. drug.DrugSumamt = fmt.Sprintf("%.2f", subItem.Price*subItem.PrescribingNumber)
  2610. drug.DrugCnt = subItem.PrescribingNumber
  2611. drug.DrugDosunt = subItem.PrescribingNumberUnit
  2612. drug.DrugGenname = subItem.AdviceName
  2613. drug.MedcWayCodg = subItem.DeliveryWay
  2614. //drug.DrugTotlcnt = subItem.PrescribingNumber
  2615. drug.SinDoscnt = subItem.SingleDose
  2616. drug.SinDosunt = subItem.SingleDoseUnit
  2617. drug.UsedFrquCodg = strconv.FormatInt(subItem.ID, 10)
  2618. drug.UsedFrquName = subItem.ExecutionFrequency
  2619. drug.DrugTotlcnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  2620. drug.DrugTotlcntEmp = subItem.PrescribingNumberUnit
  2621. drug.HospApprFlag = "1"
  2622. cFYLJG001.List = append(cFYLJG001.List, drug)
  2623. }
  2624. cFYLJG001.Mdtrtinfo.FixmedinsCode = miConfig.Code
  2625. cFYLJG001.Mdtrtinfo.FixmedinsName = miConfig.Code
  2626. cFYLJG001.Mdtrtinfo.MdtrtID = his.Number
  2627. cFYLJG001.Mdtrtinfo.MedType = item.MedType
  2628. cFYLJG001.Mdtrtinfo.IptOtpNo = his.IptOtpNo
  2629. cFYLJG001.Mdtrtinfo.OtpIptFlag = "1"
  2630. cFYLJG001.Mdtrtinfo.PsnNo = his.PsnNo
  2631. cFYLJG001.Mdtrtinfo.PatnName = his.PsnName
  2632. cFYLJG001.Mdtrtinfo.Certno = his.IdCardNo
  2633. cFYLJG001.Mdtrtinfo.PsnCertType = "01"
  2634. cFYLJG001.Mdtrtinfo.PatnAge = fmt.Sprintf("%.1f", his.Age)
  2635. cFYLJG001.Mdtrtinfo.PatnHgt = "160" //todo
  2636. cFYLJG001.Mdtrtinfo.PatnWt = "58" //todo
  2637. cFYLJG001.Mdtrtinfo.Gend = his.Gend
  2638. cFYLJG001.Mdtrtinfo.PatnAge = fmt.Sprintf("%.1f", his.Age)
  2639. cFYLJG001.Mdtrtinfo.PrscDeptName = "肾内科"
  2640. cFYLJG001.Mdtrtinfo.PrscDeptCode = "A03.06"
  2641. cFYLJG001.Mdtrtinfo.DrCode = doctor.DoctorNumber
  2642. cFYLJG001.Mdtrtinfo.PrscDrName = doctor.UserName
  2643. cFYLJG001.Mdtrtinfo.DrProfttlCodg = "234"
  2644. cFYLJG001.Mdtrtinfo.DrProfttlName = "医师"
  2645. cFYLJG001.Mdtrtinfo.DrDeptCode = "A03.06"
  2646. cFYLJG001.Mdtrtinfo.DrDeptName = "肾内科"
  2647. cFYLJG001.Mdtrtinfo.Caty = "A03.06"
  2648. tempTime2 := time.Now().Unix()
  2649. tempTime6 := time.Unix(tempTime2, 0)
  2650. timeFormatTwo := tempTime6.Format("2006-01-02 15:04:05")
  2651. cFYLJG001.Mdtrtinfo.MdtrtTime = timeFormatTwo
  2652. cFYLJG001.Mdtrtinfo.DiseCodg = "M07803"
  2653. cFYLJG001.Mdtrtinfo.SpDiseFlag = "1"
  2654. cFYLJG001.Mdtrtinfo.MaindiagCode = "N18.500"
  2655. cFYLJG001.Mdtrtinfo.MaindiagName = "慢性肾脏病5期"
  2656. //memo := make(map[string]interface{})
  2657. //inputData := make(map[string]interface{}, 0)
  2658. //type MyData struct {
  2659. // Insutype string `json:"insutype"`
  2660. //}
  2661. //
  2662. // data := MyData{
  2663. // Insutype: his.Insutype,
  2664. //}
  2665. //
  2666. diagnosis_ids := strings.Split(info.Diagnosis, ",")
  2667. var config []*models.HisXtDiagnoseConfig
  2668. for _, item := range diagnosis_ids {
  2669. id, _ := strconv.ParseInt(item, 10, 64)
  2670. diagnosisConfig, _ := service.FindDiagnoseById(id)
  2671. config = append(config, &diagnosisConfig)
  2672. }
  2673. for index, subitem := range config {
  2674. if index == 0 {
  2675. var dia models.DiseInfo
  2676. dia.DiagType = "1"
  2677. dia.MaindiagFlag = "1"
  2678. dia.DiagSrtNo = strconv.FormatInt(int64(index+1), 10)
  2679. dia.DiagCode = subitem.CountryCode
  2680. dia.DiagName = subitem.ClassName
  2681. dia.DiagDept = "肾内科"
  2682. dia.DiagDrNo = doctor.DoctorNumber
  2683. dia.DiagDrName = doctor.UserName
  2684. tempTime3 := time.Unix(item.PreTime, 0)
  2685. timeFormatTwo := tempTime3.Format("2006-01-02 15:04:05")
  2686. dia.DiagTime = timeFormatTwo
  2687. cFYLJG001.Diseinfo = append(cFYLJG001.Diseinfo, dia)
  2688. } else {
  2689. var dia models.DiseInfo
  2690. dia.DiagType = "1"
  2691. dia.MaindiagFlag = "0"
  2692. dia.DiagSrtNo = strconv.FormatInt(int64(index+1), 10)
  2693. dia.DiagCode = subitem.CountryCode
  2694. dia.DiagName = subitem.ClassName
  2695. dia.DiagDept = "肾内科"
  2696. dia.DiagDrNo = doctor.DoctorNumber
  2697. dia.DiagDrName = doctor.UserName
  2698. tempTime3 := time.Unix(item.PreTime, 0)
  2699. timeFormatTwo := tempTime3.Format("2006-01-02 15:04:05")
  2700. dia.DiagTime = timeFormatTwo
  2701. cFYLJG001.Diseinfo = append(cFYLJG001.Diseinfo, dia)
  2702. }
  2703. }
  2704. result, request := service.GetCFYLJG001(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG001, his.Insutype)
  2705. saveLog(result, request, "GetCFYLJG001", "GetCFYLJG001")
  2706. var res ResultCFYLJG001
  2707. var respJSON2 map[string]interface{}
  2708. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  2709. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2710. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2711. return
  2712. }
  2713. userJSONBytes2, _ := json.Marshal(respJSON2)
  2714. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2715. utils.ErrorLog("解析失败:%v", err)
  2716. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2717. return
  2718. }
  2719. if res.Infcode == -1 {
  2720. c.ServeSuccessJSON(map[string]interface{}{
  2721. "failed_code": -10,
  2722. "msg": res.ErrMsg,
  2723. })
  2724. return
  2725. } else {
  2726. var flow models.HisPrescriptionFlow
  2727. flow.Ctime = time.Now().Unix()
  2728. flow.SignDigest = ""
  2729. flow.RxTraceCode = res.Output.RxTraceCode
  2730. flow.HiRxno = res.Output.HiRxno
  2731. flow.MID = his.Number
  2732. flow.Status = 1
  2733. flow.DCode = doctor_info.DoctorNumber
  2734. flow.OriginalRxFile = ""
  2735. flow.OriginalValue = ""
  2736. flow.SignCertDn = ""
  2737. flow.UserOrgId = 10454
  2738. flow.SignCertSn = ""
  2739. flow.Mtime = time.Now().Unix()
  2740. service.Createflow(&flow)
  2741. c.ServeSuccessJSON(map[string]interface{}{
  2742. "msg": "上传成功",
  2743. })
  2744. }
  2745. }
  2746. }
  2747. func (c *HisApiController) GetCFYLJG002() {
  2748. admin_user_id, _ := c.GetInt64("admin_user_id")
  2749. his_patient_id, _ := c.GetInt64("his_patient_id")
  2750. record_time := c.GetString("record_time")
  2751. admin_user_id = 3626
  2752. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  2753. //id, _ := c.GetInt64("id")
  2754. admin_user_id = 3626
  2755. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2756. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2757. flow, _ := service.Getflowtwo(his.Number)
  2758. //his, _ := service.GetHisPatientByNumber(flow.MID)
  2759. //record_time := c.GetString("record_time")
  2760. patient_id, _ := c.GetInt64("patient_id")
  2761. //patient_id = 23834
  2762. //record_time = "2023-09-18"
  2763. timeLayout := "2006-01-02"
  2764. loc, _ := time.LoadLocation("Local")
  2765. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  2766. if err != nil {
  2767. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  2768. return
  2769. }
  2770. recordDateTime := theTime.Unix()
  2771. //prescriptions, _ := service.GetHisPrescriptionForMedType(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  2772. info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  2773. doctor_info, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, info.DoctorId)
  2774. dept, _ := service.GetDepartMentDetail(info.Departments)
  2775. inputData := make(map[string]interface{})
  2776. inputData["rxTraceCode"] = flow.RxTraceCode
  2777. inputData["hiRxno"] = flow.HiRxno
  2778. inputData["mdtrtId"] = flow.MID
  2779. inputData["patnName"] = his.PsnName
  2780. inputData["psnCertType"] = his.PsnCertType
  2781. inputData["certno"] = his.Certno
  2782. inputData["fixmedinsName"] = miConfig.OrgName
  2783. inputData["fixmedinsCode"] = miConfig.Code
  2784. inputData["drCode"] = doctor_info.DoctorNumber
  2785. inputData["prscDrName"] = doctor_info.UserName
  2786. inputData["pharDeptName"] = dept.Name
  2787. inputData["pharDeptCode"] = dept.Number
  2788. inputData["pharProfttlCodg"] = dept.Name
  2789. inputData["pharProfttlName"] = ""
  2790. inputData["pharCode"] = "HY440309002107"
  2791. inputData["pharCertType"] = "01"
  2792. inputData["pharCertno"] = "430482199408260023"
  2793. inputData["pharName"] = "彭斯遥"
  2794. inputData["pharPracCertNo"] = ""
  2795. tempTime2 := time.Unix(info.Ctime, 0)
  2796. timeFormatTwo := tempTime2.Format("2006-01-02 15:04:05")
  2797. inputData["pharChkTime"] = timeFormatTwo
  2798. bytesData, _ := json.Marshal(inputData)
  2799. fmt.Println(string(bytesData))
  2800. encoded := base64.StdEncoding.EncodeToString(bytesData)
  2801. pdfContent, err := ioutil.ReadFile("signed_data.pdf")
  2802. if err != nil {
  2803. fmt.Println("Error reading PDF file:", err)
  2804. return
  2805. }
  2806. // 将 PDF 文件内容进行 Base64 编码
  2807. rx_encoded := base64.StdEncoding.EncodeToString(pdfContent)
  2808. fmt.Println(err)
  2809. result, request := service.GetCFYLJG002(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, encoded, rx_encoded, "")
  2810. //result, request := service.GetCFYLJG001(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG001,his.Insutype)
  2811. saveLog(result, request, "GetCFYLJG002", "GetCFYLJG002")
  2812. var res2 Result002
  2813. var respJSON2 map[string]interface{}
  2814. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  2815. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2816. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2817. return
  2818. }
  2819. userJSONBytes2, _ := json.Marshal(respJSON2)
  2820. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  2821. utils.ErrorLog("解析失败:%v", err)
  2822. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2823. return
  2824. }
  2825. if res2.Infcode == 0 {
  2826. flow.Ctime = time.Now().Unix()
  2827. flow.SignDigest = res2.Output.SignDigest
  2828. flow.RxFile = res2.Output.RxFile
  2829. flow.MID = his.Number
  2830. flow.Status = 1
  2831. flow.DCode = doctor_info.DoctorNumber
  2832. flow.OriginalRxFile = rx_encoded
  2833. flow.OriginalValue = encoded
  2834. flow.SignCertDn = res2.Output.SignCertDn
  2835. flow.SignCertSn = res2.Output.SignCertSn
  2836. flow.Mtime = time.Now().Unix()
  2837. service.Saveflow(flow)
  2838. c.ServeSuccessJSON(map[string]interface{}{
  2839. "msg": "预签名成功",
  2840. })
  2841. } else {
  2842. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2843. return
  2844. }
  2845. }
  2846. func (c *HisApiController) GetCFYLJG003() {
  2847. admin_user_id, _ := c.GetInt64("admin_user_id")
  2848. his_patient_id, _ := c.GetInt64("his_patient_id")
  2849. record_time := c.GetString("record_time")
  2850. admin_user_id = 3626
  2851. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  2852. //id, _ := c.GetInt64("id")
  2853. admin_user_id = 3626
  2854. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2855. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2856. flow, _ := service.Getflowtwo(his.Number)
  2857. //id = 3
  2858. patient_id, _ := c.GetInt64("patient_id")
  2859. //patient_id = 23834
  2860. //record_time = "2023-09-18"
  2861. timeLayout := "2006-01-02"
  2862. loc, _ := time.LoadLocation("Local")
  2863. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  2864. if err != nil {
  2865. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  2866. return
  2867. }
  2868. recordDateTime := theTime.Unix()
  2869. //prescriptions, _ := service.GetHisPrescriptionForMedType(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  2870. info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  2871. doctor_info, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, info.DoctorId)
  2872. dept, _ := service.GetDepartMentDetail(info.Departments)
  2873. //psn_info,_ := service.GetPsnByPatientId(his.PatientId)
  2874. var cFYLJG003 models.CFYLJG003
  2875. cFYLJG003.RxTraceCode = flow.RxTraceCode
  2876. cFYLJG003.HiRxno = flow.HiRxno
  2877. cFYLJG003.MdtrtID = flow.MID
  2878. cFYLJG003.PatnName = his.Name
  2879. cFYLJG003.Certno = his.Certno
  2880. cFYLJG003.FixmedinsName = miConfig.OrgName
  2881. cFYLJG003.FixmedinsCode = miConfig.Code
  2882. cFYLJG003.DrCode = doctor_info.DoctorNumber
  2883. cFYLJG003.PrscDrName = doctor_info.UserName
  2884. cFYLJG003.PharDeptName = dept.Name
  2885. cFYLJG003.PharDeptCode = dept.Number
  2886. cFYLJG003.PharCode = "HY440309002107"
  2887. cFYLJG003.PharCertType = "01"
  2888. cFYLJG003.PharCertno = "430482199408260023"
  2889. cFYLJG003.PharName = "彭斯遥"
  2890. cFYLJG003.PsnCertType = "01"
  2891. cFYLJG003.RxFile = flow.RxFile
  2892. cFYLJG003.SignDigest = flow.SignDigest
  2893. cFYLJG003.FixmedinsCode = miConfig.Code
  2894. cFYLJG003.PsnCertType = "01"
  2895. cFYLJG003.PharProfttlCodg = dept.Name
  2896. //inputData["pharProfttlCodg"] =dept.Name
  2897. tempTime2 := time.Unix(info.Ctime, 0)
  2898. timeFormatTwo := tempTime2.Format("2006-01-02 15:04:05")
  2899. cFYLJG003.PharChkTime = timeFormatTwo
  2900. result, request := service.GetCFYLJG003(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG003)
  2901. saveLog(result, request, "GetCFYLJG003", "GetCFYLJG003")
  2902. var res ResultCFYLJG003
  2903. var respJSON2 map[string]interface{}
  2904. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  2905. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2906. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2907. return
  2908. }
  2909. userJSONBytes2, _ := json.Marshal(respJSON2)
  2910. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2911. utils.ErrorLog("解析失败:%v", err)
  2912. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2913. return
  2914. }
  2915. if res.Infcode == -1 {
  2916. c.ServeSuccessJSON(map[string]interface{}{
  2917. "failed_code": -10,
  2918. "msg": res.ErrMsg,
  2919. })
  2920. return
  2921. } else {
  2922. c.ServeSuccessJSON(map[string]interface{}{
  2923. "info": res.Output,
  2924. })
  2925. }
  2926. }
  2927. func (c *HisApiController) GetCFYLJG004() {
  2928. admin_user_id, _ := c.GetInt64("admin_user_id")
  2929. his_patient_id, _ := c.GetInt64("his_patient_id")
  2930. record_time := c.GetString("record_time")
  2931. admin_user_id = 3626
  2932. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  2933. //id, _ := c.GetInt64("id")
  2934. admin_user_id = 3626
  2935. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2936. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2937. flow, _ := service.Getflowtwo(his.Number)
  2938. //id = 3
  2939. patient_id, _ := c.GetInt64("patient_id")
  2940. //patient_id = 23834
  2941. //record_time = "2023-09-18"
  2942. timeLayout := "2006-01-02"
  2943. loc, _ := time.LoadLocation("Local")
  2944. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  2945. if err != nil {
  2946. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  2947. return
  2948. }
  2949. recordDateTime := theTime.Unix()
  2950. info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  2951. doctor_info, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, info.DoctorId)
  2952. var cFYLJG004 models.CFYLJG004
  2953. cFYLJG004.HiRxno = flow.HiRxno
  2954. cFYLJG004.FixmedinsCode = miConfig.Code
  2955. cFYLJG004.UndoDrCertno = doctor_info.IdCard
  2956. cFYLJG004.UndoDrCertType = "01"
  2957. cFYLJG004.UndoRea = "撤销处方"
  2958. cFYLJG004.UndoTime = time.Now().Format("2006-01-02 15:04:05")
  2959. cFYLJG004.UndoDrName = doctor_info.UserName
  2960. cFYLJG004.UndoDrCode = doctor_info.DoctorNumber
  2961. result, request := service.GetCFYLJG004(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG004)
  2962. saveLog(result, request, "GetCFYLJG004", "GetCFYLJG004")
  2963. var res ResultCFYLJG004
  2964. var respJSON2 map[string]interface{}
  2965. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  2966. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2967. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2968. return
  2969. }
  2970. userJSONBytes2, _ := json.Marshal(respJSON2)
  2971. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2972. utils.ErrorLog("解析失败:%v", err)
  2973. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2974. return
  2975. }
  2976. if res.Infcode == -1 {
  2977. c.ServeSuccessJSON(map[string]interface{}{
  2978. "failed_code": -10,
  2979. "msg": res.ErrMsg,
  2980. })
  2981. return
  2982. } else {
  2983. flow.Status = 0
  2984. service.Saveflow(flow)
  2985. c.ServeSuccessJSON(map[string]interface{}{
  2986. "msg": "撤销成功",
  2987. })
  2988. return
  2989. }
  2990. }
  2991. func (c *HisApiController) GetCFYLJG005() {
  2992. admin_user_id, _ := c.GetInt64("admin_user_id")
  2993. his_patient_id, _ := c.GetInt64("his_patient_id")
  2994. //record_time := c.GetString("record_time")
  2995. admin_user_id = 3626
  2996. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  2997. //id, _ := c.GetInt64("id")
  2998. admin_user_id = 3626
  2999. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3000. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3001. flow, _ := service.Getflowtwo(his.Number)
  3002. //id = 3
  3003. var cFYLJG005 models.CFYLJG005
  3004. //patient_id, _ := c.GetInt64("patient_id")
  3005. cFYLJG005.HiRxno = flow.HiRxno
  3006. cFYLJG005.MdtrtID = flow.MID
  3007. cFYLJG005.EcToken = ""
  3008. cFYLJG005.PsnName = his.Name
  3009. cFYLJG005.PsnCertType = "01"
  3010. cFYLJG005.Certno = his.IdCardNo
  3011. result, request := service.GetCFYLJG005(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG005)
  3012. saveLog(result, request, "GetCFYLJG005", "GetCFYLJG005")
  3013. var res ResultCFYLJG005
  3014. var respJSON2 map[string]interface{}
  3015. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  3016. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3017. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3018. return
  3019. }
  3020. userJSONBytes2, _ := json.Marshal(respJSON2)
  3021. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  3022. utils.ErrorLog("解析失败:%v", err)
  3023. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3024. return
  3025. }
  3026. if res.Infcode == -1 {
  3027. c.ServeSuccessJSON(map[string]interface{}{
  3028. "failed_code": -10,
  3029. "msg": res.ErrMsg,
  3030. })
  3031. return
  3032. } else {
  3033. c.ServeSuccessJSON(map[string]interface{}{
  3034. "info": res.Output,
  3035. })
  3036. return
  3037. }
  3038. }
  3039. func (c *HisApiController) GetCFYLJG006() {
  3040. admin_user_id, _ := c.GetInt64("admin_user_id")
  3041. his_patient_id, _ := c.GetInt64("his_patient_id")
  3042. admin_user_id = 3626
  3043. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  3044. //id, _ := c.GetInt64("id")
  3045. admin_user_id = 3626
  3046. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3047. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3048. flow, _ := service.Getflowtwo(his.Number)
  3049. //id = 3
  3050. patient_id, _ := c.GetInt64("patient_id")
  3051. var cFYLJG006 models.CFYLJG006
  3052. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, patient_id)
  3053. cFYLJG006.HiRxno = flow.HiRxno
  3054. cFYLJG006.MdtrtID = flow.MID
  3055. cFYLJG006.PsnName = patient.Name
  3056. cFYLJG006.PsnCertType = "01"
  3057. cFYLJG006.Certno = patient.IdCardNo
  3058. result, request := service.GetCFYLJG006(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG006)
  3059. saveLog(result, request, "GetCFYLJG006", "GetCFYLJG006")
  3060. var res ResultCFYLJG006
  3061. var respJSON2 map[string]interface{}
  3062. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  3063. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3064. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3065. return
  3066. }
  3067. userJSONBytes2, _ := json.Marshal(respJSON2)
  3068. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  3069. utils.ErrorLog("解析失败:%v", err)
  3070. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3071. return
  3072. }
  3073. if res.Infcode == -1 {
  3074. c.ServeSuccessJSON(map[string]interface{}{
  3075. "failed_code": -10,
  3076. "msg": res.ErrMsg,
  3077. })
  3078. return
  3079. } else {
  3080. c.ServeSuccessJSON(map[string]interface{}{
  3081. "info": res.Output,
  3082. })
  3083. return
  3084. }
  3085. }
  3086. func (c *HisApiController) GetCFYLJG007() {
  3087. admin_user_id, _ := c.GetInt64("admin_user_id")
  3088. his_patient_id, _ := c.GetInt64("his_patient_id")
  3089. admin_user_id = 3626
  3090. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  3091. //id, _ := c.GetInt64("id")
  3092. admin_user_id = 3626
  3093. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3094. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3095. flow, _ := service.Getflowtwo(his.Number)
  3096. //id = 3
  3097. patient_id, _ := c.GetInt64("patient_id")
  3098. var cFYLJG007 models.CFYLJG007
  3099. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, patient_id)
  3100. //his, _ := service.GetHisPatient(c.GetAdminUserInfo().CurrentOrgId,patient_id)
  3101. cFYLJG007.HiRxno = flow.HiRxno
  3102. cFYLJG007.MdtrtID = flow.MID
  3103. cFYLJG007.PsnNo = his.PsnNo
  3104. cFYLJG007.PsnCertType = "01"
  3105. cFYLJG007.Certno = patient.IdCardNo
  3106. cFYLJG007.PsnName = patient.Name
  3107. result, request := service.GetCFYLJG007(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG007)
  3108. saveLog(result, request, "GetCFYLJG007", "GetCFYLJG007")
  3109. var res ResultCFYLJG007
  3110. var respJSON2 map[string]interface{}
  3111. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  3112. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3113. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3114. return
  3115. }
  3116. userJSONBytes2, _ := json.Marshal(respJSON2)
  3117. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  3118. utils.ErrorLog("解析失败:%v", err)
  3119. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3120. return
  3121. }
  3122. if res.Infcode == -1 {
  3123. c.ServeSuccessJSON(map[string]interface{}{
  3124. "failed_code": -10,
  3125. "msg": res.ErrMsg,
  3126. })
  3127. return
  3128. } else {
  3129. c.ServeSuccessJSON(map[string]interface{}{
  3130. "info": res,
  3131. })
  3132. return
  3133. }
  3134. }
  3135. func (c *HisApiController) GetCFYLJG008() {
  3136. admin_user_id, _ := c.GetInt64("admin_user_id")
  3137. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3138. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3139. var cFYLJG008 models.CFYLJG008
  3140. //id, _ := c.GetInt64("id")
  3141. patient_id, _ := c.GetInt64("patient_id")
  3142. //patient, _ := service.G/etPatientByID(c.GetAdminUserInfo().CurrentOrgId,patient_id)
  3143. //his, _ := service.GetHisPatient(c.GetAdminUserInfo().CurrentOrgId,patient_id)
  3144. //id = 3
  3145. //flow, _ := service.Getflow(id)
  3146. //his, _ := service.GetHisPatientByNumber(flow.MID)
  3147. //
  3148. //admin_user_id, _ := c.GetInt64("admin_user_id")
  3149. //patient_id, _ := c.GetInt64("patient_id")
  3150. //his_patient_id, _ := c.GetInt64("his_patient_id")
  3151. record_time := c.GetString("record_time")
  3152. admin_user_id = 3626
  3153. patient_id = 19424
  3154. //his_patient_id = 263947
  3155. record_time = "2023-08-29"
  3156. timeLayout := "2006-01-02"
  3157. loc, _ := time.LoadLocation("Local")
  3158. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  3159. if err != nil {
  3160. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  3161. return
  3162. }
  3163. recordDateTime := theTime.Unix()
  3164. prescriptions, _ := service.GetHisPrescriptionForMedType(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  3165. cFYLJG008.FixmedinsName = ""
  3166. cFYLJG008.Lat = ""
  3167. cFYLJG008.Lng = ""
  3168. cFYLJG008.OrderType = "1"
  3169. cFYLJG008.PoolareaNo = ""
  3170. cFYLJG008.Lng = ""
  3171. cFYLJG008.PageNum = 1
  3172. cFYLJG008.PageSize = 10
  3173. var MPI models.MedinsProdInvChgDDTO
  3174. MPI.MedListCodg = prescriptions[0].HisDoctorAdviceInfo[0].MedListCodg
  3175. MPI.Cnt = prescriptions[0].HisDoctorAdviceInfo[0].PrescribingNumber
  3176. cFYLJG008.MedList = append(cFYLJG008.MedList, MPI)
  3177. result, request := service.GetCFYLJG008(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG008)
  3178. saveLog(result, request, "GetCFYLJG008", "GetCFYLJG008")
  3179. var res ResultCFYLJG008
  3180. var respJSON2 map[string]interface{}
  3181. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  3182. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3183. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3184. return
  3185. }
  3186. userJSONBytes2, _ := json.Marshal(respJSON2)
  3187. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  3188. utils.ErrorLog("解析失败:%v", err)
  3189. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3190. return
  3191. }
  3192. if res.Infcode == -1 {
  3193. c.ServeSuccessJSON(map[string]interface{}{
  3194. "failed_code": -10,
  3195. "msg": res.ErrMsg,
  3196. })
  3197. return
  3198. } else {
  3199. c.ServeSuccessJSON(map[string]interface{}{
  3200. "info": res.Output,
  3201. })
  3202. return
  3203. }
  3204. }
  3205. func (c *HisApiController) GetBL4201A() {
  3206. order_id, _ := c.GetInt64("order_id")
  3207. admin_user_id, _ := c.GetInt64("admin_user_id")
  3208. order, _ := service.GetHisOrderByIDTwo(order_id)
  3209. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  3210. order_info, _ := service.GetHisOrderInfoByNumber(order.MdtrtId)
  3211. order_info_two, _ := service.GetHisOrderInfoByNumberTwo(order.MdtrtId)
  3212. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3213. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3214. department, _ := service.GetDepartMentDetail(his.Departments)
  3215. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  3216. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  3217. if order.ID == 0 {
  3218. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  3219. return
  3220. }
  3221. var struct4201A models.Struct4201A
  3222. var fsiOPFLDs []models.FsiOwnpayPatnFeeListDDTO
  3223. for _, items := range order_info {
  3224. memo := make(map[string]interface{})
  3225. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  3226. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  3227. fsiOPFLD.MedType = "14"
  3228. fsiOPFLD.BkkpSn = items.FeedetlSn
  3229. fsiOPFLD.FixmedinsCode = miConfig.Code
  3230. fsiOPFLD.FixmedinsName = miConfig.OrgName
  3231. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  3232. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  3233. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  3234. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  3235. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  3236. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  3237. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  3238. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  3239. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  3240. fsiOPFLD.BilgDeptName = department.Name
  3241. fsiOPFLD.BilgDeptCodg = department.Number
  3242. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  3243. fsiOPFLD.BilgDrName = doctor.UserName
  3244. fsiOPFLD.MedChrgitmType = "09"
  3245. memo["hosp_appr_flag"] = "1"
  3246. memo["invoice_no"] = order.MdtrtId
  3247. memo["memo"] = "自费"
  3248. bytesData, _ := json.Marshal(memo)
  3249. fsiOPFLD.Memo = string(bytesData)
  3250. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  3251. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  3252. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  3253. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  3254. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  3255. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  3256. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  3257. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  3258. fsiOPFLD.BilgDeptName = department.Name
  3259. fsiOPFLD.BilgDeptCodg = department.Number
  3260. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  3261. fsiOPFLD.BilgDrName = doctor.UserName
  3262. switch items.HisPrescriptionProject.HisProject.CostClassify {
  3263. case 0:
  3264. break
  3265. case 1:
  3266. fsiOPFLD.MedChrgitmType = "14"
  3267. break
  3268. case 2:
  3269. fsiOPFLD.MedChrgitmType = "05"
  3270. break
  3271. case 3:
  3272. fsiOPFLD.MedChrgitmType = "03"
  3273. break
  3274. case 4:
  3275. fsiOPFLD.MedChrgitmType = "03"
  3276. break
  3277. case 5:
  3278. fsiOPFLD.MedChrgitmType = "08"
  3279. break
  3280. case 6:
  3281. fsiOPFLD.MedChrgitmType = "14"
  3282. break
  3283. case 7:
  3284. fsiOPFLD.MedChrgitmType = "14"
  3285. break
  3286. case 8:
  3287. fsiOPFLD.MedChrgitmType = "03"
  3288. break
  3289. case 9:
  3290. fsiOPFLD.MedChrgitmType = "14"
  3291. break
  3292. case 10:
  3293. fsiOPFLD.MedChrgitmType = "14"
  3294. break
  3295. case 11:
  3296. fsiOPFLD.MedChrgitmType = "06"
  3297. break
  3298. case 12:
  3299. fsiOPFLD.MedChrgitmType = "12"
  3300. break
  3301. case 13:
  3302. fsiOPFLD.MedChrgitmType = "01"
  3303. break
  3304. case 14:
  3305. fsiOPFLD.MedChrgitmType = "04"
  3306. break
  3307. case 15:
  3308. fsiOPFLD.MedChrgitmType = "14"
  3309. break
  3310. }
  3311. memo["hosp_appr_flag"] = "1"
  3312. memo["invoice_no"] = order.MdtrtId
  3313. memo["memo"] = "自费"
  3314. bytesData, _ := json.Marshal(memo)
  3315. fsiOPFLD.Memo = string(bytesData)
  3316. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  3317. } else if items.HisPrescriptionProject.Type == 3 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 {
  3318. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  3319. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  3320. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  3321. fsiOPFLD.BilgDeptName = department.Name
  3322. fsiOPFLD.BilgDeptCodg = department.Number
  3323. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  3324. fsiOPFLD.BilgDrName = doctor.UserName
  3325. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  3326. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  3327. fsiOPFLD.MedChrgitmType = "08"
  3328. memo["hosp_appr_flag"] = "1"
  3329. memo["invoice_no"] = order.MdtrtId
  3330. memo["memo"] = "自费"
  3331. bytesData, _ := json.Marshal(memo)
  3332. fsiOPFLD.Memo = string(bytesData)
  3333. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  3334. }
  3335. }
  3336. }
  3337. for _, items := range order_info_two {
  3338. memo := make(map[string]interface{})
  3339. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  3340. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  3341. fsiOPFLD.MedType = "14"
  3342. fsiOPFLD.BkkpSn = items.FeedetlSn
  3343. fsiOPFLD.FixmedinsCode = miConfig.Code
  3344. fsiOPFLD.FixmedinsName = miConfig.OrgName
  3345. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  3346. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  3347. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  3348. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  3349. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  3350. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  3351. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  3352. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  3353. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  3354. fsiOPFLD.BilgDeptName = department.Name
  3355. fsiOPFLD.BilgDeptCodg = department.Number
  3356. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  3357. fsiOPFLD.BilgDrName = doctor.UserName
  3358. fsiOPFLD.MedChrgitmType = "09"
  3359. memo["hosp_appr_flag"] = "1"
  3360. memo["invoice_no"] = order.MdtrtId
  3361. memo["memo"] = "自费"
  3362. bytesData, _ := json.Marshal(memo)
  3363. fsiOPFLD.Memo = string(bytesData)
  3364. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  3365. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  3366. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  3367. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  3368. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  3369. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  3370. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  3371. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  3372. fsiOPFLD.BilgDeptName = department.Name
  3373. fsiOPFLD.BilgDeptCodg = department.Number
  3374. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  3375. fsiOPFLD.BilgDrName = doctor.UserName
  3376. switch items.HisPrescriptionProject.HisProject.CostClassify {
  3377. case 0:
  3378. break
  3379. case 1:
  3380. fsiOPFLD.MedChrgitmType = "14"
  3381. break
  3382. case 2:
  3383. fsiOPFLD.MedChrgitmType = "05"
  3384. break
  3385. case 3:
  3386. fsiOPFLD.MedChrgitmType = "03"
  3387. break
  3388. case 4:
  3389. fsiOPFLD.MedChrgitmType = "03"
  3390. break
  3391. case 5:
  3392. fsiOPFLD.MedChrgitmType = "08"
  3393. break
  3394. case 6:
  3395. fsiOPFLD.MedChrgitmType = "14"
  3396. break
  3397. case 7:
  3398. fsiOPFLD.MedChrgitmType = "14"
  3399. break
  3400. case 8:
  3401. fsiOPFLD.MedChrgitmType = "03"
  3402. break
  3403. case 9:
  3404. fsiOPFLD.MedChrgitmType = "14"
  3405. break
  3406. case 10:
  3407. fsiOPFLD.MedChrgitmType = "14"
  3408. break
  3409. case 11:
  3410. fsiOPFLD.MedChrgitmType = "06"
  3411. break
  3412. case 12:
  3413. fsiOPFLD.MedChrgitmType = "12"
  3414. break
  3415. case 13:
  3416. fsiOPFLD.MedChrgitmType = "01"
  3417. break
  3418. case 14:
  3419. fsiOPFLD.MedChrgitmType = "04"
  3420. break
  3421. case 15:
  3422. fsiOPFLD.MedChrgitmType = "14"
  3423. break
  3424. }
  3425. memo["hosp_appr_flag"] = "1"
  3426. memo["invoice_no"] = order.MdtrtId
  3427. memo["memo"] = "自费"
  3428. bytesData, _ := json.Marshal(memo)
  3429. fsiOPFLD.Memo = string(bytesData)
  3430. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  3431. } else if items.HisPrescriptionProject.Type == 3 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 {
  3432. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  3433. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  3434. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  3435. fsiOPFLD.BilgDeptName = department.Name
  3436. fsiOPFLD.BilgDeptCodg = department.Number
  3437. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  3438. fsiOPFLD.BilgDrName = doctor.UserName
  3439. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  3440. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  3441. fsiOPFLD.MedChrgitmType = "08"
  3442. memo["hosp_appr_flag"] = "1"
  3443. memo["invoice_no"] = order.MdtrtId
  3444. memo["memo"] = "自费"
  3445. bytesData, _ := json.Marshal(memo)
  3446. fsiOPFLD.Memo = string(bytesData)
  3447. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  3448. }
  3449. }
  3450. }
  3451. fmt.Println(fsiOPFLDs)
  3452. struct4201A.Fopfd = fsiOPFLDs
  3453. fmt.Println(struct4201A.Fopfd)
  3454. result, requestLog := service.Gdyb4201A(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4201A)
  3455. saveLog(result, requestLog, "4201A", "自费费用明细上传")
  3456. var res2 ResultSix
  3457. var respJSON2 map[string]interface{}
  3458. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  3459. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3460. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3461. return
  3462. }
  3463. userJSONBytes2, _ := json.Marshal(respJSON2)
  3464. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  3465. utils.ErrorLog("解析失败:%v", err)
  3466. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3467. return
  3468. }
  3469. if res2.Infcode != 0 {
  3470. c.ServeSuccessJSON(map[string]interface{}{
  3471. "failed_code": -10,
  3472. "msg": res2.ErrMsg,
  3473. })
  3474. return
  3475. } else {
  3476. order.IsUploadOrderInfo = 1
  3477. service.UpdateOrder(order)
  3478. c.ServeSuccessJSON(map[string]interface{}{
  3479. "msg": "上传成功",
  3480. })
  3481. }
  3482. }
  3483. func (c *HisApiController) Get2505() {
  3484. admin_user_id, _ := c.GetInt64("admin_user_id")
  3485. miConfig, _ := service.FindMedicalInsuranceInfo(10375)
  3486. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3487. 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)
  3488. }
  3489. func (c *HisApiController) Get4201A() {
  3490. order_id, _ := c.GetInt64("order_id")
  3491. admin_user_id, _ := c.GetInt64("admin_user_id")
  3492. order, _ := service.GetHisOrderByIDTwo(order_id)
  3493. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  3494. order_info, _ := service.GetHisOrderInfoByNumber(order.MdtrtId)
  3495. order_info_two, _ := service.GetHisOrderInfoByNumberTwo(order.MdtrtId)
  3496. //order_info = append(order_info, order_info_two...)
  3497. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3498. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3499. department, _ := service.GetDepartMentDetail(his.Departments)
  3500. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  3501. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  3502. if order.ID == 0 {
  3503. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  3504. return
  3505. }
  3506. var struct4201A models.Struct4201A
  3507. var fsiOPFLDs []models.FsiOwnpayPatnFeeListDDTO
  3508. for _, items := range order_info {
  3509. memo := make(map[string]interface{})
  3510. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  3511. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  3512. fsiOPFLD.MedType = "14"
  3513. fsiOPFLD.BkkpSn = items.FeedetlSn
  3514. fsiOPFLD.FixmedinsCode = miConfig.Code
  3515. fsiOPFLD.FixmedinsName = miConfig.OrgName
  3516. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  3517. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  3518. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  3519. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  3520. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  3521. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  3522. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  3523. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  3524. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  3525. fsiOPFLD.BilgDeptName = department.Name
  3526. fsiOPFLD.BilgDeptCodg = department.Number
  3527. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  3528. fsiOPFLD.BilgDrName = doctor.UserName
  3529. fsiOPFLD.MedChrgitmType = "09"
  3530. memo["hosp_appr_flag"] = "1"
  3531. memo["invoice_no"] = order.MdtrtId
  3532. memo["memo"] = "自费"
  3533. bytesData, _ := json.Marshal(memo)
  3534. fsiOPFLD.Memo = string(bytesData)
  3535. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  3536. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  3537. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  3538. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  3539. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  3540. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  3541. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  3542. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  3543. fsiOPFLD.BilgDeptName = department.Name
  3544. fsiOPFLD.BilgDeptCodg = department.Number
  3545. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  3546. fsiOPFLD.BilgDrName = doctor.UserName
  3547. switch items.HisPrescriptionProject.HisProject.CostClassify {
  3548. case 0:
  3549. break
  3550. case 1:
  3551. fsiOPFLD.MedChrgitmType = "14"
  3552. break
  3553. case 2:
  3554. fsiOPFLD.MedChrgitmType = "05"
  3555. break
  3556. case 3:
  3557. fsiOPFLD.MedChrgitmType = "03"
  3558. break
  3559. case 4:
  3560. fsiOPFLD.MedChrgitmType = "03"
  3561. break
  3562. case 5:
  3563. fsiOPFLD.MedChrgitmType = "08"
  3564. break
  3565. case 6:
  3566. fsiOPFLD.MedChrgitmType = "14"
  3567. break
  3568. case 7:
  3569. fsiOPFLD.MedChrgitmType = "14"
  3570. break
  3571. case 8:
  3572. fsiOPFLD.MedChrgitmType = "03"
  3573. break
  3574. case 9:
  3575. fsiOPFLD.MedChrgitmType = "14"
  3576. break
  3577. case 10:
  3578. fsiOPFLD.MedChrgitmType = "14"
  3579. break
  3580. case 11:
  3581. fsiOPFLD.MedChrgitmType = "06"
  3582. break
  3583. case 12:
  3584. fsiOPFLD.MedChrgitmType = "12"
  3585. break
  3586. case 13:
  3587. fsiOPFLD.MedChrgitmType = "01"
  3588. break
  3589. case 14:
  3590. fsiOPFLD.MedChrgitmType = "04"
  3591. break
  3592. case 15:
  3593. fsiOPFLD.MedChrgitmType = "14"
  3594. break
  3595. }
  3596. memo["hosp_appr_flag"] = "1"
  3597. memo["invoice_no"] = order.MdtrtId
  3598. memo["memo"] = "自费"
  3599. bytesData, _ := json.Marshal(memo)
  3600. fsiOPFLD.Memo = string(bytesData)
  3601. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  3602. } else if items.HisPrescriptionProject.Type == 3 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 {
  3603. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  3604. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  3605. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  3606. fsiOPFLD.BilgDeptName = department.Name
  3607. fsiOPFLD.BilgDeptCodg = department.Number
  3608. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  3609. fsiOPFLD.BilgDrName = doctor.UserName
  3610. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  3611. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  3612. fsiOPFLD.MedChrgitmType = "08"
  3613. memo["hosp_appr_flag"] = "1"
  3614. memo["invoice_no"] = order.MdtrtId
  3615. memo["memo"] = "自费"
  3616. bytesData, _ := json.Marshal(memo)
  3617. fsiOPFLD.Memo = string(bytesData)
  3618. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  3619. }
  3620. }
  3621. }
  3622. for _, items := range order_info_two {
  3623. memo := make(map[string]interface{})
  3624. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  3625. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  3626. fsiOPFLD.MedType = "14"
  3627. fsiOPFLD.BkkpSn = items.FeedetlSn
  3628. fsiOPFLD.FixmedinsCode = miConfig.Code
  3629. fsiOPFLD.FixmedinsName = miConfig.OrgName
  3630. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  3631. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  3632. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  3633. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  3634. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  3635. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  3636. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  3637. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  3638. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  3639. fsiOPFLD.BilgDeptName = department.Name
  3640. fsiOPFLD.BilgDeptCodg = department.Number
  3641. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  3642. fsiOPFLD.BilgDrName = doctor.UserName
  3643. fsiOPFLD.MedChrgitmType = "09"
  3644. memo["hosp_appr_flag"] = "1"
  3645. memo["invoice_no"] = order.MdtrtId
  3646. memo["memo"] = "自费"
  3647. bytesData, _ := json.Marshal(memo)
  3648. fsiOPFLD.Memo = string(bytesData)
  3649. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  3650. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  3651. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  3652. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  3653. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  3654. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  3655. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  3656. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  3657. fsiOPFLD.BilgDeptName = department.Name
  3658. fsiOPFLD.BilgDeptCodg = department.Number
  3659. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  3660. fsiOPFLD.BilgDrName = doctor.UserName
  3661. switch items.HisPrescriptionProject.HisProject.CostClassify {
  3662. case 0:
  3663. break
  3664. case 1:
  3665. fsiOPFLD.MedChrgitmType = "14"
  3666. break
  3667. case 2:
  3668. fsiOPFLD.MedChrgitmType = "05"
  3669. break
  3670. case 3:
  3671. fsiOPFLD.MedChrgitmType = "03"
  3672. break
  3673. case 4:
  3674. fsiOPFLD.MedChrgitmType = "03"
  3675. break
  3676. case 5:
  3677. fsiOPFLD.MedChrgitmType = "08"
  3678. break
  3679. case 6:
  3680. fsiOPFLD.MedChrgitmType = "14"
  3681. break
  3682. case 7:
  3683. fsiOPFLD.MedChrgitmType = "14"
  3684. break
  3685. case 8:
  3686. fsiOPFLD.MedChrgitmType = "03"
  3687. break
  3688. case 9:
  3689. fsiOPFLD.MedChrgitmType = "14"
  3690. break
  3691. case 10:
  3692. fsiOPFLD.MedChrgitmType = "14"
  3693. break
  3694. case 11:
  3695. fsiOPFLD.MedChrgitmType = "06"
  3696. break
  3697. case 12:
  3698. fsiOPFLD.MedChrgitmType = "12"
  3699. break
  3700. case 13:
  3701. fsiOPFLD.MedChrgitmType = "01"
  3702. break
  3703. case 14:
  3704. fsiOPFLD.MedChrgitmType = "04"
  3705. break
  3706. case 15:
  3707. fsiOPFLD.MedChrgitmType = "14"
  3708. break
  3709. }
  3710. memo["hosp_appr_flag"] = "1"
  3711. memo["invoice_no"] = order.MdtrtId
  3712. memo["memo"] = "自费"
  3713. bytesData, _ := json.Marshal(memo)
  3714. fsiOPFLD.Memo = string(bytesData)
  3715. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  3716. } else if items.HisPrescriptionProject.Type == 3 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 {
  3717. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  3718. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  3719. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  3720. fsiOPFLD.BilgDeptName = department.Name
  3721. fsiOPFLD.BilgDeptCodg = department.Number
  3722. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  3723. fsiOPFLD.BilgDrName = doctor.UserName
  3724. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  3725. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  3726. fsiOPFLD.MedChrgitmType = "08"
  3727. memo["hosp_appr_flag"] = "1"
  3728. memo["invoice_no"] = order.MdtrtId
  3729. memo["memo"] = "自费"
  3730. bytesData, _ := json.Marshal(memo)
  3731. fsiOPFLD.Memo = string(bytesData)
  3732. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  3733. }
  3734. }
  3735. }
  3736. fmt.Println(fsiOPFLDs)
  3737. struct4201A.Fopfd = fsiOPFLDs
  3738. fmt.Println(struct4201A.Fopfd)
  3739. result, requestLog := service.Gdyb4201A(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4201A)
  3740. saveLog(result, requestLog, "4201A", "自费费用明细上传")
  3741. var res2 ResultSix
  3742. var respJSON2 map[string]interface{}
  3743. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  3744. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3745. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3746. return
  3747. }
  3748. userJSONBytes2, _ := json.Marshal(respJSON2)
  3749. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  3750. utils.ErrorLog("解析失败:%v", err)
  3751. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3752. return
  3753. }
  3754. if res2.Infcode != 0 {
  3755. c.ServeSuccessJSON(map[string]interface{}{
  3756. "failed_code": -10,
  3757. "msg": res2.ErrMsg,
  3758. })
  3759. return
  3760. } else {
  3761. order.IsUploadOrderInfo = 1
  3762. service.UpdateOrder(order)
  3763. c.ServeSuccessJSON(map[string]interface{}{
  3764. "msg": "上传成功",
  3765. })
  3766. }
  3767. }
  3768. func (c *HisApiController) Get4202() {
  3769. order_id, _ := c.GetInt64("order_id")
  3770. admin_user_id, _ := c.GetInt64("admin_user_id")
  3771. order, _ := service.GetHisOrderByIDTwo(order_id)
  3772. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  3773. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3774. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3775. if order.ID == 0 {
  3776. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  3777. return
  3778. }
  3779. var struct4202 models.Struct4202
  3780. struct4202.OwnPayPatnMdtrtD.FixmedinsMdtrtID = his.Number
  3781. struct4202.OwnPayPatnMdtrtD.FixmedinsCode = miConfig.Code
  3782. struct4202.OwnPayPatnMdtrtD.FixmedinsName = miConfig.OrgName
  3783. struct4202.OwnPayPatnMdtrtD.PsnCertType = "01"
  3784. struct4202.OwnPayPatnMdtrtD.Certno = his.IdCardNo
  3785. struct4202.OwnPayPatnMdtrtD.PsnName = his.Name
  3786. struct4202.OwnPayPatnMdtrtD.Begntime = his.InHosptialTime
  3787. struct4202.OwnPayPatnMdtrtD.MedType = "14"
  3788. struct4202.OwnPayPatnMdtrtD.ValiFlag = "1"
  3789. struct4202.OwnPayPatnMdtrtD.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  3790. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  3791. var config []*models.HisXtDiagnoseConfig
  3792. for _, item := range diagnosis_ids {
  3793. id, _ := strconv.ParseInt(item, 10, 64)
  3794. diagnosisConfig, _ := service.FindDiagnoseById(id)
  3795. config = append(config, &diagnosisConfig)
  3796. }
  3797. var tempDiaginfos []models.OwnPayPatnDiagListD
  3798. for index, item := range config {
  3799. if index == 0 {
  3800. var tempDiaginfo models.OwnPayPatnDiagListD
  3801. tempDiaginfo.InoutDiagType = "1"
  3802. tempDiaginfo.DiagCode = item.CountryCode
  3803. tempDiaginfo.DiagName = item.CountryContentName
  3804. tempDiaginfo.DiagType = "1"
  3805. tempDiaginfo.DiagSrtNo = "1"
  3806. tempDiaginfo.MaindiagFlag = "1"
  3807. tempDiaginfo.ValiFlag = "1"
  3808. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  3809. } else {
  3810. var tempDiaginfo models.OwnPayPatnDiagListD
  3811. tempDiaginfo.DiagCode = item.CountryCode
  3812. tempDiaginfo.DiagName = item.CountryContentName
  3813. tempDiaginfo.DiagType = "2"
  3814. tempDiaginfo.DiagSrtNo = strconv.FormatInt(int64(index+1), 10)
  3815. tempDiaginfo.MaindiagFlag = "0"
  3816. tempDiaginfo.ValiFlag = "1"
  3817. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  3818. }
  3819. }
  3820. struct4202.ODiagListD = tempDiaginfos
  3821. result, requestLog := service.Gdyb4202(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4202)
  3822. saveLog(result, requestLog, "4202", "自费就诊和诊断信息上传")
  3823. var res2 ResultSix
  3824. var respJSON2 map[string]interface{}
  3825. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  3826. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3827. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3828. return
  3829. }
  3830. userJSONBytes2, _ := json.Marshal(respJSON2)
  3831. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  3832. utils.ErrorLog("解析失败:%v", err)
  3833. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3834. return
  3835. }
  3836. if res2.Infcode != 0 {
  3837. c.ServeSuccessJSON(map[string]interface{}{
  3838. "failed_code": -10,
  3839. "msg": res2.ErrMsg,
  3840. })
  3841. return
  3842. } else {
  3843. order.IsUploadDiagnose = 1
  3844. service.UpdateOrder(order)
  3845. c.ServeSuccessJSON(map[string]interface{}{
  3846. "msg": "上传成功",
  3847. })
  3848. }
  3849. }
  3850. func (c *HisApiController) Get4203() {
  3851. admin_user_id, _ := c.GetInt64("admin_user_id")
  3852. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3853. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3854. order_id, _ := c.GetInt64("order_id")
  3855. order, _ := service.GetHisOrderByIDTwo1111(order_id)
  3856. number := ""
  3857. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  3858. hospital, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  3859. if his.ID == 0 {
  3860. number = hospital.Number
  3861. } else {
  3862. number = his.Number
  3863. }
  3864. result, requestLog := service.Gdyb4203(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, number)
  3865. saveLog(result, requestLog, "4203", "自费就诊与结算明细上传完成")
  3866. var res2 ResultSix
  3867. var respJSON2 map[string]interface{}
  3868. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  3869. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3870. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3871. return
  3872. }
  3873. userJSONBytes2, _ := json.Marshal(respJSON2)
  3874. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  3875. utils.ErrorLog("解析失败:%v", err)
  3876. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3877. return
  3878. }
  3879. if res2.Infcode != 0 {
  3880. c.ServeSuccessJSON(map[string]interface{}{
  3881. "failed_code": -10,
  3882. "msg": res2.ErrMsg,
  3883. })
  3884. return
  3885. } else {
  3886. order.IsUploadSuccess = 1
  3887. service.UpdateOrderTwo(order)
  3888. c.ServeSuccessJSON(map[string]interface{}{
  3889. "msg": "上传成功",
  3890. })
  3891. }
  3892. }
  3893. func (c *HisApiController) Get4205() {
  3894. order_id, _ := c.GetInt64("order_id")
  3895. admin_user_id, _ := c.GetInt64("admin_user_id")
  3896. fapiao_code := c.GetString("fapiao_code")
  3897. order, _ := service.GetHisOrderByIDTwo1111(order_id)
  3898. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  3899. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3900. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3901. order_info, _ := service.GetHisOrderInfoByNumber(order.Number)
  3902. order_info_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  3903. //order_info = append(order_info, order_info_two...)
  3904. department, _ := service.GetDepartMentDetail(his.Departments)
  3905. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  3906. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  3907. if order.ID == 0 {
  3908. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  3909. return
  3910. }
  3911. var struct4201A models.Struct4201A
  3912. var fsiOPFLDs []models.FsiOwnpayPatnFeeListDDTO
  3913. for _, items := range order_info {
  3914. memo := make(map[string]interface{})
  3915. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  3916. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  3917. fsiOPFLD.MedType = pre.MedType
  3918. fsiOPFLD.FixmedinsCode = miConfig.Code
  3919. fsiOPFLD.FixmedinsName = miConfig.OrgName
  3920. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  3921. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  3922. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  3923. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  3924. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  3925. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  3926. fsiOPFLD.BkkpSn = items.HisDoctorAdviceInfo.FeedetlSn
  3927. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  3928. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  3929. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  3930. fsiOPFLD.BilgDeptName = department.Name
  3931. fsiOPFLD.BilgDeptCodg = department.Number
  3932. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  3933. fsiOPFLD.BilgDrName = doctor.UserName
  3934. fsiOPFLD.MedChrgitmType = "09"
  3935. memo["hosp_appr_flag"] = "1"
  3936. memo["invoice_no"] = fapiao_code
  3937. memo["memo"] = "自费"
  3938. bytesData, _ := json.Marshal(memo)
  3939. fsiOPFLD.Memo = string(bytesData)
  3940. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  3941. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  3942. fsiOPFLD.BkkpSn = items.HisPrescriptionProject.FeedetlSn
  3943. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  3944. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  3945. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  3946. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  3947. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  3948. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  3949. fsiOPFLD.BilgDeptName = department.Name
  3950. fsiOPFLD.BilgDeptCodg = department.Number
  3951. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  3952. fsiOPFLD.BilgDrName = doctor.UserName
  3953. switch items.HisPrescriptionProject.HisProject.CostClassify {
  3954. case 0:
  3955. break
  3956. case 1:
  3957. fsiOPFLD.MedChrgitmType = "14"
  3958. break
  3959. case 2:
  3960. fsiOPFLD.MedChrgitmType = "05"
  3961. break
  3962. case 3:
  3963. fsiOPFLD.MedChrgitmType = "03"
  3964. break
  3965. case 4:
  3966. fsiOPFLD.MedChrgitmType = "03"
  3967. break
  3968. case 5:
  3969. fsiOPFLD.MedChrgitmType = "08"
  3970. break
  3971. case 6:
  3972. fsiOPFLD.MedChrgitmType = "14"
  3973. break
  3974. case 7:
  3975. fsiOPFLD.MedChrgitmType = "14"
  3976. break
  3977. case 8:
  3978. fsiOPFLD.MedChrgitmType = "03"
  3979. break
  3980. case 9:
  3981. fsiOPFLD.MedChrgitmType = "14"
  3982. break
  3983. case 10:
  3984. fsiOPFLD.MedChrgitmType = "14"
  3985. break
  3986. case 11:
  3987. fsiOPFLD.MedChrgitmType = "06"
  3988. break
  3989. case 12:
  3990. fsiOPFLD.MedChrgitmType = "12"
  3991. break
  3992. case 13:
  3993. fsiOPFLD.MedChrgitmType = "01"
  3994. break
  3995. case 14:
  3996. fsiOPFLD.MedChrgitmType = "04"
  3997. break
  3998. case 15:
  3999. fsiOPFLD.MedChrgitmType = "14"
  4000. break
  4001. }
  4002. memo["hosp_appr_flag"] = "1"
  4003. memo["invoice_no"] = fapiao_code
  4004. memo["memo"] = "自费"
  4005. bytesData, _ := json.Marshal(memo)
  4006. fsiOPFLD.Memo = string(bytesData)
  4007. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  4008. } else if items.HisPrescriptionProject.Type == 3 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 {
  4009. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  4010. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  4011. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  4012. fsiOPFLD.BilgDeptName = department.Name
  4013. fsiOPFLD.BilgDeptCodg = department.Number
  4014. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  4015. fsiOPFLD.BilgDrName = doctor.UserName
  4016. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  4017. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  4018. fsiOPFLD.MedChrgitmType = "08"
  4019. memo["hosp_appr_flag"] = "1"
  4020. memo["invoice_no"] = fapiao_code
  4021. memo["memo"] = "自费"
  4022. bytesData, _ := json.Marshal(memo)
  4023. fsiOPFLD.Memo = string(bytesData)
  4024. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  4025. }
  4026. }
  4027. }
  4028. for _, items := range order_info_two {
  4029. memo := make(map[string]interface{})
  4030. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  4031. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  4032. fsiOPFLD.MedType = pre.MedType
  4033. fsiOPFLD.BkkpSn = items.FeedetlSn
  4034. fsiOPFLD.FixmedinsCode = miConfig.Code
  4035. fsiOPFLD.FixmedinsName = miConfig.OrgName
  4036. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  4037. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  4038. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  4039. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  4040. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  4041. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  4042. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  4043. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  4044. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  4045. fsiOPFLD.BilgDeptName = department.Name
  4046. fsiOPFLD.BilgDeptCodg = department.Number
  4047. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  4048. fsiOPFLD.BilgDrName = doctor.UserName
  4049. fsiOPFLD.MedChrgitmType = "09"
  4050. memo["hosp_appr_flag"] = "1"
  4051. memo["invoice_no"] = fapiao_code
  4052. memo["memo"] = "自费"
  4053. bytesData, _ := json.Marshal(memo)
  4054. fsiOPFLD.Memo = string(bytesData)
  4055. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  4056. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  4057. fsiOPFLD.BkkpSn = items.HisPrescriptionProject.FeedetlSn
  4058. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  4059. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  4060. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  4061. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  4062. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  4063. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  4064. fsiOPFLD.BilgDeptName = department.Name
  4065. fsiOPFLD.BilgDeptCodg = department.Number
  4066. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  4067. fsiOPFLD.BilgDrName = doctor.UserName
  4068. switch items.HisPrescriptionProject.HisProject.CostClassify {
  4069. case 0:
  4070. break
  4071. case 1:
  4072. fsiOPFLD.MedChrgitmType = "14"
  4073. break
  4074. case 2:
  4075. fsiOPFLD.MedChrgitmType = "05"
  4076. break
  4077. case 3:
  4078. fsiOPFLD.MedChrgitmType = "03"
  4079. break
  4080. case 4:
  4081. fsiOPFLD.MedChrgitmType = "03"
  4082. break
  4083. case 5:
  4084. fsiOPFLD.MedChrgitmType = "08"
  4085. break
  4086. case 6:
  4087. fsiOPFLD.MedChrgitmType = "14"
  4088. break
  4089. case 7:
  4090. fsiOPFLD.MedChrgitmType = "14"
  4091. break
  4092. case 8:
  4093. fsiOPFLD.MedChrgitmType = "03"
  4094. break
  4095. case 9:
  4096. fsiOPFLD.MedChrgitmType = "14"
  4097. break
  4098. case 10:
  4099. fsiOPFLD.MedChrgitmType = "14"
  4100. break
  4101. case 11:
  4102. fsiOPFLD.MedChrgitmType = "06"
  4103. break
  4104. case 12:
  4105. fsiOPFLD.MedChrgitmType = "12"
  4106. break
  4107. case 13:
  4108. fsiOPFLD.MedChrgitmType = "01"
  4109. break
  4110. case 14:
  4111. fsiOPFLD.MedChrgitmType = "04"
  4112. break
  4113. case 15:
  4114. fsiOPFLD.MedChrgitmType = "14"
  4115. break
  4116. }
  4117. memo["hosp_appr_flag"] = "1"
  4118. memo["invoice_no"] = fapiao_code
  4119. memo["memo"] = "自费"
  4120. bytesData, _ := json.Marshal(memo)
  4121. fsiOPFLD.Memo = string(bytesData)
  4122. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  4123. } else if items.HisPrescriptionProject.Type == 3 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 {
  4124. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  4125. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  4126. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  4127. fsiOPFLD.BilgDeptName = department.Name
  4128. fsiOPFLD.BilgDeptCodg = department.Number
  4129. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  4130. fsiOPFLD.BilgDrName = doctor.UserName
  4131. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  4132. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  4133. fsiOPFLD.MedChrgitmType = "08"
  4134. memo["hosp_appr_flag"] = "1"
  4135. memo["invoice_no"] = fapiao_code
  4136. memo["memo"] = "自费"
  4137. bytesData, _ := json.Marshal(memo)
  4138. fsiOPFLD.Memo = string(bytesData)
  4139. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  4140. }
  4141. }
  4142. }
  4143. fmt.Println(fsiOPFLDs)
  4144. struct4201A.Fopfd = fsiOPFLDs
  4145. fmt.Println(struct4201A.Fopfd)
  4146. var struct4202 models.Struct4202
  4147. timeLayout := "2006-01-02 15:04:05"
  4148. dataTimeStr := time.Unix(his.Ctime, 0).Format(timeLayout)
  4149. struct4202.OwnPayPatnMdtrtD.FixmedinsMdtrtID = his.Number
  4150. struct4202.OwnPayPatnMdtrtD.FixmedinsCode = miConfig.Code
  4151. struct4202.OwnPayPatnMdtrtD.FixmedinsName = miConfig.OrgName
  4152. struct4202.OwnPayPatnMdtrtD.PsnCertType = "01"
  4153. struct4202.OwnPayPatnMdtrtD.Certno = his.IdCardNo
  4154. struct4202.OwnPayPatnMdtrtD.PsnName = his.Name
  4155. struct4202.OwnPayPatnMdtrtD.Begntime = dataTimeStr
  4156. struct4202.OwnPayPatnMdtrtD.MedType = pre.MedType
  4157. struct4202.OwnPayPatnMdtrtD.ValiFlag = "1"
  4158. struct4202.OwnPayPatnMdtrtD.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  4159. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  4160. var config []*models.HisXtDiagnoseConfig
  4161. for _, item := range diagnosis_ids {
  4162. id, _ := strconv.ParseInt(item, 10, 64)
  4163. diagnosisConfig, _ := service.FindDiagnoseById(id)
  4164. config = append(config, &diagnosisConfig)
  4165. }
  4166. var tempDiaginfos []models.OwnPayPatnDiagListD
  4167. for index, item := range config {
  4168. if index == 0 {
  4169. var tempDiaginfo models.OwnPayPatnDiagListD
  4170. tempDiaginfo.InoutDiagType = "1"
  4171. tempDiaginfo.DiagCode = item.CountryCode
  4172. tempDiaginfo.DiagName = item.CountryContentName
  4173. tempDiaginfo.DiagType = "1"
  4174. tempDiaginfo.DiagSrtNo = "1"
  4175. tempDiaginfo.MaindiagFlag = "1"
  4176. tempDiaginfo.ValiFlag = "1"
  4177. tempDiaginfo.DiagDrName = doctor.UserName
  4178. tempDiaginfo.DiagDrCode = doctor.DoctorNumber
  4179. tempDiaginfo.DiagTime = time.Unix(pre.Ctime, 0).Format("2006-01-02 15:04:05")
  4180. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  4181. } else {
  4182. var tempDiaginfo models.OwnPayPatnDiagListD
  4183. tempDiaginfo.DiagCode = item.CountryCode
  4184. tempDiaginfo.DiagName = item.CountryContentName
  4185. tempDiaginfo.DiagType = "2"
  4186. tempDiaginfo.DiagSrtNo = strconv.FormatInt(int64(index+1), 10)
  4187. tempDiaginfo.MaindiagFlag = "0"
  4188. tempDiaginfo.ValiFlag = "1"
  4189. tempDiaginfo.DiagDrName = doctor.UserName
  4190. tempDiaginfo.DiagDrCode = doctor.DoctorNumber
  4191. tempDiaginfo.DiagTime = time.Unix(pre.Ctime, 0).Format("2006-01-02 15:04:05")
  4192. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  4193. }
  4194. }
  4195. struct4202.ODiagListD = tempDiaginfos
  4196. result, requestLog := service.Gdyb4205(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4202, struct4201A)
  4197. saveLog(result, requestLog, "4205", "自费就诊和诊断信息上传")
  4198. var res2 ResultSix
  4199. var respJSON2 map[string]interface{}
  4200. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  4201. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4202. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4203. return
  4204. }
  4205. userJSONBytes2, _ := json.Marshal(respJSON2)
  4206. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  4207. utils.ErrorLog("解析失败:%v", err)
  4208. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4209. return
  4210. }
  4211. if res2.Infcode != 0 {
  4212. c.ServeSuccessJSON(map[string]interface{}{
  4213. "failed_code": -10,
  4214. "msg": res2.ErrMsg,
  4215. })
  4216. return
  4217. } else {
  4218. order.IsUploadDiagnose = 1
  4219. order.IsUploadOrderInfo = 1
  4220. service.UpdateOrderTwo(order)
  4221. c.ServeSuccessJSON(map[string]interface{}{
  4222. "msg": "上传成功",
  4223. })
  4224. }
  4225. }
  4226. func (c *HisApiController) Get4207() {
  4227. admin_user_id, _ := c.GetInt64("admin_user_id")
  4228. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  4229. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  4230. order_id, _ := c.GetInt64("order_id")
  4231. order, _ := service.GetHisOrderByIDTwo(order_id)
  4232. //his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  4233. var struct4207 models.Struct4207
  4234. struct4207.PageNum = "1"
  4235. struct4207.PageSize = "1000"
  4236. struct4207.FixmedinsCode = miConfig.Code
  4237. struct4207.FixmedinsMdtrtID = order.Number
  4238. result, requestLog := service.Gdyb4207(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4207)
  4239. saveLog(result, requestLog, "4207", "查询")
  4240. var res2 ResultSix
  4241. var respJSON2 map[string]interface{}
  4242. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  4243. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4244. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4245. return
  4246. }
  4247. userJSONBytes2, _ := json.Marshal(respJSON2)
  4248. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  4249. utils.ErrorLog("解析失败:%v", err)
  4250. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4251. return
  4252. }
  4253. if res2.Infcode != 0 {
  4254. c.ServeSuccessJSON(map[string]interface{}{
  4255. "failed_code": -10,
  4256. "msg": res2.ErrMsg,
  4257. })
  4258. return
  4259. } else {
  4260. c.ServeSuccessJSON(map[string]interface{}{
  4261. "msg": "查询成功",
  4262. })
  4263. }
  4264. }
  4265. func (c *HisApiController) Get4208() {
  4266. admin_user_id, _ := c.GetInt64("admin_user_id")
  4267. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  4268. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  4269. order_id, _ := c.GetInt64("order_id")
  4270. order, _ := service.GetHisOrderByIDTwo(order_id)
  4271. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  4272. var struct4208 models.Struct4208
  4273. struct4208.PageNum = "1"
  4274. struct4208.PageSize = "1000"
  4275. struct4208.PsnCertType = "01"
  4276. struct4208.Certno = his.Certno
  4277. struct4208.MedType = order.MedType
  4278. struct4208.PsnName = his.Name
  4279. result, requestLog := service.Gdyb4208(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4208)
  4280. saveLog(result, requestLog, "4208", "查询")
  4281. var res2 ResultSix
  4282. var respJSON2 map[string]interface{}
  4283. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  4284. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4285. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4286. return
  4287. }
  4288. userJSONBytes2, _ := json.Marshal(respJSON2)
  4289. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  4290. utils.ErrorLog("解析失败:%v", err)
  4291. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4292. return
  4293. }
  4294. if res2.Infcode != 0 {
  4295. c.ServeSuccessJSON(map[string]interface{}{
  4296. "failed_code": -10,
  4297. "msg": res2.ErrMsg,
  4298. })
  4299. return
  4300. } else {
  4301. c.ServeSuccessJSON(map[string]interface{}{
  4302. "msg": "查询成功",
  4303. })
  4304. }
  4305. }
  4306. func (c *HisApiController) Get4209() {
  4307. admin_user_id, _ := c.GetInt64("admin_user_id")
  4308. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  4309. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  4310. order_id, _ := c.GetInt64("order_id")
  4311. order, _ := service.GetHisOrderByIDTwo(order_id)
  4312. //his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  4313. var struct4209 models.Struct4209
  4314. struct4209.FixmedinsMdtrtID = order.Number
  4315. struct4209.FixmedinsCode = miConfig.Code
  4316. struct4209.PageSize = "1000"
  4317. struct4209.PageNum = "1"
  4318. result, requestLog := service.Gdyb4209(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4209)
  4319. saveLog(result, requestLog, "4209", "查询")
  4320. var res2 ResultSix
  4321. var respJSON2 map[string]interface{}
  4322. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  4323. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4324. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4325. return
  4326. }
  4327. userJSONBytes2, _ := json.Marshal(respJSON2)
  4328. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  4329. utils.ErrorLog("解析失败:%v", err)
  4330. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4331. return
  4332. }
  4333. if res2.Infcode != 0 {
  4334. c.ServeSuccessJSON(map[string]interface{}{
  4335. "failed_code": -10,
  4336. "msg": res2.ErrMsg,
  4337. })
  4338. return
  4339. } else {
  4340. c.ServeSuccessJSON(map[string]interface{}{
  4341. "msg": "查询成功",
  4342. })
  4343. }
  4344. }
  4345. type Result3101 struct {
  4346. Infcode string `json:"infcode"`
  4347. InfRefmsgid string `json:"inf_refmsgid"`
  4348. RefmsgTime string `json:"refmsg_time"`
  4349. RespondTime string `json:"respond_time"`
  4350. Enctype string `json:"enctype"`
  4351. Signtype string `json:"signtype"`
  4352. ErrMsg string `json:"err_msg"`
  4353. Output struct {
  4354. Result []struct {
  4355. JudgeResultDetailDtos []struct {
  4356. VolaItemType string `json:"vola_item_type"`
  4357. MdtrtID string `json:"mdtrt_id"`
  4358. JrdID string `json:"jrd_id"`
  4359. PatnID string `json:"patn_id"`
  4360. RxID string `json:"rx_id"`
  4361. VolaAmt interface{} `json:"vola_amt"`
  4362. } `json:"judge_result_detail_dtos"`
  4363. RuleID string `json:"rule_id"`
  4364. VolaEvid string `json:"vola_evid"`
  4365. MdtrtID string `json:"mdtrt_id"`
  4366. RuleName string `json:"rule_name"`
  4367. VolaAmtStas string `json:"vola_amt_stas"`
  4368. JrID string `json:"jr_id"`
  4369. PatnID string `json:"patn_id"`
  4370. SevDeg string `json:"sev_deg"`
  4371. VolaAmt float64 `json:"vola_amt"`
  4372. VolaBhvrType string `json:"vola_bhvr_type"`
  4373. VolaCont string `json:"vola_cont"`
  4374. } `json:"result"`
  4375. } `json:"output"`
  4376. }
  4377. type Resultgd3101 struct {
  4378. Infcode int64 `json:"infcode"`
  4379. InfRefmsgid string `json:"inf_refmsgid"`
  4380. RefmsgTime string `json:"refmsg_time"`
  4381. RespondTime string `json:"respond_time"`
  4382. Enctype string `json:"enctype"`
  4383. Signtype string `json:"signtype"`
  4384. ErrMsg string `json:"err_msg"`
  4385. Output struct {
  4386. Result []struct {
  4387. JudgeResultDetailDtos []struct {
  4388. VolaItemType string `json:"vola_item_type"`
  4389. MdtrtID string `json:"mdtrt_id"`
  4390. JrdID string `json:"jrd_id"`
  4391. PatnID string `json:"patn_id"`
  4392. RxID string `json:"rx_id"`
  4393. VolaAmt interface{} `json:"vola_amt"`
  4394. } `json:"judge_result_detail_dtos"`
  4395. RuleID string `json:"rule_id"`
  4396. VolaEvid string `json:"vola_evid"`
  4397. MdtrtID string `json:"mdtrt_id"`
  4398. RuleName string `json:"rule_name"`
  4399. VolaAmtStas string `json:"vola_amt_stas"`
  4400. JrID string `json:"jr_id"`
  4401. PatnID string `json:"patn_id"`
  4402. SevDeg string `json:"sev_deg"`
  4403. VolaAmt float64 `json:"vola_amt"`
  4404. VolaBhvrType string `json:"vola_bhvr_type"`
  4405. VolaCont string `json:"vola_cont"`
  4406. } `json:"result"`
  4407. } `json:"output"`
  4408. }
  4409. func (c *HisApiController) ReadEleToken() {
  4410. admin_user_id, _ := c.GetInt64("admin_user_id")
  4411. his_patient_id, _ := c.GetInt64("his_patient_id")
  4412. adminUser := c.GetAdminUserInfo()
  4413. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  4414. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  4415. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  4416. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  4417. tokens := ReadEleCard(admin_user_id, c.GetAdminUserInfo().CurrentOrgId, c)
  4418. if len(tokens) > 0 {
  4419. c.ServeSuccessJSON(map[string]interface{}{
  4420. "msg": "读取成功",
  4421. })
  4422. } else {
  4423. c.ServeSuccessJSON(map[string]interface{}{
  4424. "failed_code": -10,
  4425. "msg": "读取失败",
  4426. })
  4427. }
  4428. } else if miConfig.MdtrtareaAdmvs == "341203" {
  4429. tokens := ReadEleCardforah(admin_user_id, c.GetAdminUserInfo().CurrentOrgId, c)
  4430. if len(tokens) > 0 {
  4431. c.ServeSuccessJSON(map[string]interface{}{
  4432. "msg": "读取成功",
  4433. })
  4434. } else {
  4435. c.ServeSuccessJSON(map[string]interface{}{
  4436. "failed_code": -10,
  4437. "msg": "读取失败",
  4438. })
  4439. }
  4440. } else if miConfig.MdtrtareaAdmvs == "150499" {
  4441. var api string
  4442. 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 +
  4443. "&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"
  4444. resp, requestErr := http.Get(api)
  4445. if requestErr != nil {
  4446. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4447. }
  4448. body, ioErr := ioutil.ReadAll(resp.Body)
  4449. if ioErr != nil {
  4450. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4451. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4452. }
  4453. var respJSON map[string]interface{}
  4454. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  4455. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4456. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4457. return
  4458. }
  4459. var status string
  4460. status = respJSON["data"].(map[string]interface{})["status"].(string)
  4461. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  4462. var token string
  4463. var res ResultTwo //1101结果
  4464. var res10265 ResultTwo10265 //1101结果
  4465. if status == "0" { //读卡成功
  4466. var card_info string //卡信息
  4467. var busi_card_info string
  4468. token = respJSON["data"].(map[string]interface{})["token"].(string)
  4469. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  4470. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  4471. fmt.Println(card_info)
  4472. fmt.Println(busi_card_info)
  4473. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  4474. result, _ := json.Marshal(respJSON)
  4475. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  4476. utils.ErrorLog("解析失败:%v", err)
  4477. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4478. return
  4479. }
  4480. res.ErrMsg = res10265.ErrMsg
  4481. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  4482. res.Infcode = infocode
  4483. res.Output = res10265.Output
  4484. res.InfRefmsgid = res10265.InfRefmsgid
  4485. if res.Infcode == 0 {
  4486. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  4487. if err == gorm.ErrRecordNotFound {
  4488. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  4489. return
  4490. } else if err != nil {
  4491. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  4492. return
  4493. } else {
  4494. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  4495. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  4496. infoStr := string(Iinfos)
  4497. idetinfoStr := string(Idetinfos)
  4498. //date,age,_ := GetBirthdateAndAge(res.Output.Baseinfo.Certno),
  4499. b, age, _ := getBirthdateAndAge(res.Output.Baseinfo.Certno)
  4500. psn := &models.HisPsn{
  4501. PsnNo: res.Output.Baseinfo.PsnNo,
  4502. PatientId: patient.ID,
  4503. Certno: res.Output.Baseinfo.Certno,
  4504. Gend: res.Output.Baseinfo.Gend,
  4505. Naty: res.Output.Baseinfo.Naty,
  4506. PsnCertType: res.Output.Baseinfo.PsnCertType,
  4507. PsnName: res.Output.Baseinfo.PsnName,
  4508. Age: float64(age),
  4509. Brdy: b,
  4510. Idetinfo: idetinfoStr,
  4511. Insuinfo: infoStr,
  4512. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  4513. CardInfo: card_info,
  4514. VerifyNumber: token,
  4515. IdCardType: 4,
  4516. }
  4517. var rf []*ResultFive
  4518. json.Unmarshal([]byte(infoStr), &rf)
  4519. var insutypes []*ResultFive
  4520. var insutype string
  4521. var is390 int = 0
  4522. var is310 int = 0
  4523. for _, item := range rf {
  4524. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  4525. insutypes = append(insutypes, item)
  4526. }
  4527. }
  4528. if len(insutypes) == 1 {
  4529. insutype = insutypes[0].Insutype
  4530. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  4531. } else {
  4532. for _, i := range insutypes {
  4533. if i.Insutype == "390" {
  4534. is390 = 1
  4535. }
  4536. if i.Insutype == "310" {
  4537. is310 = 1
  4538. }
  4539. }
  4540. }
  4541. if is390 == 1 {
  4542. insutype = "390"
  4543. }
  4544. if is310 == 1 {
  4545. insutype = "310"
  4546. }
  4547. if len(insutypes) == 0 {
  4548. insutype = "310"
  4549. }
  4550. service.CreateHisPsn(psn)
  4551. c.ServeSuccessJSON(map[string]interface{}{
  4552. "patient": patient,
  4553. "number": token,
  4554. "insutype": insutype,
  4555. })
  4556. }
  4557. } else {
  4558. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  4559. return
  4560. }
  4561. } else { //读卡失败
  4562. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  4563. return
  4564. }
  4565. } else if miConfig.MdtrtareaAdmvs == "350500" {
  4566. _, outPutInfo, errMsg := service.ReadEleCardForSettle(miConfig.Code, roles.UserName, roles.AdminUserId)
  4567. if len(errMsg) == 0 {
  4568. type ELeData struct {
  4569. Data struct {
  4570. IdNo string `json:"idNo"`
  4571. IdType string `json:"idType"`
  4572. UserName string `json:"userName"`
  4573. EcToken string `json:"ecToken"`
  4574. InsuOrg string `json:"insuOrg"`
  4575. Gender string `json:"gender"`
  4576. Birthday string `json:"birthday"`
  4577. Nationality string `json:"nationality"`
  4578. Email string `json:"email"`
  4579. Extra string `json:"extra"`
  4580. } `json:"data"`
  4581. Code int `json:"code"`
  4582. Message string `json:"message"`
  4583. }
  4584. var ele ELeData
  4585. err := json.Unmarshal([]byte(outPutInfo), &ele)
  4586. if err != nil {
  4587. utils.ErrorLog("解析失败:%v", err)
  4588. }
  4589. token := ele.Data.EcToken
  4590. if len(token) > 0 {
  4591. psn := &models.HisPsn{
  4592. PsnNo: his.PsnNo,
  4593. Age: 0,
  4594. PatientId: his.PatientId,
  4595. Certno: his.Certno,
  4596. Brdy: his.Brdy,
  4597. Gend: his.Gend,
  4598. Naty: his.Naty,
  4599. PsnCertType: his.PsnCertType,
  4600. PsnName: his.PsnName,
  4601. Idetinfo: his.Idetinfo,
  4602. Insuinfo: his.Iinfo,
  4603. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  4604. CardInfo: outPutInfo,
  4605. VerifyNumber: token,
  4606. }
  4607. service.CreateHisPsn(psn)
  4608. }
  4609. if len(token) > 0 {
  4610. c.ServeSuccessJSON(map[string]interface{}{
  4611. "msg": "读取成功",
  4612. })
  4613. } else {
  4614. c.ServeSuccessJSON(map[string]interface{}{
  4615. "failed_code": -10,
  4616. "msg": "读取失败",
  4617. })
  4618. }
  4619. }
  4620. } else if miConfig.MdtrtareaAdmvs == "360302" {
  4621. _, result := GetELeInfoThree(miConfig.Code, "1", roles.UserName)
  4622. //json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  4623. type ELeData struct {
  4624. Data struct {
  4625. IdNo string `json:"idNo"`
  4626. IdType string `json:"idType"`
  4627. UserName string `json:"userName"`
  4628. EcToken string `json:"ecToken"`
  4629. InsuOrg string `json:"insuOrg"`
  4630. Gender string `json:"gender"`
  4631. Birthday string `json:"birthday"`
  4632. Nationality string `json:"nationality"`
  4633. Email string `json:"email"`
  4634. Extra string `json:"extra"`
  4635. } `json:"data"`
  4636. Code int `json:"code"`
  4637. Message string `json:"message"`
  4638. }
  4639. var ele ELeData
  4640. err := json.Unmarshal([]byte(result), &ele)
  4641. if err != nil {
  4642. utils.ErrorLog("解析失败:%v", err)
  4643. }
  4644. token := ele.Data.EcToken
  4645. token = Remove0000(token)
  4646. fmt.Println(ele.Data.UserName)
  4647. 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)
  4648. saveLog(result2, requestLog2, "1101", "获取人员信息")
  4649. var res ResultTwo
  4650. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  4651. utils.ErrorLog("解析失败:%v", err)
  4652. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4653. return
  4654. }
  4655. if res.Infcode == 0 {
  4656. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  4657. if err == gorm.ErrRecordNotFound {
  4658. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  4659. return
  4660. } else if err != nil {
  4661. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  4662. return
  4663. } else {
  4664. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  4665. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  4666. infoStr := string(Iinfos)
  4667. idetinfoStr := string(Idetinfos)
  4668. psn := &models.HisPsn{
  4669. PsnNo: res.Output.Baseinfo.PsnNo,
  4670. PatientId: patient.ID,
  4671. Certno: res.Output.Baseinfo.Certno,
  4672. Gend: res.Output.Baseinfo.Gend,
  4673. Naty: res.Output.Baseinfo.Naty,
  4674. PsnCertType: res.Output.Baseinfo.PsnCertType,
  4675. PsnName: res.Output.Baseinfo.PsnName,
  4676. Idetinfo: idetinfoStr,
  4677. Insuinfo: infoStr,
  4678. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  4679. CardInfo: "",
  4680. VerifyNumber: token,
  4681. }
  4682. service.CreateHisPsn(psn)
  4683. c.ServeSuccessJSON(map[string]interface{}{
  4684. "patient": patient,
  4685. "number": token,
  4686. })
  4687. }
  4688. } else {
  4689. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  4690. return
  4691. }
  4692. } else if miConfig.MdtrtareaAdmvs == "430800" {
  4693. idNo := c.GetString("idNo")
  4694. userName := c.GetString("userName")
  4695. ecToken := c.GetString("ecToken")
  4696. insuOrg := c.GetString("insuOrg")
  4697. result2, requestLog2 := service.Hnyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, insuOrg, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, ecToken, "", idNo, userName)
  4698. saveLog(result2, requestLog2, "1101", "获取人员信息")
  4699. var res ResultTwo
  4700. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  4701. utils.ErrorLog("解析失败:%v", err)
  4702. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4703. return
  4704. }
  4705. if res.Infcode == 0 {
  4706. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  4707. if err == gorm.ErrRecordNotFound {
  4708. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  4709. return
  4710. } else if err != nil {
  4711. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  4712. return
  4713. } else {
  4714. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  4715. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  4716. infoStr := string(Iinfos)
  4717. idetinfoStr := string(Idetinfos)
  4718. psn := &models.HisPsn{
  4719. PsnNo: res.Output.Baseinfo.PsnNo,
  4720. PatientId: patient.ID,
  4721. Certno: res.Output.Baseinfo.Certno,
  4722. Gend: res.Output.Baseinfo.Gend,
  4723. Naty: res.Output.Baseinfo.Naty,
  4724. PsnCertType: res.Output.Baseinfo.PsnCertType,
  4725. PsnName: res.Output.Baseinfo.PsnName,
  4726. Idetinfo: idetinfoStr,
  4727. Insuinfo: infoStr,
  4728. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  4729. CardInfo: "",
  4730. VerifyNumber: ecToken,
  4731. InsuplcAdmdvs: insuOrg,
  4732. }
  4733. service.CreateHisPsn(psn)
  4734. c.ServeSuccessJSON(map[string]interface{}{
  4735. "patient": patient,
  4736. "number": ecToken,
  4737. })
  4738. }
  4739. } else {
  4740. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  4741. return
  4742. }
  4743. } else if miConfig.MdtrtareaAdmvs == "450721" {
  4744. res := c.GetoleInfo()
  4745. if res.Infcode == 0 {
  4746. var result string
  4747. if res.Output.MdtrtCertType == "01" {
  4748. 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)
  4749. } else if res.Output.MdtrtCertType == "02" {
  4750. 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)
  4751. } else if res.Output.MdtrtCertType == "03" {
  4752. 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)
  4753. }
  4754. var dat map[string]interface{}
  4755. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4756. fmt.Println(dat)
  4757. } else {
  4758. fmt.Println(err)
  4759. }
  4760. userJSONBytes, _ := json.Marshal(dat)
  4761. var res2 ResultTwo
  4762. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  4763. utils.ErrorLog("解析失败:%v", err)
  4764. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4765. return
  4766. }
  4767. if res2.Infcode == 0 {
  4768. patient, err := service.GetPatientByNumber(res.Output.CertNo, c.GetAdminUserInfo().CurrentOrgId)
  4769. if err == gorm.ErrRecordNotFound {
  4770. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  4771. return
  4772. } else if err != nil {
  4773. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  4774. return
  4775. } else {
  4776. Iinfos, _ := json.Marshal(res2.Output.Iinfo)
  4777. Idetinfos, _ := json.Marshal(res2.Output.Idetinfo)
  4778. infoStr := string(Iinfos)
  4779. idetinfoStr := string(Idetinfos)
  4780. var rf []*ResultFive
  4781. json.Unmarshal([]byte(infoStr), &rf)
  4782. var insutypes []*ResultFive
  4783. var insutype string
  4784. var is390 int = 0
  4785. var is310 int = 0
  4786. //var insuplc_admdvs string
  4787. for _, item := range rf {
  4788. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  4789. insutypes = append(insutypes, item)
  4790. }
  4791. }
  4792. if len(insutypes) == 1 {
  4793. insutype = insutypes[0].Insutype
  4794. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  4795. } else {
  4796. for _, i := range insutypes {
  4797. if i.Insutype == "390" {
  4798. is390 = 1
  4799. }
  4800. if i.Insutype == "310" {
  4801. is310 = 1
  4802. }
  4803. }
  4804. }
  4805. if is390 == 1 {
  4806. insutype = "390"
  4807. }
  4808. if is310 == 1 {
  4809. insutype = "310"
  4810. }
  4811. if len(insutypes) == 0 {
  4812. insutype = "310"
  4813. }
  4814. psn := &models.HisPsn{
  4815. PsnNo: res2.Output.Baseinfo.PsnNo,
  4816. PatientId: patient.ID,
  4817. Certno: res2.Output.Baseinfo.Certno,
  4818. Gend: res2.Output.Baseinfo.Gend,
  4819. Naty: res2.Output.Baseinfo.Naty,
  4820. PsnCertType: res2.Output.Baseinfo.PsnCertType,
  4821. PsnName: res2.Output.Baseinfo.PsnName,
  4822. Idetinfo: idetinfoStr,
  4823. Insuinfo: infoStr,
  4824. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  4825. CardInfo: res.Output.CertNo + "|" + res.Output.CardSN,
  4826. VerifyNumber: res.Output.EcToken,
  4827. InsuplcAdmdvs: res.Output.InsuplcAdmdvs,
  4828. }
  4829. service.CreateHisPsn(psn)
  4830. c.ServeSuccessJSON(map[string]interface{}{
  4831. "patient": patient,
  4832. "number": res.Output.CardNo,
  4833. "insutype": insutype,
  4834. })
  4835. }
  4836. } else {
  4837. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  4838. return
  4839. }
  4840. } else {
  4841. c.ServeSuccessJSON(map[string]interface{}{
  4842. "failed_code": -10,
  4843. "msg": res.ErrMsg,
  4844. })
  4845. }
  4846. } else {
  4847. //if initFlag == 0 {
  4848. // c.TestGetBasBaseInit()
  4849. //}
  4850. //token := c.GetEleBaseInfo()
  4851. //token = Remove0000(token)
  4852. type ELeData struct {
  4853. Code string `json:"code"`
  4854. Data struct {
  4855. Aac002 string `json:"aac002"`
  4856. Aaz500 string `json:"aaz500"`
  4857. ActCardNo string `json:"actCardNo"`
  4858. Bab520 string `json:"bab520"`
  4859. Bkz543 string `json:"bkz543"`
  4860. BusinessType string `json:"businessType"`
  4861. CertfCodg string `json:"certfCodg"`
  4862. EcIndexNo string `json:"ecIndexNo"`
  4863. EcToken string `json:"ecToken"`
  4864. ID0000 string `json:"id0000"`
  4865. IDNo string `json:"idNo"`
  4866. IDType string `json:"idType"`
  4867. Idcode string `json:"idcode"`
  4868. IdentityToken string `json:"identity_token"`
  4869. InsuOrg string `json:"insuOrg"`
  4870. OfficeID string `json:"officeId"`
  4871. OfficeName string `json:"officeName"`
  4872. OperatorID string `json:"operatorId"`
  4873. OperatorName string `json:"operatorName"`
  4874. OrgID string `json:"orgId"`
  4875. UserName string `json:"userName"`
  4876. } `json:"data"`
  4877. Infno interface{} `json:"infno"`
  4878. Message string `json:"message"`
  4879. OrgID string `json:"orgId"`
  4880. TransType string `json:"transType"`
  4881. }
  4882. _, result := GetELeInfoThree(miConfig.Code, "1", roles.UserName)
  4883. fmt.Println(result)
  4884. outPutInfo := Remove0000(result)
  4885. fmt.Println(outPutInfo)
  4886. var ele ELeData
  4887. err := json.Unmarshal([]byte(outPutInfo), &ele)
  4888. if err != nil {
  4889. utils.ErrorLog("解析失败:%v", err)
  4890. }
  4891. token := ele.Data.EcToken
  4892. var result2 string
  4893. var requestLog2 string
  4894. if len(token) > 0 {
  4895. if strings.Contains(ele.Data.IDNo, "HKG") {
  4896. 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)
  4897. } else {
  4898. result2, requestLog2 = service.Gdyb1101ForEleCerttwo(miConfig.OrgName, roles.UserName, miConfig.Code, ele.Data.InsuOrg, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, token, ele.Data.UserName, ele.Data.IDNo)
  4899. }
  4900. saveLog(result2, requestLog2, "1101", "获取人员信息")
  4901. var res ResultTwo
  4902. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  4903. utils.ErrorLog("解析失败:%v", err)
  4904. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4905. return
  4906. }
  4907. if res.Infcode == 0 {
  4908. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  4909. if err == gorm.ErrRecordNotFound {
  4910. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  4911. return
  4912. } else if err != nil {
  4913. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  4914. return
  4915. } else {
  4916. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  4917. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  4918. infoStr := string(Iinfos)
  4919. idetinfoStr := string(Idetinfos)
  4920. psn := &models.HisPsn{
  4921. PsnNo: res.Output.Baseinfo.PsnNo,
  4922. PatientId: patient.ID,
  4923. Certno: res.Output.Baseinfo.Certno,
  4924. Gend: res.Output.Baseinfo.Gend,
  4925. Naty: res.Output.Baseinfo.Naty,
  4926. PsnCertType: res.Output.Baseinfo.PsnCertType,
  4927. PsnName: res.Output.Baseinfo.PsnName,
  4928. Idetinfo: idetinfoStr,
  4929. Insuinfo: infoStr,
  4930. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  4931. CardInfo: "",
  4932. VerifyNumber: token,
  4933. }
  4934. service.CreateHisPsn(psn)
  4935. c.ServeSuccessJSON(map[string]interface{}{
  4936. "msg": "读取成功",
  4937. })
  4938. }
  4939. } else {
  4940. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  4941. return
  4942. }
  4943. } else {
  4944. c.ServeSuccessJSON(map[string]interface{}{
  4945. "failed_code": -10,
  4946. "msg": "读取失败",
  4947. })
  4948. }
  4949. }
  4950. }
  4951. func (c *HisApiController) ReadEleFace() {
  4952. admin_user_id, _ := c.GetInt64("admin_user_id")
  4953. //his_patient_id, _ := c.GetInt64("his_patient_id")
  4954. adminUser := c.GetAdminUserInfo()
  4955. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  4956. //roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  4957. //his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  4958. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  4959. tokens := ReadEleFace(admin_user_id, c.GetAdminUserInfo().CurrentOrgId, c)
  4960. if len(tokens) > 0 {
  4961. c.ServeSuccessJSON(map[string]interface{}{
  4962. "msg": "读取成功",
  4963. })
  4964. } else {
  4965. c.ServeSuccessJSON(map[string]interface{}{
  4966. "failed_code": -10,
  4967. "msg": "读取失败",
  4968. })
  4969. }
  4970. }
  4971. }
  4972. func (c *HisApiController) Get9001() {
  4973. adminUser := c.GetAdminUserInfo()
  4974. admin_user_id, _ := c.GetInt64("admin_user_id")
  4975. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  4976. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  4977. if miConfig.MdtrtareaAdmvs == "350500" {
  4978. service.GetFjAuthorizationInfo(miConfig.Code)
  4979. } else if miConfig.MdtrtareaAdmvs == "131023" {
  4980. result, _ := service.HeBeiyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  4981. var dat map[string]interface{}
  4982. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4983. fmt.Println(dat)
  4984. } else {
  4985. fmt.Println(err)
  4986. }
  4987. userJSONBytes, _ := json.Marshal(dat)
  4988. var res models.Result9001
  4989. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4990. utils.ErrorLog("解析失败:%v", err)
  4991. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4992. return
  4993. }
  4994. } else if miConfig.MdtrtareaAdmvs == "341203" {
  4995. fmt.Println(miConfig.SecretKey)
  4996. var res models.Result9001Two
  4997. 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 +
  4998. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&cainfo=" + miConfig.Cainfo + "&url=" + miConfig.Url
  4999. resp, requestErr := http.Get(api)
  5000. if requestErr != nil {
  5001. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5002. return
  5003. }
  5004. body, ioErr := ioutil.ReadAll(resp.Body)
  5005. if ioErr != nil {
  5006. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5007. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5008. return
  5009. }
  5010. var respJSON map[string]interface{}
  5011. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5012. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5013. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5014. return
  5015. }
  5016. status := respJSON["data"].(map[string]interface{})["status"].(string)
  5017. if status == "0" {
  5018. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  5019. c.ServeSuccessJSON(map[string]interface{}{
  5020. "failed_code": -10,
  5021. "msg": err_msg,
  5022. })
  5023. return
  5024. }
  5025. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5026. result, _ := json.Marshal(respJSON)
  5027. fmt.Println("log")
  5028. fmt.Println(string(result))
  5029. if err := json.Unmarshal([]byte(result), &res); err != nil {
  5030. utils.ErrorLog("解析失败:%v", err)
  5031. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5032. return
  5033. }
  5034. if res.Infcode == 0 {
  5035. sign := models.HisSignIn{
  5036. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  5037. SignNo: res.Output.Signinoutb.SignNo,
  5038. SignTime: "",
  5039. Ctime: time.Now().Unix(),
  5040. Mtime: time.Now().Unix(),
  5041. Status: 1,
  5042. InputLog: "",
  5043. OutputLog: "",
  5044. FixmedinsCode: miConfig.Code,
  5045. }
  5046. err := service.CreateSignIn(&sign)
  5047. if err == nil {
  5048. c.ServeSuccessJSON(map[string]interface{}{
  5049. "msg": "签到成功",
  5050. })
  5051. }
  5052. } else {
  5053. c.ServeSuccessJSON(map[string]interface{}{
  5054. "failed_code": -10,
  5055. "msg": res.ErrMsg,
  5056. })
  5057. return
  5058. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  5059. //return
  5060. }
  5061. } else {
  5062. result, _ := service.Gdyb9001Two(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  5063. var dat map[string]interface{}
  5064. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5065. fmt.Println(dat)
  5066. } else {
  5067. fmt.Println(err)
  5068. }
  5069. userJSONBytes, _ := json.Marshal(dat)
  5070. var res models.Result9001
  5071. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5072. utils.ErrorLog("解析失败:%v", err)
  5073. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5074. return
  5075. }
  5076. if res.Infcode == 0 {
  5077. sign := models.HisSignIn{
  5078. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  5079. SignNo: res.Output.Signinoutb.SignNo,
  5080. SignTime: res.Output.Signinoutb.SignTime,
  5081. Ctime: time.Now().Unix(),
  5082. Mtime: time.Now().Unix(),
  5083. Status: 1,
  5084. InputLog: "",
  5085. OutputLog: "",
  5086. FixmedinsCode: miConfig.Code,
  5087. }
  5088. err := service.CreateSignIn(&sign)
  5089. if err == nil {
  5090. c.ServeSuccessJSON(map[string]interface{}{
  5091. "msg": "签到成功",
  5092. })
  5093. }
  5094. }
  5095. }
  5096. }
  5097. 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) {
  5098. var res Result3101
  5099. adminUser := c.GetAdminUserInfo()
  5100. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  5101. //his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  5102. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  5103. //record_time := c.GetString("record_time")
  5104. //trig_scen := c.GetString("trig_scen")
  5105. timeLayout := "2006-01-02"
  5106. loc, _ := time.LoadLocation("Local")
  5107. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  5108. if err != nil {
  5109. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5110. return res
  5111. }
  5112. recordDateTime := theTime.Unix()
  5113. var patientPrescription models.HisPrescriptionInfo
  5114. //patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  5115. //if patientPrescription.ID == 0 {
  5116. patientPrescription, _ = service.FindLastPatientPrescriptionInfoTwo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  5117. //}
  5118. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  5119. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  5120. //
  5121. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  5122. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  5123. var pp models.PublicParams
  5124. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  5125. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  5126. pp.FixmedinsName = miConfig.OrgName
  5127. pp.FixmedinsCode = miConfig.Code
  5128. pp.RequestUrl = miConfig.Url
  5129. pp.Cainfo = miConfig.Cainfo
  5130. pp.SecretKey = miConfig.SecretKey
  5131. pp.AccessKey = miConfig.AccessKey
  5132. pp.OpterName = roles.UserName
  5133. var config []*models.HisXtDiagnoseConfig
  5134. for _, item := range diagnosis_ids {
  5135. id, _ := strconv.ParseInt(item, 10, 64)
  5136. diagnosisConfig, _ := service.FindDiagnoseById(id)
  5137. config = append(config, &diagnosisConfig)
  5138. }
  5139. var pd models.PatientDtos
  5140. pd.PatnID = his.PsnNo
  5141. pd.PatnName = his.Name
  5142. pd.Gend = his.Gend
  5143. pd.Brdy = his.Brdy
  5144. pd.Poolarea = miConfig.MdtrtareaAdmvs
  5145. pd.CurrMdtrtID = his.Number
  5146. var fed models.FsiEncounterDtos
  5147. fed.MdtrtID = his.Number
  5148. fed.MedinsID = miConfig.Code
  5149. fed.MedinsName = miConfig.OrgName
  5150. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  5151. fed.MedMdtrtType = "1"
  5152. fed.MedinsType = "1"
  5153. fed.MedinsLv = "11"
  5154. tm := time.Unix(his.RecordDate, 0)
  5155. s_tm := tm.Format("2006-01-02 15:04:05")
  5156. fed.AdmDate = s_tm
  5157. fed.DscgDate = s_tm
  5158. fed.DscgMainDiseCodg = config[0].CountryCode
  5159. fed.DscgMainDiseName = config[0].CountryContentName
  5160. //诊断信息
  5161. var fdds []*models.FsiDiagnoseDtos
  5162. for index, item := range config {
  5163. if index == 0 {
  5164. var fdd models.FsiDiagnoseDtos
  5165. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  5166. fdd.InoutDiseType = "1"
  5167. fdd.MaindiseFlag = "1"
  5168. fdd.DiseDate = s_tm
  5169. fdd.DiasSrtNo = "1"
  5170. fdd.DiseName = item.CountryContentName
  5171. fdd.DiseCodg = item.CountryCode
  5172. fdds = append(fdds, &fdd)
  5173. } else {
  5174. var fdd models.FsiDiagnoseDtos
  5175. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  5176. fdd.InoutDiseType = "1"
  5177. fdd.MaindiseFlag = "1"
  5178. fdd.DiseDate = s_tm
  5179. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  5180. fdd.DiseName = item.CountryContentName
  5181. fdd.DiseCodg = item.CountryCode
  5182. fdds = append(fdds, &fdd)
  5183. }
  5184. }
  5185. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  5186. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  5187. fed.AdmDeptName = department.Name
  5188. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  5189. fed.DscgDeptName = department.Name
  5190. fed.MedMdtrtType = "1"
  5191. fed.MedType = "11"
  5192. //if his.Insutype == "390" {
  5193. // fed.MedType = "1402"
  5194. //} else {
  5195. // fed.MedType = "9933"
  5196. //}
  5197. var orders []*models.FsiOrderDtos
  5198. if trig_scen == "2" {
  5199. //处方医嘱信息
  5200. for _, item := range prescriptions {
  5201. for _, subItem := range item.HisDoctorAdviceInfo {
  5202. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  5203. var order models.FsiOrderDtos
  5204. order.RxID = strconv.FormatInt(item.ID, 10)
  5205. order.Rxno = strconv.FormatInt(item.ID, 10)
  5206. order.LongDrordFlag = "0"
  5207. order.HilistType = "1"
  5208. order.ChrgType = "1"
  5209. order.DrordBhvr = "-"
  5210. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  5211. order.HosplistName = subItem.BaseDrugLib.DrugName
  5212. order.HilistLv = "1"
  5213. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  5214. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  5215. order.HosplistName = subItem.BaseDrugLib.DrugName
  5216. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  5217. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  5218. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  5219. order.OwnpayAmt = ""
  5220. order.SelfpayAmt = ""
  5221. order.Spec = ""
  5222. order.SpecUnt = ""
  5223. order.DrordBegnDate = s_tm
  5224. order.DrordStopDate = ""
  5225. order.DrordDrCodg = doctor_info.DoctorNumber
  5226. order.DrordDeptName = department.Name
  5227. order.DrordDeptCodg = department.Number
  5228. order.DrordDrName = doctor_info.UserName
  5229. order.DrordDrProfttl = "234"
  5230. order.CurrDrordFlag = "1"
  5231. orders = append(orders, &order)
  5232. }
  5233. }
  5234. for _, subItem := range item.HisPrescriptionProject {
  5235. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  5236. var order models.FsiOrderDtos
  5237. order.RxID = strconv.FormatInt(item.ID, 10)
  5238. order.Rxno = strconv.FormatInt(item.ID, 10)
  5239. order.LongDrordFlag = "0"
  5240. order.HilistType = "1"
  5241. order.ChrgType = "1"
  5242. order.DrordBhvr = "-"
  5243. order.HilistCode = subItem.HisProject.MedicalCode
  5244. order.HosplistName = subItem.HisProject.ProjectName
  5245. order.HilistLv = "1"
  5246. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  5247. order.HosplistCode = subItem.HisProject.MedicalCode
  5248. order.HosplistName = subItem.HisProject.ProjectName
  5249. order.Cnt = subItem.Count
  5250. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  5251. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  5252. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  5253. order.OwnpayAmt = ""
  5254. order.SelfpayAmt = ""
  5255. order.Spec = ""
  5256. order.SpecUnt = ""
  5257. order.DrordBegnDate = s_tm
  5258. order.DrordStopDate = ""
  5259. order.DrordDrCodg = doctor_info.DoctorNumber
  5260. order.DrordDeptName = department.Name
  5261. order.DrordDeptCodg = department.Number
  5262. order.DrordDrName = doctor_info.UserName
  5263. order.DrordDrProfttl = "234"
  5264. order.CurrDrordFlag = "1"
  5265. orders = append(orders, &order)
  5266. }
  5267. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  5268. var order models.FsiOrderDtos
  5269. order.RxID = strconv.FormatInt(item.ID, 10)
  5270. order.Rxno = strconv.FormatInt(item.ID, 10)
  5271. order.LongDrordFlag = "0"
  5272. order.HilistType = "1"
  5273. order.ChrgType = "1"
  5274. order.DrordBhvr = "-"
  5275. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  5276. order.HosplistName = subItem.GoodInfo.GoodName
  5277. order.HilistLv = "1"
  5278. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  5279. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  5280. order.HosplistName = subItem.GoodInfo.GoodName
  5281. order.Cnt = subItem.Count
  5282. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  5283. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  5284. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  5285. order.OwnpayAmt = ""
  5286. order.SelfpayAmt = ""
  5287. order.Spec = ""
  5288. order.SpecUnt = ""
  5289. order.DrordBegnDate = s_tm
  5290. order.DrordStopDate = ""
  5291. order.DrordDrCodg = doctor_info.DoctorNumber
  5292. order.DrordDeptName = department.Name
  5293. order.DrordDeptCodg = department.Number
  5294. order.DrordDrName = doctor_info.UserName
  5295. order.DrordDrProfttl = "234"
  5296. order.CurrDrordFlag = "1"
  5297. orders = append(orders, &order)
  5298. }
  5299. }
  5300. }
  5301. //处方医嘱信息
  5302. }
  5303. fed.MatnStas = "0"
  5304. fed.MedfeeSumamt = "0"
  5305. fed.OwnpayAmt = "0"
  5306. fed.SelfpayAmt = "0"
  5307. fed.AcctPayamt = "0"
  5308. fed.MaAmt = "0"
  5309. fed.HifpPayamt = "0"
  5310. fed.SetlTotlnum = "1"
  5311. fed.Insutype = his.Insutype
  5312. fed.ReimFlag = "0"
  5313. fed.OutSetlFlag = "0"
  5314. var fopd []*models.FsiOperationDtosData
  5315. data := make(map[string]interface{})
  5316. data["fed"] = fed
  5317. data["fdd"] = fdds
  5318. data["fod"] = orders
  5319. data["pd"] = pd
  5320. data["pp"] = pp
  5321. data["fopd"] = fopd
  5322. data["trig_scen"] = trig_scen
  5323. fmt.Println(data)
  5324. fmt.Println(fed)
  5325. fmt.Println(fdds)
  5326. fmt.Println(orders)
  5327. fmt.Println(pd)
  5328. fmt.Println(pp)
  5329. fmt.Println(fopd)
  5330. client := &http.Client{}
  5331. bytesData, _ := json.Marshal(data)
  5332. var req *http.Request
  5333. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  5334. if miConfig.MdtrtareaAdmvs == "320921" {
  5335. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  5336. } else {
  5337. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  5338. }
  5339. resp, _ := client.Do(req)
  5340. defer resp.Body.Close()
  5341. body, ioErr := ioutil.ReadAll(resp.Body)
  5342. if ioErr != nil {
  5343. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5344. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5345. return res
  5346. }
  5347. var respJSON map[string]interface{}
  5348. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5349. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5350. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5351. return res
  5352. }
  5353. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  5354. fmt.Println(respJSON)
  5355. result, _ := json.Marshal(respJSON)
  5356. fmt.Println(result)
  5357. if err := json.Unmarshal([]byte(result), &res); err != nil {
  5358. utils.ErrorLog("解析失败:%v", err)
  5359. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5360. return res
  5361. }
  5362. return res
  5363. } else {
  5364. //if miConfig.MdtrtareaAdmvs == "441202" {
  5365. output, input := service.Gdyb3101(pd, fed, fdds, orders, fopd, pp, trig_scen)
  5366. saveLog(output, input, "3101", "事前")
  5367. if err := json.Unmarshal([]byte(output), &res); err != nil {
  5368. utils.ErrorLog("解析失败:%v", err)
  5369. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5370. return
  5371. }
  5372. return res
  5373. //}
  5374. }
  5375. }
  5376. 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) {
  5377. adminUser := c.GetAdminUserInfo()
  5378. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  5379. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  5380. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  5381. //record_time := c.GetString("record_time")
  5382. //trig_scen := c.GetString("trig_scen")
  5383. timeLayout := "2006-01-02"
  5384. loc, _ := time.LoadLocation("Local")
  5385. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  5386. if err != nil {
  5387. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5388. return res
  5389. }
  5390. recordDateTime := theTime.Unix()
  5391. var patientPrescription models.HisPrescriptionInfo
  5392. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  5393. if patientPrescription.ID == 0 {
  5394. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  5395. }
  5396. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  5397. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  5398. //
  5399. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  5400. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  5401. var pp models.PublicParams
  5402. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  5403. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  5404. pp.FixmedinsName = miConfig.OrgName
  5405. pp.FixmedinsCode = miConfig.Code
  5406. pp.RequestUrl = miConfig.Url
  5407. pp.Cainfo = miConfig.Cainfo
  5408. pp.SecretKey = miConfig.SecretKey
  5409. pp.AccessKey = miConfig.AccessKey
  5410. pp.OpterName = roles.UserName
  5411. var config []*models.HisXtDiagnoseConfig
  5412. for _, item := range diagnosis_ids {
  5413. id, _ := strconv.ParseInt(item, 10, 64)
  5414. diagnosisConfig, _ := service.FindDiagnoseById(id)
  5415. config = append(config, &diagnosisConfig)
  5416. }
  5417. var pd models.PatientDtos
  5418. pd.PatnID = his.PsnNo
  5419. pd.PatnName = his.Name
  5420. pd.Gend = his.Gend
  5421. pd.Brdy = his.Brdy
  5422. pd.Poolarea = his.InsuplcAdmdvs
  5423. pd.CurrMdtrtID = his.Number
  5424. var fed models.FsiEncounterDtos
  5425. fed.MdtrtID = his.Number
  5426. fed.MedinsID = miConfig.Code
  5427. fed.MedinsName = miConfig.OrgName
  5428. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  5429. fed.MedMdtrtType = "1"
  5430. fed.MedinsType = "1"
  5431. fed.MedinsLv = "11"
  5432. tm := time.Unix(his.RecordDate, 0)
  5433. s_tm := tm.Format("2006-01-02 15:04:05")
  5434. fed.AdmDate = s_tm
  5435. fed.DscgDate = s_tm
  5436. fed.DscgMainDiseCodg = config[0].CountryCode
  5437. fed.DscgMainDiseName = config[0].CountryContentName
  5438. //诊断信息
  5439. var fdds []*models.FsiDiagnoseDtos
  5440. for index, item := range config {
  5441. if index == 0 {
  5442. var fdd models.FsiDiagnoseDtos
  5443. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  5444. fdd.InoutDiseType = "1"
  5445. fdd.MaindiseFlag = "1"
  5446. fdd.DiseDate = s_tm
  5447. fdd.DiasSrtNo = "1"
  5448. fdd.DiseName = item.CountryContentName
  5449. fdd.DiseCodg = item.CountryCode
  5450. fdds = append(fdds, &fdd)
  5451. } else {
  5452. var fdd models.FsiDiagnoseDtos
  5453. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  5454. fdd.InoutDiseType = "1"
  5455. fdd.MaindiseFlag = "1"
  5456. fdd.DiseDate = s_tm
  5457. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  5458. fdd.DiseName = item.CountryContentName
  5459. fdd.DiseCodg = item.CountryCode
  5460. fdds = append(fdds, &fdd)
  5461. }
  5462. }
  5463. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  5464. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  5465. fed.AdmDeptName = department.Name
  5466. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  5467. fed.DscgDeptName = department.Name
  5468. fed.MedMdtrtType = "1"
  5469. fed.MedType = "11"
  5470. //if his.Insutype == "390" {
  5471. // fed.MedType = "1402"
  5472. //} else {
  5473. // fed.MedType = "9933"
  5474. //}
  5475. var orders []*models.FsiOrderDtos
  5476. if trig_scen == "2" {
  5477. //处方医嘱信息
  5478. for _, item := range prescriptions {
  5479. for _, subItem := range item.HisDoctorAdviceInfo {
  5480. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  5481. var order models.FsiOrderDtos
  5482. order.RxID = strconv.FormatInt(item.ID, 10)
  5483. order.Rxno = strconv.FormatInt(item.ID, 10)
  5484. order.LongDrordFlag = "0"
  5485. order.HilistType = "1"
  5486. order.ChrgType = "1"
  5487. order.DrordBhvr = "-"
  5488. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  5489. order.HosplistName = subItem.BaseDrugLib.DrugName
  5490. order.HilistLv = "1"
  5491. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  5492. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  5493. order.HosplistName = subItem.BaseDrugLib.DrugName
  5494. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  5495. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  5496. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  5497. order.OwnpayAmt = ""
  5498. order.SelfpayAmt = ""
  5499. order.Spec = ""
  5500. order.SpecUnt = ""
  5501. order.DrordBegnDate = s_tm
  5502. order.DrordStopDate = ""
  5503. order.DrordDrCodg = doctor_info.DoctorNumber
  5504. order.DrordDeptName = department.Name
  5505. order.DrordDeptCodg = department.Number
  5506. order.DrordDrName = doctor_info.UserName
  5507. order.DrordDrProfttl = "234"
  5508. order.CurrDrordFlag = "1"
  5509. orders = append(orders, &order)
  5510. }
  5511. }
  5512. for _, subItem := range item.HisPrescriptionProject {
  5513. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  5514. var order models.FsiOrderDtos
  5515. order.RxID = strconv.FormatInt(item.ID, 10)
  5516. order.Rxno = strconv.FormatInt(item.ID, 10)
  5517. order.LongDrordFlag = "0"
  5518. order.HilistType = "1"
  5519. order.ChrgType = "1"
  5520. order.DrordBhvr = "-"
  5521. order.HilistCode = subItem.HisProject.MedicalCode
  5522. order.HosplistName = subItem.HisProject.ProjectName
  5523. order.HilistLv = "1"
  5524. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  5525. order.HosplistCode = subItem.HisProject.MedicalCode
  5526. order.HosplistName = subItem.HisProject.ProjectName
  5527. order.Cnt = subItem.Count
  5528. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  5529. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  5530. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  5531. order.OwnpayAmt = ""
  5532. order.SelfpayAmt = ""
  5533. order.Spec = ""
  5534. order.SpecUnt = ""
  5535. order.DrordBegnDate = s_tm
  5536. order.DrordStopDate = ""
  5537. order.DrordDrCodg = doctor_info.DoctorNumber
  5538. order.DrordDeptName = department.Name
  5539. order.DrordDeptCodg = department.Number
  5540. order.DrordDrName = doctor_info.UserName
  5541. order.DrordDrProfttl = "234"
  5542. order.CurrDrordFlag = "1"
  5543. orders = append(orders, &order)
  5544. }
  5545. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  5546. var order models.FsiOrderDtos
  5547. order.RxID = strconv.FormatInt(item.ID, 10)
  5548. order.Rxno = strconv.FormatInt(item.ID, 10)
  5549. order.LongDrordFlag = "0"
  5550. order.HilistType = "1"
  5551. order.ChrgType = "1"
  5552. order.DrordBhvr = "-"
  5553. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  5554. order.HosplistName = subItem.GoodInfo.GoodName
  5555. order.HilistLv = "1"
  5556. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  5557. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  5558. order.HosplistName = subItem.GoodInfo.GoodName
  5559. order.Cnt = subItem.Count
  5560. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  5561. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  5562. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  5563. order.OwnpayAmt = ""
  5564. order.SelfpayAmt = ""
  5565. order.Spec = ""
  5566. order.SpecUnt = ""
  5567. order.DrordBegnDate = s_tm
  5568. order.DrordStopDate = ""
  5569. order.DrordDrCodg = doctor_info.DoctorNumber
  5570. order.DrordDeptName = department.Name
  5571. order.DrordDeptCodg = department.Number
  5572. order.DrordDrName = doctor_info.UserName
  5573. order.DrordDrProfttl = "234"
  5574. order.CurrDrordFlag = "1"
  5575. orders = append(orders, &order)
  5576. }
  5577. }
  5578. }
  5579. //处方医嘱信息
  5580. }
  5581. fed.MatnStas = "0"
  5582. fed.MedfeeSumamt = "0"
  5583. fed.OwnpayAmt = "0"
  5584. fed.SelfpayAmt = "0"
  5585. fed.AcctPayamt = "0"
  5586. fed.MaAmt = "0"
  5587. fed.HifpPayamt = "0"
  5588. fed.SetlTotlnum = "1"
  5589. fed.Insutype = his.Insutype
  5590. fed.ReimFlag = "0"
  5591. fed.OutSetlFlag = "0"
  5592. var fopd []*models.FsiOperationDtosData
  5593. data := make(map[string]interface{})
  5594. data["fed"] = fed
  5595. data["fdd"] = fdds
  5596. data["fod"] = orders
  5597. data["pd"] = pd
  5598. data["pp"] = pp
  5599. data["fopd"] = fopd
  5600. data["trig_scen"] = trig_scen
  5601. fmt.Println(data)
  5602. fmt.Println(fed)
  5603. fmt.Println(fdds)
  5604. fmt.Println(orders)
  5605. fmt.Println(pd)
  5606. fmt.Println(pp)
  5607. fmt.Println(fopd)
  5608. client := &http.Client{}
  5609. bytesData, _ := json.Marshal(data)
  5610. var req *http.Request
  5611. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  5612. if miConfig.MdtrtareaAdmvs == "320921" {
  5613. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  5614. } else {
  5615. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  5616. }
  5617. resp, _ := client.Do(req)
  5618. defer resp.Body.Close()
  5619. body, ioErr := ioutil.ReadAll(resp.Body)
  5620. if ioErr != nil {
  5621. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5622. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5623. return res
  5624. }
  5625. var respJSON map[string]interface{}
  5626. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5627. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5628. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5629. return res
  5630. }
  5631. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  5632. fmt.Println(respJSON)
  5633. result, _ := json.Marshal(respJSON)
  5634. fmt.Println(result)
  5635. if err := json.Unmarshal([]byte(result), &res); err != nil {
  5636. utils.ErrorLog("解析失败:%v", err)
  5637. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5638. return res
  5639. }
  5640. return res
  5641. } else {
  5642. output, input := service.Gdyb3101(pd, fed, fdds, orders, fopd, pp, trig_scen)
  5643. saveLog(output, input, "3101", "事前")
  5644. if err := json.Unmarshal([]byte(output), &res); err != nil {
  5645. utils.ErrorLog("解析失败:%v", err)
  5646. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5647. return
  5648. }
  5649. return res
  5650. }
  5651. return res
  5652. }
  5653. func Check3102(c *HisApiController, patient_id int64, his_patient_id int64, admin_user_id int64, trig_scen string, order_id int64) (res Result3101) {
  5654. ////patient_id, _ := c.GetInt64("patient_id")
  5655. //order_id, _ := c.GetInt64("order_id")
  5656. ////his_patient_id, _ := c.GetInt64("his_patient_id")
  5657. ////admin_user_id, _ := c.GetInt64("admin_user_id")
  5658. //trig_scen := c.GetString("trig_scen")
  5659. adminUser := c.GetAdminUserInfo()
  5660. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  5661. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  5662. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  5663. record_time := c.GetString("record_time")
  5664. order, _ := service.GetHisOrderByID(order_id)
  5665. psn_info, _ := service.GetPsnByPatientId(patient_id)
  5666. timeLayout := "2006-01-02"
  5667. loc, _ := time.LoadLocation("Local")
  5668. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  5669. if err != nil {
  5670. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5671. return
  5672. }
  5673. recordDateTime := theTime.Unix()
  5674. var patientPrescription models.HisPrescriptionInfo
  5675. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  5676. if patientPrescription.ID == 0 {
  5677. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  5678. }
  5679. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  5680. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  5681. //
  5682. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  5683. prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  5684. var pp models.PublicParams
  5685. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  5686. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  5687. pp.FixmedinsName = miConfig.OrgName
  5688. pp.FixmedinsCode = miConfig.Code
  5689. pp.RequestUrl = miConfig.Url
  5690. pp.Cainfo = miConfig.Cainfo
  5691. pp.SecretKey = miConfig.SecretKey
  5692. pp.AccessKey = miConfig.AccessKey
  5693. pp.OpterName = roles.UserName
  5694. var config []*models.HisXtDiagnoseConfig
  5695. for _, item := range diagnosis_ids {
  5696. id, _ := strconv.ParseInt(item, 10, 64)
  5697. diagnosisConfig, _ := service.FindDiagnoseById(id)
  5698. config = append(config, &diagnosisConfig)
  5699. }
  5700. var pd models.PatientDtos
  5701. pd.PatnID = his.PsnNo
  5702. pd.PatnName = his.Name
  5703. pd.Gend = his.Gend
  5704. pd.Brdy = psn_info.Brdy
  5705. pd.Poolarea = his.InsuplcAdmdvs
  5706. pd.CurrMdtrtID = his.Number
  5707. var fed models.FsiEncounterDtos
  5708. fed.MdtrtID = his.Number
  5709. fed.MedinsID = miConfig.Code
  5710. fed.MedinsName = miConfig.OrgName
  5711. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  5712. fed.MedMdtrtType = "1"
  5713. fed.MedinsType = "1"
  5714. fed.MedinsLv = "11"
  5715. tm := time.Unix(his.RecordDate, 0)
  5716. s_tm := tm.Format("2006-01-02 15:04:05")
  5717. fed.AdmDate = s_tm
  5718. fed.DscgDate = s_tm
  5719. fed.DscgMainDiseCodg = config[0].CountryCode
  5720. fed.DscgMainDiseName = config[0].CountryContentName
  5721. //诊断信息
  5722. var fdds []*models.FsiDiagnoseDtos
  5723. for index, item := range config {
  5724. if index == 0 {
  5725. var fdd models.FsiDiagnoseDtos
  5726. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  5727. fdd.InoutDiseType = "1"
  5728. fdd.MaindiseFlag = "1"
  5729. fdd.DiseDate = s_tm
  5730. fdd.DiasSrtNo = "1"
  5731. fdd.DiseName = item.CountryContentName
  5732. fdd.DiseCodg = item.CountryCode
  5733. fdds = append(fdds, &fdd)
  5734. } else {
  5735. var fdd models.FsiDiagnoseDtos
  5736. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  5737. fdd.InoutDiseType = "1"
  5738. fdd.MaindiseFlag = "1"
  5739. fdd.DiseDate = s_tm
  5740. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  5741. fdd.DiseName = item.CountryContentName
  5742. fdd.DiseCodg = item.CountryCode
  5743. fdds = append(fdds, &fdd)
  5744. }
  5745. }
  5746. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  5747. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  5748. fed.AdmDeptName = department.Name
  5749. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  5750. fed.DscgDeptName = department.Name
  5751. fed.MedType = order.MedType
  5752. //处方医嘱信息
  5753. var orders []*models.FsiOrderDtos
  5754. //for _, item := range prescriptions {
  5755. // for _, subItem := range item.HisDoctorAdviceInfo {
  5756. // var order models.FsiOrderDtos
  5757. // order.RxID = strconv.FormatInt(item.ID, 10)
  5758. // order.Rxno = strconv.FormatInt(item.ID, 10)
  5759. // order.LongDrordFlag = "0"
  5760. // order.HilistType = "1"
  5761. // order.ChrgType = "1"
  5762. // order.DrordBhvr = "-"
  5763. // order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  5764. // order.HosplistName = subItem.BaseDrugLib.DrugName
  5765. // order.HilistLv = "1"
  5766. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  5767. // order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  5768. // order.HosplistName = subItem.BaseDrugLib.DrugName
  5769. // order.Cnt = strconv.FormatFloat(subItem.PrescribingNumber, 'E', -1, 64)
  5770. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  5771. // order.Sumamt = strconv.FormatFloat((subItem.Price * subItem.PrescribingNumber), 'E', -1, 64)
  5772. // order.OwnpayAmt = ""
  5773. // order.SelfpayAmt = ""
  5774. // order.Spec = ""
  5775. // order.SpecUnt = ""
  5776. // order.DrordBegnDate = s_tm
  5777. // order.DrordStopDate = ""
  5778. // order.DrordDrCodg = "1"
  5779. // order.DrordDeptName = department.Name
  5780. // order.DrordDrCodg = "1"
  5781. // order.DrordDrName = doctor_info.UserName
  5782. // order.DrordDrProfttl = ""
  5783. // order.CurrDrordFlag = "1"
  5784. // orders = append(orders, &order)
  5785. // }
  5786. // for _, subItem := range item.HisPrescriptionProject {
  5787. // if subItem.Type == 2 {
  5788. // var order models.FsiOrderDtos
  5789. // order.RxID = strconv.FormatInt(item.ID, 10)
  5790. // order.Rxno = strconv.FormatInt(item.ID, 10)
  5791. // order.LongDrordFlag = "0"
  5792. // order.HilistType = "1"
  5793. // order.ChrgType = "1"
  5794. // order.DrordBhvr = "-"
  5795. // order.HilistCode = subItem.HisProject.MedicalCode
  5796. // order.HosplistName = subItem.HisProject.ProjectName
  5797. // order.HilistLv = "1"
  5798. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  5799. // order.HosplistCode = subItem.HisProject.MedicalCode
  5800. // order.HosplistName = subItem.HisProject.ProjectName
  5801. // order.Cnt = subItem.Count
  5802. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  5803. //
  5804. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  5805. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  5806. // order.OwnpayAmt = ""
  5807. // order.SelfpayAmt = ""
  5808. // order.Spec = ""
  5809. // order.SpecUnt = ""
  5810. // order.DrordBegnDate = s_tm
  5811. // order.DrordStopDate = ""
  5812. // order.DrordDrCodg = "1"
  5813. // order.DrordDeptName = department.Name
  5814. // order.DrordDrCodg = "1"
  5815. // order.DrordDrName = doctor_info.UserName
  5816. // order.DrordDrProfttl = ""
  5817. // order.CurrDrordFlag = "1"
  5818. // orders = append(orders, &order)
  5819. //
  5820. // }
  5821. // if subItem.Type == 3 {
  5822. //
  5823. // var order models.FsiOrderDtos
  5824. // order.RxID = strconv.FormatInt(item.ID, 10)
  5825. // order.Rxno = strconv.FormatInt(item.ID, 10)
  5826. // order.LongDrordFlag = "0"
  5827. // order.HilistType = "1"
  5828. // order.ChrgType = "1"
  5829. // order.DrordBhvr = "-"
  5830. // order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  5831. // order.HosplistName = subItem.GoodInfo.GoodName
  5832. // order.HilistLv = "1"
  5833. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  5834. // order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  5835. // order.HosplistName = subItem.GoodInfo.GoodName
  5836. // order.Cnt = subItem.Count
  5837. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  5838. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  5839. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  5840. // order.OwnpayAmt = ""
  5841. // order.SelfpayAmt = ""
  5842. // order.Spec = ""
  5843. // order.SpecUnt = ""
  5844. // order.DrordBegnDate = s_tm
  5845. // order.DrordStopDate = ""
  5846. // order.DrordDrCodg = "1"
  5847. // order.DrordDeptName = department.Name
  5848. // order.DrordDrCodg = "1"
  5849. // order.DrordDrName = doctor_info.UserName
  5850. // order.DrordDrProfttl = ""
  5851. // order.CurrDrordFlag = "1"
  5852. // orders = append(orders, &order)
  5853. //
  5854. // }
  5855. // }
  5856. //}
  5857. for _, item := range prescriptions {
  5858. for _, subItem := range item.HisDoctorAdviceInfo {
  5859. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  5860. var order models.FsiOrderDtos
  5861. order.RxID = strconv.FormatInt(item.ID, 10)
  5862. order.Rxno = strconv.FormatInt(item.ID, 10)
  5863. order.LongDrordFlag = "0"
  5864. order.HilistType = "1"
  5865. order.ChrgType = "1"
  5866. order.DrordBhvr = "-"
  5867. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  5868. order.HosplistName = subItem.BaseDrugLib.DrugName
  5869. order.HilistLv = "1"
  5870. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  5871. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  5872. order.HosplistName = subItem.BaseDrugLib.DrugName
  5873. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  5874. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  5875. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  5876. order.OwnpayAmt = ""
  5877. order.SelfpayAmt = ""
  5878. order.Spec = ""
  5879. order.SpecUnt = ""
  5880. order.DrordBegnDate = s_tm
  5881. order.DrordStopDate = ""
  5882. order.DrordDrCodg = doctor_info.DoctorNumber
  5883. order.DrordDeptName = department.Name
  5884. order.DrordDeptCodg = department.Number
  5885. order.DrordDrName = doctor_info.UserName
  5886. order.DrordDrProfttl = "234"
  5887. order.CurrDrordFlag = "1"
  5888. orders = append(orders, &order)
  5889. }
  5890. }
  5891. for _, subItem := range item.HisPrescriptionProject {
  5892. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  5893. var order models.FsiOrderDtos
  5894. order.RxID = strconv.FormatInt(item.ID, 10)
  5895. order.Rxno = strconv.FormatInt(item.ID, 10)
  5896. order.LongDrordFlag = "0"
  5897. order.HilistType = "1"
  5898. order.ChrgType = "1"
  5899. order.DrordBhvr = "-"
  5900. order.HilistCode = subItem.HisProject.MedicalCode
  5901. order.HosplistName = subItem.HisProject.ProjectName
  5902. order.HilistLv = "1"
  5903. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  5904. order.HosplistCode = subItem.HisProject.MedicalCode
  5905. order.HosplistName = subItem.HisProject.ProjectName
  5906. order.Cnt = subItem.Count
  5907. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  5908. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  5909. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  5910. order.OwnpayAmt = ""
  5911. order.SelfpayAmt = ""
  5912. order.Spec = ""
  5913. order.SpecUnt = ""
  5914. order.DrordBegnDate = s_tm
  5915. order.DrordStopDate = ""
  5916. order.DrordDrCodg = doctor_info.DoctorNumber
  5917. order.DrordDeptName = department.Name
  5918. order.DrordDeptCodg = department.Number
  5919. order.DrordDrName = doctor_info.UserName
  5920. order.DrordDrProfttl = "234"
  5921. order.CurrDrordFlag = "1"
  5922. orders = append(orders, &order)
  5923. }
  5924. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  5925. var order models.FsiOrderDtos
  5926. order.RxID = strconv.FormatInt(item.ID, 10)
  5927. order.Rxno = strconv.FormatInt(item.ID, 10)
  5928. order.LongDrordFlag = "0"
  5929. order.HilistType = "1"
  5930. order.ChrgType = "1"
  5931. order.DrordBhvr = "0"
  5932. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  5933. order.HosplistName = subItem.GoodInfo.GoodName
  5934. order.HilistLv = "1"
  5935. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  5936. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  5937. order.HosplistName = subItem.GoodInfo.GoodName
  5938. order.Cnt = subItem.Count
  5939. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  5940. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  5941. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  5942. order.OwnpayAmt = ""
  5943. order.SelfpayAmt = ""
  5944. order.Spec = ""
  5945. order.SpecUnt = ""
  5946. order.DrordBegnDate = s_tm
  5947. order.DrordStopDate = ""
  5948. order.DrordDrCodg = doctor_info.DoctorNumber
  5949. order.DrordDeptName = department.Name
  5950. order.DrordDeptCodg = department.Number
  5951. order.DrordDrName = doctor_info.UserName
  5952. order.DrordDrProfttl = "234"
  5953. order.CurrDrordFlag = "1"
  5954. orders = append(orders, &order)
  5955. }
  5956. }
  5957. }
  5958. //处方医嘱信息
  5959. fed.MatnStas = "0"
  5960. fed.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  5961. fed.OwnpayAmt = fmt.Sprintf("%.2f", order.FulamtOwnpayAmt)
  5962. fed.SelfpayAmt = fmt.Sprintf("%.2f", order.PreselfpayAmt)
  5963. fed.AcctPayamt = fmt.Sprintf("%.2f", order.AcctPay)
  5964. fed.MaAmt = fmt.Sprintf("%.2f", order.MafPay)
  5965. fed.HifpPayamt = fmt.Sprintf("%.2f", order.HifpPay)
  5966. fed.SetlTotlnum = "1"
  5967. fed.Insutype = his.Insutype
  5968. fed.ReimFlag = "0"
  5969. fed.OutSetlFlag = "0"
  5970. var fopd []*models.FsiOperationDtosData
  5971. data := make(map[string]interface{})
  5972. data["fed"] = fed
  5973. data["fdd"] = fdds
  5974. data["fod"] = orders
  5975. data["pd"] = pd
  5976. data["pp"] = pp
  5977. data["fopd"] = fopd
  5978. data["trig_scen"] = trig_scen
  5979. client := &http.Client{}
  5980. bytesData, _ := json.Marshal(data)
  5981. var req *http.Request
  5982. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  5983. if miConfig.MdtrtareaAdmvs == "320921" {
  5984. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  5985. } else {
  5986. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  5987. }
  5988. resp, _ := client.Do(req)
  5989. defer resp.Body.Close()
  5990. body, ioErr := ioutil.ReadAll(resp.Body)
  5991. if ioErr != nil {
  5992. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5993. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5994. return res
  5995. }
  5996. var respJSON map[string]interface{}
  5997. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5998. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5999. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6000. return res
  6001. }
  6002. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  6003. result, _ := json.Marshal(respJSON)
  6004. if err := json.Unmarshal([]byte(result), &res); err != nil {
  6005. utils.ErrorLog("解析失败:%v", err)
  6006. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6007. return res
  6008. }
  6009. return res
  6010. } else {
  6011. output, input := service.Gdyb3102(pd, fed, fdds, orders, fopd, pp, trig_scen)
  6012. saveLog(output, input, "3102", "事中")
  6013. if err := json.Unmarshal([]byte(output), &res); err != nil {
  6014. utils.ErrorLog("解析失败:%v", err)
  6015. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6016. return
  6017. }
  6018. return res
  6019. }
  6020. return res
  6021. }
  6022. 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) {
  6023. var res Resultgd3101
  6024. adminUser := c.GetAdminUserInfo()
  6025. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6026. //his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  6027. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6028. //record_time := c.GetString("record_time")
  6029. //trig_scen := c.GetString("trig_scen")
  6030. psn_info, _ := service.GetPsnByPatientId(patient_id)
  6031. timeLayout := "2006-01-02"
  6032. loc, _ := time.LoadLocation("Local")
  6033. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  6034. if err != nil {
  6035. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6036. return res
  6037. }
  6038. recordDateTime := theTime.Unix()
  6039. var patientPrescription models.HisPrescriptionInfo
  6040. //patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  6041. //if patientPrescription.ID == 0 {
  6042. patientPrescription, _ = service.FindLastPatientPrescriptionInfoTwo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  6043. //}
  6044. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  6045. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  6046. //
  6047. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  6048. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  6049. var pp models.PublicParams
  6050. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  6051. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  6052. pp.FixmedinsName = miConfig.OrgName
  6053. pp.FixmedinsCode = miConfig.Code
  6054. pp.RequestUrl = miConfig.Url
  6055. pp.Cainfo = miConfig.Cainfo
  6056. pp.SecretKey = miConfig.SecretKey
  6057. pp.AccessKey = miConfig.AccessKey
  6058. pp.OpterName = roles.UserName
  6059. var config []*models.HisXtDiagnoseConfig
  6060. for _, item := range diagnosis_ids {
  6061. id, _ := strconv.ParseInt(item, 10, 64)
  6062. diagnosisConfig, _ := service.FindDiagnoseById(id)
  6063. config = append(config, &diagnosisConfig)
  6064. }
  6065. var pd models.PatientDtos
  6066. pd.PatnID = his.PsnNo
  6067. pd.PatnName = his.Name
  6068. pd.Gend = his.Gend
  6069. pd.Brdy = psn_info.Brdy
  6070. pd.Poolarea = miConfig.MdtrtareaAdmvs
  6071. pd.CurrMdtrtID = his.Number
  6072. var fed models.FsiEncounterDtos
  6073. fed.MdtrtID = his.Number
  6074. fed.MedinsID = miConfig.Code
  6075. fed.MedinsName = miConfig.OrgName
  6076. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  6077. fed.MedMdtrtType = "1"
  6078. fed.MedinsType = "1"
  6079. fed.MedinsLv = "11"
  6080. tm := time.Unix(his.RecordDate, 0)
  6081. s_tm := tm.Format("2006-01-02 15:04:05")
  6082. fed.AdmDate = s_tm
  6083. fed.DscgDate = s_tm
  6084. fed.DscgMainDiseCodg = config[0].CountryCode
  6085. fed.DscgMainDiseName = config[0].CountryContentName
  6086. //诊断信息
  6087. var fdds []*models.FsiDiagnoseDtos
  6088. for index, item := range config {
  6089. if index == 0 {
  6090. var fdd models.FsiDiagnoseDtos
  6091. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  6092. fdd.InoutDiseType = "1"
  6093. fdd.MaindiseFlag = "1"
  6094. fdd.DiseDate = s_tm
  6095. fdd.DiasSrtNo = "1"
  6096. fdd.DiseName = item.CountryContentName
  6097. fdd.DiseCodg = item.CountryCode
  6098. fdds = append(fdds, &fdd)
  6099. } else {
  6100. var fdd models.FsiDiagnoseDtos
  6101. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  6102. fdd.InoutDiseType = "1"
  6103. fdd.MaindiseFlag = "1"
  6104. fdd.DiseDate = s_tm
  6105. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  6106. fdd.DiseName = item.CountryContentName
  6107. fdd.DiseCodg = item.CountryCode
  6108. fdds = append(fdds, &fdd)
  6109. }
  6110. }
  6111. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  6112. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  6113. fed.AdmDeptName = department.Name
  6114. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  6115. fed.DscgDeptName = department.Name
  6116. fed.MedMdtrtType = "1"
  6117. fed.MedType = "11"
  6118. //if his.Insutype == "390" {
  6119. // fed.MedType = "1402"
  6120. //} else {
  6121. // fed.MedType = "9933"
  6122. //}
  6123. var orders []*models.FsiOrderDtos
  6124. if trig_scen == "2" {
  6125. //处方医嘱信息
  6126. for _, item := range prescriptions {
  6127. for _, subItem := range item.HisDoctorAdviceInfo {
  6128. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  6129. spec := (subItem.BaseDrugLib.Dose + subItem.BaseDrugLib.DoseUnit) + "*" + strconv.FormatInt(subItem.BaseDrugLib.MinNumber, 10) + subItem.BaseDrugLib.MinUnit + "/" + subItem.BaseDrugLib.MaxUnit
  6130. var order models.FsiOrderDtos
  6131. order.RxID = strconv.FormatInt(item.ID, 10)
  6132. order.Rxno = strconv.FormatInt(item.ID, 10)
  6133. order.LongDrordFlag = "0"
  6134. order.HilistType = "1"
  6135. order.ChrgType = "1"
  6136. order.DrordBhvr = "0"
  6137. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  6138. order.HosplistName = subItem.BaseDrugLib.DrugName
  6139. order.HilistLv = "1"
  6140. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  6141. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  6142. order.HosplistName = subItem.BaseDrugLib.DrugName
  6143. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  6144. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  6145. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  6146. order.OwnpayAmt = ""
  6147. order.SelfpayAmt = ""
  6148. order.Spec = spec
  6149. order.SpecUnt = subItem.PrescribingNumberUnit
  6150. order.DrordBegnDate = s_tm
  6151. order.DrordStopDate = ""
  6152. order.DrordDrCodg = doctor_info.DoctorNumber
  6153. order.DrordDeptName = department.Name
  6154. order.DrordDeptCodg = department.Number
  6155. order.DrordDrName = doctor_info.UserName
  6156. order.DrordDrProfttl = "234"
  6157. order.CurrDrordFlag = "1"
  6158. orders = append(orders, &order)
  6159. }
  6160. }
  6161. for _, subItem := range item.HisPrescriptionProject {
  6162. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  6163. var order models.FsiOrderDtos
  6164. order.RxID = strconv.FormatInt(item.ID, 10)
  6165. order.Rxno = strconv.FormatInt(item.ID, 10)
  6166. order.LongDrordFlag = "0"
  6167. order.HilistType = "1"
  6168. order.ChrgType = "1"
  6169. order.DrordBhvr = "0"
  6170. order.HilistCode = subItem.HisProject.MedicalCode
  6171. order.HosplistName = subItem.HisProject.ProjectName
  6172. order.HilistLv = "1"
  6173. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  6174. order.HosplistCode = subItem.HisProject.MedicalCode
  6175. order.HosplistName = subItem.HisProject.ProjectName
  6176. order.Cnt = subItem.Count
  6177. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  6178. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  6179. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  6180. order.OwnpayAmt = ""
  6181. order.SelfpayAmt = ""
  6182. order.Spec = subItem.Unit
  6183. order.SpecUnt = subItem.Unit
  6184. order.DrordBegnDate = s_tm
  6185. order.DrordStopDate = ""
  6186. order.DrordDrCodg = doctor_info.DoctorNumber
  6187. order.DrordDeptName = department.Name
  6188. order.DrordDeptCodg = department.Number
  6189. order.DrordDrName = doctor_info.UserName
  6190. order.DrordDrProfttl = "234"
  6191. order.CurrDrordFlag = "1"
  6192. orders = append(orders, &order)
  6193. }
  6194. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  6195. var order models.FsiOrderDtos
  6196. order.RxID = strconv.FormatInt(item.ID, 10)
  6197. order.Rxno = strconv.FormatInt(item.ID, 10)
  6198. order.LongDrordFlag = "0"
  6199. order.HilistType = "1"
  6200. order.ChrgType = "1"
  6201. order.DrordBhvr = "0"
  6202. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  6203. order.HosplistName = subItem.GoodInfo.GoodName
  6204. order.HilistLv = "1"
  6205. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  6206. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  6207. order.HosplistName = subItem.GoodInfo.GoodName
  6208. order.Cnt = subItem.Count
  6209. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  6210. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  6211. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  6212. order.OwnpayAmt = ""
  6213. order.SelfpayAmt = ""
  6214. order.Spec = subItem.GoodInfo.SpecificationName
  6215. order.SpecUnt = subItem.Unit
  6216. order.DrordBegnDate = s_tm
  6217. order.DrordStopDate = ""
  6218. order.DrordDrCodg = doctor_info.DoctorNumber
  6219. order.DrordDeptName = department.Name
  6220. order.DrordDeptCodg = department.Number
  6221. order.DrordDrName = doctor_info.UserName
  6222. order.DrordDrProfttl = "234"
  6223. order.CurrDrordFlag = "1"
  6224. orders = append(orders, &order)
  6225. }
  6226. }
  6227. }
  6228. //处方医嘱信息
  6229. }
  6230. fed.MatnStas = "0"
  6231. fed.MedfeeSumamt = "0"
  6232. fed.OwnpayAmt = "0"
  6233. fed.SelfpayAmt = "0"
  6234. fed.AcctPayamt = "0"
  6235. fed.MaAmt = "0"
  6236. fed.HifpPayamt = "0"
  6237. fed.SetlTotlnum = "1"
  6238. fed.Insutype = his.Insutype
  6239. fed.ReimFlag = "0"
  6240. fed.OutSetlFlag = "0"
  6241. var fopd []*models.FsiOperationDtosData
  6242. data := make(map[string]interface{})
  6243. data["fed"] = fed
  6244. data["fdd"] = fdds
  6245. data["fod"] = orders
  6246. data["pd"] = pd
  6247. data["pp"] = pp
  6248. data["fopd"] = fopd
  6249. data["trig_scen"] = trig_scen
  6250. fmt.Println(data)
  6251. fmt.Println(fed)
  6252. fmt.Println(fdds)
  6253. fmt.Println(orders)
  6254. fmt.Println(pd)
  6255. fmt.Println(pp)
  6256. fmt.Println(fopd)
  6257. client := &http.Client{}
  6258. bytesData, _ := json.Marshal(data)
  6259. var req *http.Request
  6260. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  6261. if miConfig.MdtrtareaAdmvs == "320921" {
  6262. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  6263. } else {
  6264. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  6265. }
  6266. resp, _ := client.Do(req)
  6267. defer resp.Body.Close()
  6268. body, ioErr := ioutil.ReadAll(resp.Body)
  6269. if ioErr != nil {
  6270. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6271. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6272. return res
  6273. }
  6274. var respJSON map[string]interface{}
  6275. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6276. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6277. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6278. return res
  6279. }
  6280. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  6281. fmt.Println(respJSON)
  6282. result, _ := json.Marshal(respJSON)
  6283. fmt.Println(result)
  6284. if err := json.Unmarshal([]byte(result), &res); err != nil {
  6285. utils.ErrorLog("解析失败:%v", err)
  6286. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6287. return res
  6288. }
  6289. return res
  6290. } else {
  6291. //if miConfig.MdtrtareaAdmvs == "441202" {
  6292. output, input := service.Gdyb3101(pd, fed, fdds, orders, fopd, pp, trig_scen)
  6293. saveLog(output, input, "3101", "事前")
  6294. if err := json.Unmarshal([]byte(output), &res); err != nil {
  6295. utils.ErrorLog("解析失败:%v", err)
  6296. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6297. return
  6298. }
  6299. return res
  6300. //}
  6301. }
  6302. }
  6303. 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) {
  6304. adminUser := c.GetAdminUserInfo()
  6305. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6306. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  6307. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6308. //record_time := c.GetString("record_time")
  6309. //trig_scen := c.GetString("trig_scen")
  6310. psn_info, _ := service.GetPsnByPatientId(patient_id)
  6311. timeLayout := "2006-01-02"
  6312. loc, _ := time.LoadLocation("Local")
  6313. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  6314. if err != nil {
  6315. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6316. return res
  6317. }
  6318. recordDateTime := theTime.Unix()
  6319. var patientPrescription models.HisPrescriptionInfo
  6320. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  6321. if patientPrescription.ID == 0 {
  6322. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  6323. }
  6324. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  6325. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  6326. //
  6327. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  6328. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  6329. var pp models.PublicParams
  6330. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  6331. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  6332. pp.FixmedinsName = miConfig.OrgName
  6333. pp.FixmedinsCode = miConfig.Code
  6334. pp.RequestUrl = miConfig.Url
  6335. pp.Cainfo = miConfig.Cainfo
  6336. pp.SecretKey = miConfig.SecretKey
  6337. pp.AccessKey = miConfig.AccessKey
  6338. pp.OpterName = roles.UserName
  6339. var config []*models.HisXtDiagnoseConfig
  6340. for _, item := range diagnosis_ids {
  6341. id, _ := strconv.ParseInt(item, 10, 64)
  6342. diagnosisConfig, _ := service.FindDiagnoseById(id)
  6343. config = append(config, &diagnosisConfig)
  6344. }
  6345. var pd models.PatientDtos
  6346. pd.PatnID = his.PsnNo
  6347. pd.PatnName = his.Name
  6348. pd.Gend = his.Gend
  6349. pd.Brdy = psn_info.Brdy
  6350. pd.Poolarea = his.InsuplcAdmdvs
  6351. pd.CurrMdtrtID = his.Number
  6352. var fed models.FsiEncounterDtos
  6353. fed.MdtrtID = his.Number
  6354. fed.MedinsID = miConfig.Code
  6355. fed.MedinsName = miConfig.OrgName
  6356. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  6357. fed.MedMdtrtType = "1"
  6358. fed.MedinsType = "1"
  6359. fed.MedinsLv = "11"
  6360. tm := time.Unix(his.RecordDate, 0)
  6361. s_tm := tm.Format("2006-01-02 15:04:05")
  6362. fed.AdmDate = s_tm
  6363. fed.DscgDate = s_tm
  6364. fed.DscgMainDiseCodg = config[0].CountryCode
  6365. fed.DscgMainDiseName = config[0].CountryContentName
  6366. //诊断信息
  6367. var fdds []*models.FsiDiagnoseDtos
  6368. for index, item := range config {
  6369. if index == 0 {
  6370. var fdd models.FsiDiagnoseDtos
  6371. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  6372. fdd.InoutDiseType = "1"
  6373. fdd.MaindiseFlag = "1"
  6374. fdd.DiseDate = s_tm
  6375. fdd.DiasSrtNo = "1"
  6376. fdd.DiseName = item.CountryContentName
  6377. fdd.DiseCodg = item.CountryCode
  6378. fdds = append(fdds, &fdd)
  6379. } else {
  6380. var fdd models.FsiDiagnoseDtos
  6381. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  6382. fdd.InoutDiseType = "1"
  6383. fdd.MaindiseFlag = "1"
  6384. fdd.DiseDate = s_tm
  6385. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  6386. fdd.DiseName = item.CountryContentName
  6387. fdd.DiseCodg = item.CountryCode
  6388. fdds = append(fdds, &fdd)
  6389. }
  6390. }
  6391. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  6392. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  6393. fed.AdmDeptName = department.Name
  6394. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  6395. fed.DscgDeptName = department.Name
  6396. fed.MedMdtrtType = "1"
  6397. fed.MedType = "11"
  6398. //if his.Insutype == "390" {
  6399. // fed.MedType = "1402"
  6400. //} else {
  6401. // fed.MedType = "9933"
  6402. //}
  6403. var orders []*models.FsiOrderDtos
  6404. if trig_scen == "2" {
  6405. //处方医嘱信息
  6406. for _, item := range prescriptions {
  6407. for _, subItem := range item.HisDoctorAdviceInfo {
  6408. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  6409. spec := (subItem.BaseDrugLib.Dose + subItem.BaseDrugLib.DoseUnit) + "*" + strconv.FormatInt(subItem.BaseDrugLib.MinNumber, 10) + subItem.BaseDrugLib.MinUnit + "/" + subItem.BaseDrugLib.MaxUnit
  6410. var order models.FsiOrderDtos
  6411. order.RxID = strconv.FormatInt(item.ID, 10)
  6412. order.Rxno = strconv.FormatInt(item.ID, 10)
  6413. order.LongDrordFlag = "0"
  6414. order.HilistType = "1"
  6415. order.ChrgType = "1"
  6416. order.DrordBhvr = "0"
  6417. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  6418. order.HosplistName = subItem.BaseDrugLib.DrugName
  6419. order.HilistLv = "1"
  6420. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  6421. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  6422. order.HosplistName = subItem.BaseDrugLib.DrugName
  6423. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  6424. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  6425. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  6426. order.OwnpayAmt = ""
  6427. order.SelfpayAmt = ""
  6428. order.Spec = spec
  6429. order.SpecUnt = subItem.PrescribingNumberUnit
  6430. order.DrordBegnDate = s_tm
  6431. order.DrordStopDate = ""
  6432. order.DrordDrCodg = doctor_info.DoctorNumber
  6433. order.DrordDeptName = department.Name
  6434. order.DrordDeptCodg = department.Number
  6435. order.DrordDrName = doctor_info.UserName
  6436. order.DrordDrProfttl = "234"
  6437. order.CurrDrordFlag = "1"
  6438. orders = append(orders, &order)
  6439. }
  6440. }
  6441. for _, subItem := range item.HisPrescriptionProject {
  6442. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  6443. var order models.FsiOrderDtos
  6444. order.RxID = strconv.FormatInt(item.ID, 10)
  6445. order.Rxno = strconv.FormatInt(item.ID, 10)
  6446. order.LongDrordFlag = "0"
  6447. order.HilistType = "1"
  6448. order.ChrgType = "1"
  6449. order.DrordBhvr = "0"
  6450. order.HilistCode = subItem.HisProject.MedicalCode
  6451. order.HosplistName = subItem.HisProject.ProjectName
  6452. order.HilistLv = "1"
  6453. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  6454. order.HosplistCode = subItem.HisProject.MedicalCode
  6455. order.HosplistName = subItem.HisProject.ProjectName
  6456. order.Cnt = subItem.Count
  6457. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  6458. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  6459. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  6460. order.OwnpayAmt = ""
  6461. order.SelfpayAmt = ""
  6462. order.Spec = subItem.Unit
  6463. order.SpecUnt = subItem.Unit
  6464. order.DrordBegnDate = s_tm
  6465. order.DrordStopDate = ""
  6466. order.DrordDrCodg = doctor_info.DoctorNumber
  6467. order.DrordDeptName = department.Name
  6468. order.DrordDeptCodg = department.Number
  6469. order.DrordDrName = doctor_info.UserName
  6470. order.DrordDrProfttl = "234"
  6471. order.CurrDrordFlag = "1"
  6472. orders = append(orders, &order)
  6473. }
  6474. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  6475. var order models.FsiOrderDtos
  6476. order.RxID = strconv.FormatInt(item.ID, 10)
  6477. order.Rxno = strconv.FormatInt(item.ID, 10)
  6478. order.LongDrordFlag = "0"
  6479. order.HilistType = "1"
  6480. order.ChrgType = "1"
  6481. order.DrordBhvr = "0"
  6482. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  6483. order.HosplistName = subItem.GoodInfo.GoodName
  6484. order.HilistLv = "1"
  6485. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  6486. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  6487. order.HosplistName = subItem.GoodInfo.GoodName
  6488. order.Cnt = subItem.Count
  6489. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  6490. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  6491. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  6492. order.OwnpayAmt = ""
  6493. order.SelfpayAmt = ""
  6494. order.Spec = subItem.GoodInfo.SpecificationName
  6495. order.SpecUnt = subItem.Unit
  6496. order.DrordBegnDate = s_tm
  6497. order.DrordStopDate = ""
  6498. order.DrordDrCodg = doctor_info.DoctorNumber
  6499. order.DrordDeptName = department.Name
  6500. order.DrordDeptCodg = department.Number
  6501. order.DrordDrName = doctor_info.UserName
  6502. order.DrordDrProfttl = "234"
  6503. order.CurrDrordFlag = "1"
  6504. orders = append(orders, &order)
  6505. }
  6506. }
  6507. }
  6508. //处方医嘱信息
  6509. }
  6510. fed.MatnStas = "0"
  6511. fed.MedfeeSumamt = "0"
  6512. fed.OwnpayAmt = "0"
  6513. fed.SelfpayAmt = "0"
  6514. fed.AcctPayamt = "0"
  6515. fed.MaAmt = "0"
  6516. fed.HifpPayamt = "0"
  6517. fed.SetlTotlnum = "1"
  6518. fed.Insutype = his.Insutype
  6519. fed.ReimFlag = "0"
  6520. fed.OutSetlFlag = "0"
  6521. var fopd []*models.FsiOperationDtosData
  6522. data := make(map[string]interface{})
  6523. data["fed"] = fed
  6524. data["fdd"] = fdds
  6525. data["fod"] = orders
  6526. data["pd"] = pd
  6527. data["pp"] = pp
  6528. data["fopd"] = fopd
  6529. data["trig_scen"] = trig_scen
  6530. fmt.Println(data)
  6531. fmt.Println(fed)
  6532. fmt.Println(fdds)
  6533. fmt.Println(orders)
  6534. fmt.Println(pd)
  6535. fmt.Println(pp)
  6536. fmt.Println(fopd)
  6537. client := &http.Client{}
  6538. bytesData, _ := json.Marshal(data)
  6539. var req *http.Request
  6540. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  6541. if miConfig.MdtrtareaAdmvs == "320921" {
  6542. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  6543. } else {
  6544. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  6545. }
  6546. resp, _ := client.Do(req)
  6547. defer resp.Body.Close()
  6548. body, ioErr := ioutil.ReadAll(resp.Body)
  6549. if ioErr != nil {
  6550. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6551. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6552. return res
  6553. }
  6554. var respJSON map[string]interface{}
  6555. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6556. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6557. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6558. return res
  6559. }
  6560. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  6561. fmt.Println(respJSON)
  6562. result, _ := json.Marshal(respJSON)
  6563. fmt.Println(result)
  6564. if err := json.Unmarshal([]byte(result), &res); err != nil {
  6565. utils.ErrorLog("解析失败:%v", err)
  6566. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6567. return res
  6568. }
  6569. return res
  6570. } else {
  6571. output, input := service.Gdyb3101(pd, fed, fdds, orders, fopd, pp, trig_scen)
  6572. saveLog(output, input, "3101", "事前")
  6573. if err := json.Unmarshal([]byte(output), &res); err != nil {
  6574. utils.ErrorLog("解析失败:%v", err)
  6575. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6576. return
  6577. }
  6578. return res
  6579. }
  6580. return res
  6581. }
  6582. func Checkgd3102(c *HisApiController, patient_id int64, his_patient_id int64, admin_user_id int64, trig_scen string, order_id int64) (res Resultgd3101) {
  6583. ////patient_id, _ := c.GetInt64("patient_id")
  6584. //order_id, _ := c.GetInt64("order_id")
  6585. ////his_patient_id, _ := c.GetInt64("his_patient_id")
  6586. ////admin_user_id, _ := c.GetInt64("admin_user_id")
  6587. //trig_scen := c.GetString("trig_scen")
  6588. psn_info, _ := service.GetPsnByPatientId(patient_id)
  6589. utils.ErrorLog("解析失败:%v", psn_info)
  6590. adminUser := c.GetAdminUserInfo()
  6591. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6592. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  6593. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6594. record_time := c.GetString("record_time")
  6595. order, _ := service.GetHisOrderByID(order_id)
  6596. timeLayout := "2006-01-02"
  6597. loc, _ := time.LoadLocation("Local")
  6598. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  6599. if err != nil {
  6600. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6601. return
  6602. }
  6603. recordDateTime := theTime.Unix()
  6604. var patientPrescription models.HisPrescriptionInfo
  6605. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  6606. if patientPrescription.ID == 0 {
  6607. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  6608. }
  6609. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  6610. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  6611. //
  6612. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  6613. prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  6614. var pp models.PublicParams
  6615. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  6616. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  6617. pp.FixmedinsName = miConfig.OrgName
  6618. pp.FixmedinsCode = miConfig.Code
  6619. pp.RequestUrl = miConfig.Url
  6620. pp.Cainfo = miConfig.Cainfo
  6621. pp.SecretKey = miConfig.SecretKey
  6622. pp.AccessKey = miConfig.AccessKey
  6623. pp.OpterName = roles.UserName
  6624. var config []*models.HisXtDiagnoseConfig
  6625. for _, item := range diagnosis_ids {
  6626. id, _ := strconv.ParseInt(item, 10, 64)
  6627. diagnosisConfig, _ := service.FindDiagnoseById(id)
  6628. config = append(config, &diagnosisConfig)
  6629. }
  6630. var pd models.PatientDtos
  6631. pd.PatnID = his.PsnNo
  6632. pd.PatnName = his.Name
  6633. pd.Gend = his.Gend
  6634. pd.Brdy = psn_info.Brdy
  6635. pd.Poolarea = his.InsuplcAdmdvs
  6636. pd.CurrMdtrtID = his.Number
  6637. var fed models.FsiEncounterDtos
  6638. fed.MdtrtID = his.Number
  6639. fed.MedinsID = miConfig.Code
  6640. fed.MedinsName = miConfig.OrgName
  6641. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  6642. fed.MedMdtrtType = "1"
  6643. fed.MedinsType = "1"
  6644. fed.MedinsLv = "11"
  6645. tm := time.Unix(his.RecordDate, 0)
  6646. s_tm := tm.Format("2006-01-02 15:04:05")
  6647. fed.AdmDate = s_tm
  6648. fed.DscgDate = s_tm
  6649. fed.DscgMainDiseCodg = config[0].CountryCode
  6650. fed.DscgMainDiseName = config[0].CountryContentName
  6651. //诊断信息
  6652. var fdds []*models.FsiDiagnoseDtos
  6653. for index, item := range config {
  6654. if index == 0 {
  6655. var fdd models.FsiDiagnoseDtos
  6656. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  6657. fdd.InoutDiseType = "1"
  6658. fdd.MaindiseFlag = "1"
  6659. fdd.DiseDate = s_tm
  6660. fdd.DiasSrtNo = "1"
  6661. fdd.DiseName = item.CountryContentName
  6662. fdd.DiseCodg = item.CountryCode
  6663. fdds = append(fdds, &fdd)
  6664. } else {
  6665. var fdd models.FsiDiagnoseDtos
  6666. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  6667. fdd.InoutDiseType = "1"
  6668. fdd.MaindiseFlag = "1"
  6669. fdd.DiseDate = s_tm
  6670. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  6671. fdd.DiseName = item.CountryContentName
  6672. fdd.DiseCodg = item.CountryCode
  6673. fdds = append(fdds, &fdd)
  6674. }
  6675. }
  6676. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  6677. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  6678. fed.AdmDeptName = department.Name
  6679. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  6680. fed.DscgDeptName = department.Name
  6681. fed.MedType = order.MedType
  6682. //处方医嘱信息
  6683. var orders []*models.FsiOrderDtos
  6684. //for _, item := range prescriptions {
  6685. // for _, subItem := range item.HisDoctorAdviceInfo {
  6686. // var order models.FsiOrderDtos
  6687. // order.RxID = strconv.FormatInt(item.ID, 10)
  6688. // order.Rxno = strconv.FormatInt(item.ID, 10)
  6689. // order.LongDrordFlag = "0"
  6690. // order.HilistType = "1"
  6691. // order.ChrgType = "1"
  6692. // order.DrordBhvr = "-"
  6693. // order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  6694. // order.HosplistName = subItem.BaseDrugLib.DrugName
  6695. // order.HilistLv = "1"
  6696. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  6697. // order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  6698. // order.HosplistName = subItem.BaseDrugLib.DrugName
  6699. // order.Cnt = strconv.FormatFloat(subItem.PrescribingNumber, 'E', -1, 64)
  6700. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  6701. // order.Sumamt = strconv.FormatFloat((subItem.Price * subItem.PrescribingNumber), 'E', -1, 64)
  6702. // order.OwnpayAmt = ""
  6703. // order.SelfpayAmt = ""
  6704. // order.Spec = ""
  6705. // order.SpecUnt = ""
  6706. // order.DrordBegnDate = s_tm
  6707. // order.DrordStopDate = ""
  6708. // order.DrordDrCodg = "1"
  6709. // order.DrordDeptName = department.Name
  6710. // order.DrordDrCodg = "1"
  6711. // order.DrordDrName = doctor_info.UserName
  6712. // order.DrordDrProfttl = ""
  6713. // order.CurrDrordFlag = "1"
  6714. // orders = append(orders, &order)
  6715. // }
  6716. // for _, subItem := range item.HisPrescriptionProject {
  6717. // if subItem.Type == 2 {
  6718. // var order models.FsiOrderDtos
  6719. // order.RxID = strconv.FormatInt(item.ID, 10)
  6720. // order.Rxno = strconv.FormatInt(item.ID, 10)
  6721. // order.LongDrordFlag = "0"
  6722. // order.HilistType = "1"
  6723. // order.ChrgType = "1"
  6724. // order.DrordBhvr = "-"
  6725. // order.HilistCode = subItem.HisProject.MedicalCode
  6726. // order.HosplistName = subItem.HisProject.ProjectName
  6727. // order.HilistLv = "1"
  6728. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  6729. // order.HosplistCode = subItem.HisProject.MedicalCode
  6730. // order.HosplistName = subItem.HisProject.ProjectName
  6731. // order.Cnt = subItem.Count
  6732. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  6733. //
  6734. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  6735. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  6736. // order.OwnpayAmt = ""
  6737. // order.SelfpayAmt = ""
  6738. // order.Spec = ""
  6739. // order.SpecUnt = ""
  6740. // order.DrordBegnDate = s_tm
  6741. // order.DrordStopDate = ""
  6742. // order.DrordDrCodg = "1"
  6743. // order.DrordDeptName = department.Name
  6744. // order.DrordDrCodg = "1"
  6745. // order.DrordDrName = doctor_info.UserName
  6746. // order.DrordDrProfttl = ""
  6747. // order.CurrDrordFlag = "1"
  6748. // orders = append(orders, &order)
  6749. //
  6750. // }
  6751. // if subItem.Type == 3 {
  6752. //
  6753. // var order models.FsiOrderDtos
  6754. // order.RxID = strconv.FormatInt(item.ID, 10)
  6755. // order.Rxno = strconv.FormatInt(item.ID, 10)
  6756. // order.LongDrordFlag = "0"
  6757. // order.HilistType = "1"
  6758. // order.ChrgType = "1"
  6759. // order.DrordBhvr = "-"
  6760. // order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  6761. // order.HosplistName = subItem.GoodInfo.GoodName
  6762. // order.HilistLv = "1"
  6763. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  6764. // order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  6765. // order.HosplistName = subItem.GoodInfo.GoodName
  6766. // order.Cnt = subItem.Count
  6767. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  6768. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  6769. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  6770. // order.OwnpayAmt = ""
  6771. // order.SelfpayAmt = ""
  6772. // order.Spec = ""
  6773. // order.SpecUnt = ""
  6774. // order.DrordBegnDate = s_tm
  6775. // order.DrordStopDate = ""
  6776. // order.DrordDrCodg = "1"
  6777. // order.DrordDeptName = department.Name
  6778. // order.DrordDrCodg = "1"
  6779. // order.DrordDrName = doctor_info.UserName
  6780. // order.DrordDrProfttl = ""
  6781. // order.CurrDrordFlag = "1"
  6782. // orders = append(orders, &order)
  6783. //
  6784. // }
  6785. // }
  6786. //}
  6787. for _, item := range prescriptions {
  6788. for _, subItem := range item.HisDoctorAdviceInfo {
  6789. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  6790. spec := (subItem.BaseDrugLib.Dose + subItem.BaseDrugLib.DoseUnit) + "*" + strconv.FormatInt(subItem.BaseDrugLib.MinNumber, 10) + subItem.BaseDrugLib.MinUnit + "/" + subItem.BaseDrugLib.MaxUnit
  6791. var order models.FsiOrderDtos
  6792. order.RxID = strconv.FormatInt(item.ID, 10)
  6793. order.Rxno = strconv.FormatInt(item.ID, 10)
  6794. order.LongDrordFlag = "0"
  6795. order.HilistType = "1"
  6796. order.ChrgType = "1"
  6797. order.DrordBhvr = "0"
  6798. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  6799. order.HosplistName = subItem.BaseDrugLib.DrugName
  6800. order.HilistLv = "1"
  6801. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  6802. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  6803. order.HosplistName = subItem.BaseDrugLib.DrugName
  6804. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  6805. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  6806. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  6807. order.OwnpayAmt = ""
  6808. order.SelfpayAmt = ""
  6809. order.Spec = spec
  6810. order.SpecUnt = subItem.PrescribingNumberUnit
  6811. order.DrordBegnDate = s_tm
  6812. order.DrordStopDate = ""
  6813. order.DrordDrCodg = doctor_info.DoctorNumber
  6814. order.DrordDeptName = department.Name
  6815. order.DrordDeptCodg = department.Number
  6816. order.DrordDrName = doctor_info.UserName
  6817. order.DrordDrProfttl = "234"
  6818. order.CurrDrordFlag = "1"
  6819. orders = append(orders, &order)
  6820. }
  6821. }
  6822. for _, subItem := range item.HisPrescriptionProject {
  6823. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  6824. var order models.FsiOrderDtos
  6825. order.RxID = strconv.FormatInt(item.ID, 10)
  6826. order.Rxno = strconv.FormatInt(item.ID, 10)
  6827. order.LongDrordFlag = "0"
  6828. order.HilistType = "1"
  6829. order.ChrgType = "1"
  6830. order.DrordBhvr = "0"
  6831. order.HilistCode = subItem.HisProject.MedicalCode
  6832. order.HosplistName = subItem.HisProject.ProjectName
  6833. order.HilistLv = "1"
  6834. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  6835. order.HosplistCode = subItem.HisProject.MedicalCode
  6836. order.HosplistName = subItem.HisProject.ProjectName
  6837. order.Cnt = subItem.Count
  6838. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  6839. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  6840. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  6841. order.OwnpayAmt = ""
  6842. order.SelfpayAmt = ""
  6843. order.Spec = subItem.Unit
  6844. order.SpecUnt = subItem.Unit
  6845. order.DrordBegnDate = s_tm
  6846. order.DrordStopDate = ""
  6847. order.DrordDrCodg = doctor_info.DoctorNumber
  6848. order.DrordDeptName = department.Name
  6849. order.DrordDeptCodg = department.Number
  6850. order.DrordDrName = doctor_info.UserName
  6851. order.DrordDrProfttl = "234"
  6852. order.CurrDrordFlag = "1"
  6853. orders = append(orders, &order)
  6854. }
  6855. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  6856. var order models.FsiOrderDtos
  6857. order.RxID = strconv.FormatInt(item.ID, 10)
  6858. order.Rxno = strconv.FormatInt(item.ID, 10)
  6859. order.LongDrordFlag = "0"
  6860. order.HilistType = "1"
  6861. order.ChrgType = "1"
  6862. order.DrordBhvr = "0"
  6863. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  6864. order.HosplistName = subItem.GoodInfo.GoodName
  6865. order.HilistLv = "1"
  6866. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  6867. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  6868. order.HosplistName = subItem.GoodInfo.GoodName
  6869. order.Cnt = subItem.Count
  6870. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  6871. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  6872. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  6873. order.OwnpayAmt = ""
  6874. order.SelfpayAmt = ""
  6875. order.Spec = subItem.GoodInfo.SpecificationName
  6876. order.SpecUnt = subItem.Unit
  6877. order.DrordBegnDate = s_tm
  6878. order.DrordStopDate = ""
  6879. order.DrordDrCodg = doctor_info.DoctorNumber
  6880. order.DrordDeptName = department.Name
  6881. order.DrordDeptCodg = department.Number
  6882. order.DrordDrName = doctor_info.UserName
  6883. order.DrordDrProfttl = "234"
  6884. order.CurrDrordFlag = "1"
  6885. orders = append(orders, &order)
  6886. }
  6887. }
  6888. }
  6889. //处方医嘱信息
  6890. fed.MatnStas = "0"
  6891. fed.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  6892. fed.OwnpayAmt = fmt.Sprintf("%.2f", order.FulamtOwnpayAmt)
  6893. fed.SelfpayAmt = fmt.Sprintf("%.2f", order.PreselfpayAmt)
  6894. fed.AcctPayamt = fmt.Sprintf("%.2f", order.AcctPay)
  6895. fed.MaAmt = fmt.Sprintf("%.2f", order.MafPay)
  6896. fed.HifpPayamt = fmt.Sprintf("%.2f", order.HifpPay)
  6897. fed.SetlTotlnum = "1"
  6898. fed.Insutype = his.Insutype
  6899. fed.ReimFlag = "0"
  6900. fed.OutSetlFlag = "0"
  6901. var fopd []*models.FsiOperationDtosData
  6902. data := make(map[string]interface{})
  6903. data["fed"] = fed
  6904. data["fdd"] = fdds
  6905. data["fod"] = orders
  6906. data["pd"] = pd
  6907. data["pp"] = pp
  6908. data["fopd"] = fopd
  6909. data["trig_scen"] = trig_scen
  6910. client := &http.Client{}
  6911. bytesData, _ := json.Marshal(data)
  6912. var req *http.Request
  6913. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  6914. if miConfig.MdtrtareaAdmvs == "320921" {
  6915. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  6916. } else {
  6917. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  6918. }
  6919. resp, _ := client.Do(req)
  6920. defer resp.Body.Close()
  6921. body, ioErr := ioutil.ReadAll(resp.Body)
  6922. if ioErr != nil {
  6923. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6924. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6925. return res
  6926. }
  6927. var respJSON map[string]interface{}
  6928. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6929. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6930. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6931. return res
  6932. }
  6933. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  6934. result, _ := json.Marshal(respJSON)
  6935. if err := json.Unmarshal([]byte(result), &res); err != nil {
  6936. utils.ErrorLog("解析失败:%v", err)
  6937. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6938. return res
  6939. }
  6940. return res
  6941. } else {
  6942. output, input := service.Gdyb3102(pd, fed, fdds, orders, fopd, pp, trig_scen)
  6943. saveLog(output, input, "3102", "事中")
  6944. if err := json.Unmarshal([]byte(output), &res); err != nil {
  6945. utils.ErrorLog("解析失败:%v", err)
  6946. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6947. return
  6948. }
  6949. return res
  6950. }
  6951. return res
  6952. }
  6953. func (c *HisApiController) Check() {
  6954. psn_no := c.GetString("psn_no")
  6955. in := c.GetString("in")
  6956. mt := c.GetString("mt")
  6957. baseParams := models.BaseParams{
  6958. SecretKey: "MSDBYGxXm1Mtyi3PtOUB7n1ktcxwyW57",
  6959. FixmedinsCode: "H15049901371",
  6960. InsuplcAdmdvs: "150499",
  6961. MdtrtareaAdmvs: "150499",
  6962. OrgName: "赤峰费森血液透析中心",
  6963. Doctor: "1111",
  6964. }
  6965. service.Gdyb2001(baseParams, psn_no, in, mt)
  6966. }
  6967. func (c *HisApiController) GetPsnNcdsInfo() {
  6968. admin_user_id, _ := c.GetInt64("admin_user_id")
  6969. patient_id, _ := c.GetInt64("patient_id")
  6970. //id, _ := c.GetInt64("id")
  6971. adminUser := c.GetAdminUserInfo()
  6972. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6973. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  6974. //patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  6975. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6976. //psn_record, _ := service.GetP(id)
  6977. psn_info, _ := service.GetPsnByPatientId(patient_id)
  6978. //psn_record, _ := service.GetPsnNCDSRecordById(id)
  6979. //
  6980. //if psn_record.ID == 0 {
  6981. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  6982. // return
  6983. //}
  6984. var res Result5301
  6985. var res10265 Result5301For10265
  6986. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  6987. psn_info, _ := service.GetPsnByPatientId(patient_id)
  6988. var api string
  6989. if miConfig.MdtrtareaAdmvs == "320921" {
  6990. 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 +
  6991. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  6992. } else {
  6993. 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 +
  6994. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  6995. }
  6996. resp, requestErr := http.Get(api)
  6997. if requestErr != nil {
  6998. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6999. return
  7000. }
  7001. body, ioErr := ioutil.ReadAll(resp.Body)
  7002. if ioErr != nil {
  7003. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7004. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7005. return
  7006. }
  7007. var respJSON map[string]interface{}
  7008. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7009. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7010. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7011. return
  7012. }
  7013. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7014. result, _ := json.Marshal(respJSON)
  7015. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  7016. utils.ErrorLog("解析失败:%v", err)
  7017. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7018. return
  7019. }
  7020. res.ErrMsg = res10265.ErrMsg
  7021. res.Output = res10265.Output
  7022. res.InfRefmsgid = res10265.InfRefmsgid
  7023. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  7024. res.Infcode = infocode
  7025. } else if miConfig.MdtrtareaAdmvs == "341203" {
  7026. psn_info, _ := service.GetPsnByPatientId(patient_id)
  7027. var api string
  7028. api = miConfig.SecretKey + "ahyb/5301?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName +
  7029. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  7030. resp, requestErr := http.Get(api)
  7031. if requestErr != nil {
  7032. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7033. return
  7034. }
  7035. body, ioErr := ioutil.ReadAll(resp.Body)
  7036. if ioErr != nil {
  7037. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7038. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7039. return
  7040. }
  7041. var respJSON map[string]interface{}
  7042. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7043. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7044. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7045. return
  7046. }
  7047. status := respJSON["data"].(map[string]interface{})["status"].(string)
  7048. if status == "0" {
  7049. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  7050. c.ServeSuccessJSON(map[string]interface{}{
  7051. "failed_code": -10,
  7052. "msg": err_msg,
  7053. })
  7054. return
  7055. }
  7056. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7057. result, _ := json.Marshal(respJSON)
  7058. if err := json.Unmarshal([]byte(result), &res); err != nil {
  7059. utils.ErrorLog("解析失败:%v", err)
  7060. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7061. return
  7062. }
  7063. } else if miConfig.MdtrtareaAdmvs == "360302" {
  7064. p, _ := service.GetHisPatientById(patient_id)
  7065. result, _ := service.Jxyb5301(p.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, "")
  7066. var dat map[string]interface{}
  7067. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7068. fmt.Println(dat)
  7069. } else {
  7070. fmt.Println(err)
  7071. }
  7072. userJSONBytes, _ := json.Marshal(dat)
  7073. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7074. utils.ErrorLog("解析失败:%v", err)
  7075. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7076. return
  7077. }
  7078. } else if miConfig.MdtrtareaAdmvs == "430800" {
  7079. p, _ := service.GetHisPatientById(patient_id)
  7080. result, _ := service.Hnyb5301(p.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, "")
  7081. var dat map[string]interface{}
  7082. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7083. fmt.Println(dat)
  7084. } else {
  7085. fmt.Println(err)
  7086. }
  7087. userJSONBytes, _ := json.Marshal(dat)
  7088. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7089. utils.ErrorLog("解析失败:%v", err)
  7090. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7091. return
  7092. }
  7093. } else if miConfig.MdtrtareaAdmvs == "420200" {
  7094. p, _ := service.GetHisPatientById(patient_id)
  7095. api := "http://192.168.0.197:9532/" + "/hbyb/5301?psn_no=" + p.PsnNo +
  7096. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  7097. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  7098. resp, requestErr := http.Get(api)
  7099. if requestErr != nil {
  7100. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7101. return
  7102. }
  7103. body, ioErr := ioutil.ReadAll(resp.Body)
  7104. if ioErr != nil {
  7105. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7106. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7107. return
  7108. }
  7109. var respJSON map[string]interface{}
  7110. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7111. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7112. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7113. return
  7114. }
  7115. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7116. result, _ := json.Marshal(respJSON)
  7117. if err := json.Unmarshal([]byte(result), &res); err != nil {
  7118. utils.ErrorLog("解析失败:%v", err)
  7119. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7120. return
  7121. }
  7122. } else if miConfig.MdtrtareaAdmvs == "420902" {
  7123. p, _ := service.GetHisPatientById(patient_id)
  7124. api := miConfig.Url + "hbyb/5301?psn_no=" + p.PsnNo +
  7125. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  7126. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  7127. resp, requestErr := http.Get(api)
  7128. if requestErr != nil {
  7129. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7130. return
  7131. }
  7132. body, ioErr := ioutil.ReadAll(resp.Body)
  7133. if ioErr != nil {
  7134. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7135. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7136. return
  7137. }
  7138. var respJSON map[string]interface{}
  7139. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7140. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7141. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7142. return
  7143. }
  7144. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7145. result, _ := json.Marshal(respJSON)
  7146. if err := json.Unmarshal([]byte(result), &res); err != nil {
  7147. utils.ErrorLog("解析失败:%v", err)
  7148. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7149. return
  7150. }
  7151. } else if miConfig.MdtrtareaAdmvs == "421182" {
  7152. p, _ := service.GetHisPatientById(patient_id)
  7153. api := miConfig.Url + "/hbyb/5301?psn_no=" + p.PsnNo +
  7154. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  7155. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  7156. resp, requestErr := http.Get(api)
  7157. if requestErr != nil {
  7158. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7159. return
  7160. }
  7161. body, ioErr := ioutil.ReadAll(resp.Body)
  7162. if ioErr != nil {
  7163. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7164. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7165. return
  7166. }
  7167. var respJSON map[string]interface{}
  7168. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7169. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7170. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7171. return
  7172. }
  7173. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7174. result, _ := json.Marshal(respJSON)
  7175. if err := json.Unmarshal([]byte(result), &res); err != nil {
  7176. utils.ErrorLog("解析失败:%v", err)
  7177. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7178. return
  7179. }
  7180. } else if miConfig.MdtrtareaAdmvs == "420902" {
  7181. p, _ := service.GetHisPatientById(patient_id)
  7182. api := miConfig.Url + "/hbyb/5301?psn_no=" + p.PsnNo +
  7183. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  7184. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  7185. resp, requestErr := http.Get(api)
  7186. if requestErr != nil {
  7187. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7188. return
  7189. }
  7190. body, ioErr := ioutil.ReadAll(resp.Body)
  7191. if ioErr != nil {
  7192. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7193. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7194. return
  7195. }
  7196. var respJSON map[string]interface{}
  7197. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7198. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7199. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7200. return
  7201. }
  7202. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7203. result, _ := json.Marshal(respJSON)
  7204. if err := json.Unmarshal([]byte(result), &res); err != nil {
  7205. utils.ErrorLog("解析失败:%v", err)
  7206. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7207. return
  7208. }
  7209. } else if miConfig.MdtrtareaAdmvs == "421300" {
  7210. p, _ := service.GetHisPatientById(patient_id)
  7211. api := "http://192.168.124.4:9532/" + "/hbyb/5301?psn_no=" + p.PsnNo +
  7212. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  7213. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  7214. resp, requestErr := http.Get(api)
  7215. if requestErr != nil {
  7216. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7217. return
  7218. }
  7219. body, ioErr := ioutil.ReadAll(resp.Body)
  7220. if ioErr != nil {
  7221. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7222. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7223. return
  7224. }
  7225. var respJSON map[string]interface{}
  7226. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7227. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7228. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7229. return
  7230. }
  7231. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7232. result, _ := json.Marshal(respJSON)
  7233. if err := json.Unmarshal([]byte(result), &res); err != nil {
  7234. utils.ErrorLog("解析失败:%v", err)
  7235. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7236. return
  7237. }
  7238. } else if miConfig.MdtrtareaAdmvs == "441799" {
  7239. p, _ := service.GetHisPatientById(patient_id)
  7240. api := miConfig.Url + "gdyb/5301?psn_no=" + p.PsnNo +
  7241. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  7242. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  7243. resp, requestErr := http.Get(api)
  7244. if requestErr != nil {
  7245. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7246. return
  7247. }
  7248. body, ioErr := ioutil.ReadAll(resp.Body)
  7249. if ioErr != nil {
  7250. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7251. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7252. return
  7253. }
  7254. var respJSON map[string]interface{}
  7255. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7256. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7257. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7258. return
  7259. }
  7260. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7261. result, _ := json.Marshal(respJSON)
  7262. if err := json.Unmarshal([]byte(result), &res); err != nil {
  7263. utils.ErrorLog("解析失败:%v", err)
  7264. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7265. return
  7266. }
  7267. } else {
  7268. result := service.Gdyb5301(psn_info.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  7269. var dat map[string]interface{}
  7270. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7271. fmt.Println(dat)
  7272. } else {
  7273. fmt.Println(err)
  7274. }
  7275. userJSONBytes, _ := json.Marshal(dat)
  7276. if miConfig.Code == "H15049901371" {
  7277. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  7278. utils.ErrorLog("解析失败:%v", err)
  7279. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7280. return
  7281. }
  7282. res.InfRefmsgid = res10265.InfRefmsgid
  7283. res.Output = res10265.Output
  7284. res.ErrMsg = res10265.ErrMsg
  7285. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  7286. res.Infcode = infocode
  7287. } else {
  7288. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7289. utils.ErrorLog("解析失败:%v", err)
  7290. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7291. return
  7292. }
  7293. }
  7294. }
  7295. if res.Infcode == 0 {
  7296. c.ServeSuccessJSON(map[string]interface{}{
  7297. "result": res.Output.Result,
  7298. })
  7299. }
  7300. }
  7301. func (c *HisApiController) CheckInsutype() {
  7302. his_patient_id, _ := c.GetInt64("his_patient_id")
  7303. admin_user_id, _ := c.GetInt64("admin_user_id")
  7304. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7305. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  7306. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7307. result := service.Gdyb90100(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  7308. var dat map[string]interface{}
  7309. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7310. fmt.Println(dat)
  7311. } else {
  7312. fmt.Println(err)
  7313. }
  7314. userJSONBytes, _ := json.Marshal(dat)
  7315. var res Result90100
  7316. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7317. utils.ErrorLog("解析失败:%v", err)
  7318. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7319. return
  7320. }
  7321. if res.Infcode != 0 {
  7322. c.ServeSuccessJSON(map[string]interface{}{
  7323. "failed_code": -10,
  7324. "msg": res.ErrMsg,
  7325. })
  7326. return
  7327. } else {
  7328. fmt.Println(res)
  7329. }
  7330. }
  7331. func (c *HisApiController) CheckCardPWD() {
  7332. card_pwd := c.GetString("card_pwd")
  7333. his_patient_id, _ := c.GetInt64("his_patient_id")
  7334. admin_user_id, _ := c.GetInt64("admin_user_id")
  7335. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7336. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7337. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  7338. psn, _ := service.GetPsnByPatientId(his.PatientId)
  7339. bas := strings.Split(psn.CardInfo, "|")
  7340. basNumber := bas[2]
  7341. if psn.InsuplcAdmdvs[:4] == "4403" {
  7342. result := service.Gdyb90991(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, card_pwd, basNumber)
  7343. var dat map[string]interface{}
  7344. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7345. fmt.Println(dat)
  7346. } else {
  7347. fmt.Println(err)
  7348. }
  7349. userJSONBytes, _ := json.Marshal(dat)
  7350. var res Result90991
  7351. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7352. utils.ErrorLog("解析失败:%v", err)
  7353. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7354. return
  7355. }
  7356. if res.Infcode != 0 {
  7357. c.ServeSuccessJSON(map[string]interface{}{
  7358. "failed_code": -10,
  7359. "msg": res.ErrMsg,
  7360. })
  7361. return
  7362. } else {
  7363. if res.Output.Result.SscnoCheckStat == "0" && res.Output.Result.CardStat != "10" {
  7364. var msg string
  7365. switch res.Output.Result.CardStat {
  7366. case "00":
  7367. msg = "未激活"
  7368. break
  7369. case "10":
  7370. msg = "激活"
  7371. break
  7372. case "20":
  7373. msg = "窗口挂失"
  7374. break
  7375. case "21":
  7376. msg = "电话挂失"
  7377. break
  7378. case "22":
  7379. msg = "单位网上申报挂失"
  7380. break
  7381. case "23":
  7382. msg = "保健办挂失"
  7383. break
  7384. case "24":
  7385. msg = "个人网上挂失"
  7386. break
  7387. case "25":
  7388. msg = "网上服务大厅挂失"
  7389. break
  7390. case "30":
  7391. msg = "注销"
  7392. break
  7393. case "40":
  7394. msg = "回收"
  7395. break
  7396. case "99":
  7397. msg = "制卡中(无效卡)"
  7398. break
  7399. }
  7400. c.ServeSuccessJSON(map[string]interface{}{
  7401. "failed_code": -10,
  7402. "msg": msg,
  7403. })
  7404. return
  7405. } else {
  7406. c.ServeSuccessJSON(map[string]interface{}{
  7407. "msg": "校验成功",
  7408. })
  7409. return
  7410. }
  7411. }
  7412. } else {
  7413. c.ServeSuccessJSON(map[string]interface{}{
  7414. "msg": "校验成功",
  7415. })
  7416. return
  7417. }
  7418. }
  7419. func (c *HisApiController) CheckCardPWDTwo() {
  7420. //card_pwd := c.GetString("card_pwd")
  7421. //his_patient_id, _ := c.GetInt64("his_patient_id")
  7422. admin_user_id, _ := c.GetInt64("admin_user_id")
  7423. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7424. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7425. result := service.Gdyb90991("44030000000629690364", miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, "000000", "BDM421363")
  7426. var dat map[string]interface{}
  7427. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7428. fmt.Println(dat)
  7429. } else {
  7430. fmt.Println(err)
  7431. }
  7432. userJSONBytes, _ := json.Marshal(dat)
  7433. var res Result90991
  7434. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7435. utils.ErrorLog("解析失败:%v", err)
  7436. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7437. return
  7438. }
  7439. if res.Infcode != 0 {
  7440. c.ServeSuccessJSON(map[string]interface{}{
  7441. "failed_code": -10,
  7442. "msg": res.ErrMsg,
  7443. })
  7444. return
  7445. } else {
  7446. if res.Output.Result.SscnoCheckStat == "0" {
  7447. var msg string
  7448. switch res.Output.Result.CardStat {
  7449. case "00":
  7450. msg = "未激活"
  7451. break
  7452. case "10":
  7453. msg = "激活"
  7454. break
  7455. case "20":
  7456. msg = "窗口挂失"
  7457. break
  7458. case "21":
  7459. msg = "电话挂失"
  7460. break
  7461. case "22":
  7462. msg = "单位网上申报挂失"
  7463. break
  7464. case "23":
  7465. msg = "保健办挂失"
  7466. break
  7467. case "24":
  7468. msg = "个人网上挂失"
  7469. break
  7470. case "25":
  7471. msg = "网上服务大厅挂失"
  7472. break
  7473. case "30":
  7474. msg = "注销"
  7475. break
  7476. case "40":
  7477. msg = "回收"
  7478. break
  7479. case "99":
  7480. msg = "制卡中(无效卡)"
  7481. break
  7482. }
  7483. c.ServeSuccessJSON(map[string]interface{}{
  7484. "failed_code": -10,
  7485. "msg": msg,
  7486. })
  7487. return
  7488. } else {
  7489. c.ServeSuccessJSON(map[string]interface{}{
  7490. "msg": "校验成功",
  7491. })
  7492. return
  7493. }
  7494. }
  7495. }
  7496. type ELeCertData struct {
  7497. Data struct {
  7498. Extra string `json:"extra"`
  7499. IDNo string `json:"idNo"`
  7500. IDType string `json:"idType"`
  7501. EcToken string `json:"ecToken"`
  7502. InsuOrg string `json:"insuOrg"`
  7503. UserName string `json:"userName"`
  7504. EcIndexNo string `json:"ecIndexNo"`
  7505. Gender string `json:"gender"`
  7506. Birthday string `json:"birthday"`
  7507. Nationality string `json:"nationality"`
  7508. Email string `json:"email"`
  7509. } `json:"OutData"`
  7510. }
  7511. func (c *HisApiController) ReadCard() {
  7512. id_card_type, _ := c.GetInt64("id_card_type")
  7513. admin_user_id, _ := c.GetInt64("admin_user_id")
  7514. certificates, _ := c.GetInt64("certificates")
  7515. //insuplc_admdvs_str := c.GetString("insuplc_admdvs")
  7516. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7517. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7518. switch id_card_type {
  7519. case 1:
  7520. if miConfig.MdtrtareaAdmvs == "421300" {
  7521. var res ResultTwo
  7522. api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  7523. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  7524. "&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)
  7525. resp, requestErr := http.Get(api)
  7526. if requestErr != nil {
  7527. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7528. return
  7529. }
  7530. body, ioErr := ioutil.ReadAll(resp.Body)
  7531. if ioErr != nil {
  7532. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7533. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7534. return
  7535. }
  7536. var respJSON map[string]interface{}
  7537. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7538. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7539. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7540. return
  7541. }
  7542. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7543. result, _ := json.Marshal(respJSON)
  7544. fmt.Println("log")
  7545. fmt.Println(string(result))
  7546. if err := json.Unmarshal([]byte(result), &res); err != nil {
  7547. utils.ErrorLog("解析失败:%v", err)
  7548. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7549. return
  7550. }
  7551. if res.Infcode == 0 {
  7552. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  7553. if err == gorm.ErrRecordNotFound {
  7554. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  7555. return
  7556. } else if err != nil {
  7557. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  7558. return
  7559. } else {
  7560. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  7561. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  7562. infoStr := string(Iinfos)
  7563. idetinfoStr := string(Idetinfos)
  7564. var rf []*ResultFive
  7565. json.Unmarshal([]byte(infoStr), &rf)
  7566. var insutypes []*ResultFive
  7567. var insutype string
  7568. var is390 int = 0
  7569. var is310 int = 0
  7570. for _, item := range rf {
  7571. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  7572. insutypes = append(insutypes, item)
  7573. }
  7574. }
  7575. if len(insutypes) == 1 {
  7576. insutype = insutypes[0].Insutype
  7577. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  7578. } else {
  7579. for _, i := range insutypes {
  7580. if i.Insutype == "390" {
  7581. is390 = 1
  7582. }
  7583. if i.Insutype == "310" {
  7584. is310 = 1
  7585. }
  7586. }
  7587. }
  7588. if is390 == 1 {
  7589. insutype = "390"
  7590. }
  7591. if is310 == 1 {
  7592. insutype = "310"
  7593. }
  7594. if len(insutypes) == 0 {
  7595. insutype = "390"
  7596. }
  7597. var insuplc_admdvs string
  7598. for _, item := range rf {
  7599. if item.Insutype == insutype {
  7600. insuplc_admdvs = item.InsuplcAdmdvs
  7601. }
  7602. }
  7603. if strings.Contains(insuplc_admdvs, "4213") {
  7604. insuplc_admdvs = miConfig.MdtrtareaAdmvs
  7605. }
  7606. psn := &models.HisPsn{
  7607. PsnNo: res.Output.Baseinfo.PsnNo,
  7608. PatientId: patient.ID,
  7609. Certno: res.Output.Baseinfo.Certno,
  7610. Gend: res.Output.Baseinfo.Gend,
  7611. Naty: res.Output.Baseinfo.Naty,
  7612. PsnCertType: res.Output.Baseinfo.PsnCertType,
  7613. PsnName: res.Output.Baseinfo.PsnName,
  7614. Idetinfo: idetinfoStr,
  7615. Insuinfo: infoStr,
  7616. InsuplcAdmdvs: insuplc_admdvs,
  7617. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  7618. }
  7619. service.CreateHisPsn(psn)
  7620. c.ServeSuccessJSON(map[string]interface{}{
  7621. "patient": patient,
  7622. "number": res.Output.Baseinfo.Certno,
  7623. })
  7624. }
  7625. } else {
  7626. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  7627. return
  7628. }
  7629. } else if miConfig.MdtrtareaAdmvs == "420200" {
  7630. var res ResultTwo
  7631. api := "http://192.168.0.197:9532/" + "hbyb/1101?cert_no=" + "" +
  7632. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  7633. "&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)
  7634. resp, requestErr := http.Get(api)
  7635. if requestErr != nil {
  7636. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7637. return
  7638. }
  7639. body, ioErr := ioutil.ReadAll(resp.Body)
  7640. if ioErr != nil {
  7641. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7642. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7643. return
  7644. }
  7645. var respJSON map[string]interface{}
  7646. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7647. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7648. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7649. return
  7650. }
  7651. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7652. result, _ := json.Marshal(respJSON)
  7653. fmt.Println("log")
  7654. fmt.Println(string(result))
  7655. if err := json.Unmarshal([]byte(result), &res); err != nil {
  7656. utils.ErrorLog("解析失败:%v", err)
  7657. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7658. return
  7659. }
  7660. if res.Infcode == 0 {
  7661. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  7662. if err == gorm.ErrRecordNotFound {
  7663. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  7664. return
  7665. } else if err != nil {
  7666. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  7667. return
  7668. } else {
  7669. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  7670. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  7671. infoStr := string(Iinfos)
  7672. idetinfoStr := string(Idetinfos)
  7673. psn := &models.HisPsn{
  7674. PsnNo: res.Output.Baseinfo.PsnNo,
  7675. PatientId: patient.ID,
  7676. Certno: res.Output.Baseinfo.Certno,
  7677. Gend: res.Output.Baseinfo.Gend,
  7678. Naty: res.Output.Baseinfo.Naty,
  7679. PsnCertType: res.Output.Baseinfo.PsnCertType,
  7680. PsnName: res.Output.Baseinfo.PsnName,
  7681. Idetinfo: idetinfoStr,
  7682. Insuinfo: infoStr,
  7683. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  7684. }
  7685. service.CreateHisPsn(psn)
  7686. var rf []*ResultFive
  7687. json.Unmarshal([]byte(infoStr), &rf)
  7688. var insutypes []*ResultFive
  7689. var insutype string
  7690. var is390 int = 0
  7691. var is310 int = 0
  7692. for _, item := range rf {
  7693. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  7694. insutypes = append(insutypes, item)
  7695. }
  7696. }
  7697. if len(insutypes) == 1 {
  7698. insutype = insutypes[0].Insutype
  7699. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  7700. } else {
  7701. for _, i := range insutypes {
  7702. if i.Insutype == "390" {
  7703. is390 = 1
  7704. }
  7705. if i.Insutype == "310" {
  7706. is310 = 1
  7707. }
  7708. }
  7709. }
  7710. if is390 == 1 {
  7711. insutype = "390"
  7712. }
  7713. if is310 == 1 {
  7714. insutype = "310"
  7715. }
  7716. if len(insutypes) == 0 {
  7717. insutype = "310"
  7718. }
  7719. c.ServeSuccessJSON(map[string]interface{}{
  7720. "patient": patient,
  7721. "number": res.Output.Baseinfo.Certno,
  7722. "insutype": insutype,
  7723. })
  7724. }
  7725. } else {
  7726. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  7727. return
  7728. }
  7729. } else if miConfig.MdtrtareaAdmvs == "420902" {
  7730. var res ResultTwo
  7731. api := miConfig.Url + "hbyb/1101?cert_no=" + "" +
  7732. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  7733. "&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)
  7734. resp, requestErr := http.Get(api)
  7735. if requestErr != nil {
  7736. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7737. return
  7738. }
  7739. body, ioErr := ioutil.ReadAll(resp.Body)
  7740. if ioErr != nil {
  7741. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7742. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7743. return
  7744. }
  7745. var respJSON map[string]interface{}
  7746. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7747. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7748. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7749. return
  7750. }
  7751. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7752. result, _ := json.Marshal(respJSON)
  7753. fmt.Println("log")
  7754. fmt.Println(string(result))
  7755. if err := json.Unmarshal([]byte(result), &res); err != nil {
  7756. utils.ErrorLog("解析失败:%v", err)
  7757. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7758. return
  7759. }
  7760. if res.Infcode == 0 {
  7761. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  7762. if err == gorm.ErrRecordNotFound {
  7763. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  7764. return
  7765. } else if err != nil {
  7766. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  7767. return
  7768. } else {
  7769. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  7770. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  7771. infoStr := string(Iinfos)
  7772. idetinfoStr := string(Idetinfos)
  7773. var rf []*ResultFive
  7774. json.Unmarshal([]byte(infoStr), &rf)
  7775. var insutypes []*ResultFive
  7776. var insutype string
  7777. var is390 int = 0
  7778. var is310 int = 0
  7779. for _, item := range rf {
  7780. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  7781. insutypes = append(insutypes, item)
  7782. }
  7783. }
  7784. if len(insutypes) == 1 {
  7785. insutype = insutypes[0].Insutype
  7786. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  7787. } else {
  7788. for _, i := range insutypes {
  7789. if i.Insutype == "390" {
  7790. is390 = 1
  7791. }
  7792. if i.Insutype == "310" {
  7793. is310 = 1
  7794. }
  7795. }
  7796. }
  7797. if is390 == 1 {
  7798. insutype = "390"
  7799. }
  7800. if is310 == 1 {
  7801. insutype = "310"
  7802. }
  7803. if len(insutypes) == 0 {
  7804. insutype = "390"
  7805. }
  7806. var insuplc_admdvs string
  7807. for _, item := range rf {
  7808. if item.Insutype == insutype {
  7809. insuplc_admdvs = item.InsuplcAdmdvs
  7810. }
  7811. }
  7812. psn := &models.HisPsn{
  7813. PsnNo: res.Output.Baseinfo.PsnNo,
  7814. PatientId: patient.ID,
  7815. Certno: res.Output.Baseinfo.Certno,
  7816. Gend: res.Output.Baseinfo.Gend,
  7817. Naty: res.Output.Baseinfo.Naty,
  7818. PsnCertType: res.Output.Baseinfo.PsnCertType,
  7819. PsnName: res.Output.Baseinfo.PsnName,
  7820. Idetinfo: idetinfoStr,
  7821. Insuinfo: infoStr,
  7822. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  7823. InsuplcAdmdvs: insuplc_admdvs,
  7824. }
  7825. service.CreateHisPsn(psn)
  7826. for _, item := range rf {
  7827. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  7828. insutypes = append(insutypes, item)
  7829. }
  7830. }
  7831. if len(insutypes) == 1 {
  7832. insutype = insutypes[0].Insutype
  7833. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  7834. } else {
  7835. for _, i := range insutypes {
  7836. if i.Insutype == "390" {
  7837. is390 = 1
  7838. }
  7839. if i.Insutype == "310" {
  7840. is310 = 1
  7841. }
  7842. }
  7843. }
  7844. if is390 == 1 {
  7845. insutype = "390"
  7846. }
  7847. if is310 == 1 {
  7848. insutype = "310"
  7849. }
  7850. if len(insutypes) == 0 {
  7851. insutype = "310"
  7852. }
  7853. c.ServeSuccessJSON(map[string]interface{}{
  7854. "patient": patient,
  7855. "number": res.Output.Baseinfo.Certno,
  7856. "insutype": insutype,
  7857. })
  7858. }
  7859. } else {
  7860. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  7861. return
  7862. }
  7863. } else if miConfig.MdtrtareaAdmvs == "421182" {
  7864. var res ResultTwo
  7865. api := "http://192.168.0:9532/" + "hbyb/1101?cert_no=" + "" +
  7866. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  7867. "&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)
  7868. resp, requestErr := http.Get(api)
  7869. if requestErr != nil {
  7870. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7871. return
  7872. }
  7873. body, ioErr := ioutil.ReadAll(resp.Body)
  7874. if ioErr != nil {
  7875. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7876. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7877. return
  7878. }
  7879. var respJSON map[string]interface{}
  7880. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7881. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7882. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7883. return
  7884. }
  7885. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7886. result, _ := json.Marshal(respJSON)
  7887. fmt.Println("log")
  7888. fmt.Println(string(result))
  7889. if err := json.Unmarshal([]byte(result), &res); err != nil {
  7890. utils.ErrorLog("解析失败:%v", err)
  7891. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7892. return
  7893. }
  7894. if res.Infcode == 0 {
  7895. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  7896. if err == gorm.ErrRecordNotFound {
  7897. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  7898. return
  7899. } else if err != nil {
  7900. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  7901. return
  7902. } else {
  7903. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  7904. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  7905. infoStr := string(Iinfos)
  7906. idetinfoStr := string(Idetinfos)
  7907. b, age, _ := getBirthdateAndAge(res.Output.Baseinfo.Certno)
  7908. psn := &models.HisPsn{
  7909. PsnNo: res.Output.Baseinfo.PsnNo,
  7910. PatientId: patient.ID,
  7911. Certno: res.Output.Baseinfo.Certno,
  7912. Brdy: b,
  7913. Age: float64(age),
  7914. Gend: res.Output.Baseinfo.Gend,
  7915. Naty: res.Output.Baseinfo.Naty,
  7916. PsnCertType: res.Output.Baseinfo.PsnCertType,
  7917. PsnName: res.Output.Baseinfo.PsnName,
  7918. Idetinfo: idetinfoStr,
  7919. Insuinfo: infoStr,
  7920. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  7921. }
  7922. service.CreateHisPsn(psn)
  7923. var rf []*ResultFive
  7924. json.Unmarshal([]byte(infoStr), &rf)
  7925. var insutypes []*ResultFive
  7926. var insutype string
  7927. var is390 int = 0
  7928. var is310 int = 0
  7929. for _, item := range rf {
  7930. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  7931. insutypes = append(insutypes, item)
  7932. }
  7933. }
  7934. if len(insutypes) == 1 {
  7935. insutype = insutypes[0].Insutype
  7936. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  7937. } else {
  7938. for _, i := range insutypes {
  7939. if i.Insutype == "390" {
  7940. is390 = 1
  7941. }
  7942. if i.Insutype == "310" {
  7943. is310 = 1
  7944. }
  7945. }
  7946. }
  7947. if is390 == 1 {
  7948. insutype = "390"
  7949. }
  7950. if is310 == 1 {
  7951. insutype = "310"
  7952. }
  7953. if len(insutypes) == 0 {
  7954. insutype = "310"
  7955. }
  7956. c.ServeSuccessJSON(map[string]interface{}{
  7957. "patient": patient,
  7958. "number": res.Output.Baseinfo.Certno,
  7959. "insutype": insutype,
  7960. })
  7961. }
  7962. } else {
  7963. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  7964. return
  7965. }
  7966. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7967. var api string
  7968. if miConfig.MdtrtareaAdmvs == "320921" {
  7969. 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 +
  7970. "&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
  7971. fmt.Println(api)
  7972. } else {
  7973. 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 +
  7974. "&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)
  7975. }
  7976. resp, requestErr := http.Get(api)
  7977. if requestErr != nil {
  7978. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7979. return
  7980. }
  7981. body, ioErr := ioutil.ReadAll(resp.Body)
  7982. if ioErr != nil {
  7983. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7984. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7985. return
  7986. }
  7987. var respJSON map[string]interface{}
  7988. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7989. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7990. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7991. return
  7992. }
  7993. var status string
  7994. status = respJSON["data"].(map[string]interface{})["status"].(string)
  7995. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  7996. //console.log()
  7997. fmt.Println("type===")
  7998. fmt.Println(card_type)
  7999. var token string
  8000. var res ResultTwo //1101结果
  8001. var res10265 ResultTwo10265 //1101结果
  8002. var card_info string //卡信息
  8003. var busi_card_info string
  8004. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  8005. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  8006. if status == "0" { //读卡成功
  8007. if card_type == "1" {
  8008. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  8009. result, _ := json.Marshal(respJSON)
  8010. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  8011. utils.ErrorLog("解析失败:%v", err)
  8012. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8013. return
  8014. }
  8015. res.ErrMsg = res10265.ErrMsg
  8016. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  8017. res.Infcode = infocode
  8018. res.Output = res10265.Output
  8019. res.InfRefmsgid = res10265.InfRefmsgid
  8020. } else {
  8021. //var card_info string //卡信息
  8022. //var busi_card_info string
  8023. token = respJSON["data"].(map[string]interface{})["token"].(string)
  8024. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  8025. //fmt.Println(card_info)
  8026. //fmt.Println(busi_card_info)
  8027. respJSON = respJSON["data"].(map[string]interface{})["result"].(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. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  8036. res.Infcode = infocode
  8037. res.Output = res10265.Output
  8038. res.InfRefmsgid = res10265.InfRefmsgid
  8039. }
  8040. if res.Infcode == 0 {
  8041. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  8042. if err == gorm.ErrRecordNotFound {
  8043. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  8044. return
  8045. } else if err != nil {
  8046. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  8047. return
  8048. } else {
  8049. if card_type == "1" {
  8050. bas := strings.Split(card_info, "|")
  8051. basNumber := bas[2]
  8052. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  8053. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  8054. infoStr := string(Iinfos)
  8055. idetinfoStr := string(Idetinfos)
  8056. b, age, _ := getBirthdateAndAge(res.Output.Baseinfo.Certno)
  8057. psn := &models.HisPsn{
  8058. PsnNo: res.Output.Baseinfo.PsnNo,
  8059. PatientId: patient.ID,
  8060. Certno: res.Output.Baseinfo.Certno,
  8061. Brdy: b,
  8062. Age: float64(age),
  8063. Gend: res.Output.Baseinfo.Gend,
  8064. Naty: res.Output.Baseinfo.Naty,
  8065. PsnCertType: res.Output.Baseinfo.PsnCertType,
  8066. PsnName: res.Output.Baseinfo.PsnName,
  8067. Idetinfo: idetinfoStr,
  8068. Insuinfo: infoStr,
  8069. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  8070. CardInfo: card_info,
  8071. VerifyNumber: busi_card_info,
  8072. }
  8073. service.CreateHisPsn(psn)
  8074. var rf []*ResultFive
  8075. json.Unmarshal([]byte(infoStr), &rf)
  8076. var insutypes []*ResultFive
  8077. var insutype string
  8078. var is390 int = 0
  8079. var is310 int = 0
  8080. for _, item := range rf {
  8081. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  8082. insutypes = append(insutypes, item)
  8083. }
  8084. }
  8085. if len(insutypes) == 1 {
  8086. insutype = insutypes[0].Insutype
  8087. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  8088. } else {
  8089. for _, i := range insutypes {
  8090. if i.Insutype == "390" {
  8091. is390 = 1
  8092. }
  8093. if i.Insutype == "310" {
  8094. is310 = 1
  8095. }
  8096. }
  8097. }
  8098. if is390 == 1 {
  8099. insutype = "390"
  8100. }
  8101. if is310 == 1 {
  8102. insutype = "310"
  8103. }
  8104. if len(insutypes) == 0 {
  8105. insutype = "310"
  8106. }
  8107. c.ServeSuccessJSON(map[string]interface{}{
  8108. "patient": patient,
  8109. "number": basNumber,
  8110. "insutype": insutype,
  8111. })
  8112. } else {
  8113. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  8114. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  8115. infoStr := string(Iinfos)
  8116. idetinfoStr := string(Idetinfos)
  8117. psn := &models.HisPsn{
  8118. PsnNo: res.Output.Baseinfo.PsnNo,
  8119. PatientId: patient.ID,
  8120. Certno: res.Output.Baseinfo.Certno,
  8121. Gend: res.Output.Baseinfo.Gend,
  8122. Naty: res.Output.Baseinfo.Naty,
  8123. PsnCertType: res.Output.Baseinfo.PsnCertType,
  8124. PsnName: res.Output.Baseinfo.PsnName,
  8125. Idetinfo: idetinfoStr,
  8126. Insuinfo: infoStr,
  8127. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  8128. CardInfo: card_info,
  8129. VerifyNumber: token,
  8130. }
  8131. service.CreateHisPsn(psn)
  8132. c.ServeSuccessJSON(map[string]interface{}{
  8133. "patient": patient,
  8134. "number": token,
  8135. })
  8136. }
  8137. }
  8138. } else {
  8139. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  8140. return
  8141. }
  8142. } else { //读卡失败
  8143. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  8144. return
  8145. }
  8146. } else if miConfig.MdtrtareaAdmvs == "350500" {
  8147. cardnum, cardCode, id_card_no, name, errmsg := c.GetFjBasBaseInfo()
  8148. cardnum = DeleteExtraSpaceTwo(cardnum)
  8149. cardCode = DeleteExtraSpaceTwo(cardCode)
  8150. id_card_no = DeleteExtraSpaceTwo(id_card_no)
  8151. name = DeleteExtraSpaceTwo(name)
  8152. errmsg = DeleteExtraSpaceTwo(errmsg)
  8153. cardnum = Remove0000(cardnum)
  8154. cardCode = Remove0000(cardCode)
  8155. id_card_no = Remove0000(id_card_no)
  8156. name = Remove0000(name)
  8157. errmsg = Remove0000(errmsg)
  8158. patient, _ := service.GetPatientByIDCard(id_card_no, miConfig.UserOrgId)
  8159. basStr := cardnum + "|" + cardCode + "|" + id_card_no + "|" + name
  8160. //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)
  8161. //fmt.Println(result2)
  8162. //fmt.Println(requestLog2)
  8163. //fmt.Println(errMsgLog2)
  8164. 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)
  8165. saveLog(result, requestLog, "1101", "获取人员信息")
  8166. fmt.Println(errMsgLog)
  8167. if len(errMsgLog) > 0 {
  8168. } else {
  8169. var dat map[string]interface{}
  8170. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8171. fmt.Println(dat)
  8172. } else {
  8173. fmt.Println(err)
  8174. }
  8175. userJSONBytes, _ := json.Marshal(dat)
  8176. var res ResultTwo
  8177. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8178. utils.ErrorLog("解析失败:%v", err)
  8179. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8180. return
  8181. }
  8182. res.ErrMsg = errMsgLog
  8183. if res.Infcode == 0 {
  8184. patient, err := service.GetPatientByNumber(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  8185. if err == gorm.ErrRecordNotFound {
  8186. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  8187. return
  8188. } else if err != nil {
  8189. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  8190. return
  8191. } else {
  8192. fmt.Println(res)
  8193. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  8194. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  8195. infoStr := string(Iinfos)
  8196. idetinfoStr := string(Idetinfos)
  8197. var rf []*ResultFive
  8198. json.Unmarshal([]byte(infoStr), &rf)
  8199. var insutypes []*ResultFive
  8200. var insutype string
  8201. var is390 int = 0
  8202. var is310 int = 0
  8203. for _, item := range rf {
  8204. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  8205. insutypes = append(insutypes, item)
  8206. }
  8207. }
  8208. if len(insutypes) == 1 {
  8209. insutype = insutypes[0].Insutype
  8210. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  8211. } else {
  8212. for _, i := range insutypes {
  8213. if i.Insutype == "390" {
  8214. is390 = 1
  8215. }
  8216. if i.Insutype == "310" {
  8217. is310 = 1
  8218. }
  8219. }
  8220. }
  8221. if is390 == 1 {
  8222. insutype = "390"
  8223. }
  8224. if is310 == 1 {
  8225. insutype = "310"
  8226. }
  8227. if len(insutypes) == 0 {
  8228. insutype = "390"
  8229. }
  8230. var insuplc_admdvs string
  8231. for _, item := range rf {
  8232. if item.Insutype == insutype {
  8233. insuplc_admdvs = item.InsuplcAdmdvs
  8234. }
  8235. }
  8236. psn := &models.HisPsn{
  8237. PsnNo: res.Output.Baseinfo.PsnNo,
  8238. PatientId: patient.ID,
  8239. Certno: res.Output.Baseinfo.Certno,
  8240. Gend: res.Output.Baseinfo.Gend,
  8241. Naty: res.Output.Baseinfo.Naty,
  8242. PsnCertType: res.Output.Baseinfo.PsnCertType,
  8243. PsnName: res.Output.Baseinfo.PsnName,
  8244. Idetinfo: idetinfoStr,
  8245. Insuinfo: infoStr,
  8246. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  8247. CardInfo: basStr,
  8248. VerifyNumber: "",
  8249. InsuplcAdmdvs: insuplc_admdvs,
  8250. }
  8251. service.CreateHisPsn(psn)
  8252. c.ServeSuccessJSON(map[string]interface{}{
  8253. "patient": patient,
  8254. "number": cardnum,
  8255. "insutype": insutype,
  8256. })
  8257. }
  8258. } else {
  8259. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  8260. return
  8261. }
  8262. }
  8263. } else if miConfig.MdtrtareaAdmvs == "360302" {
  8264. fmt.Println(initFlag)
  8265. fmt.Println("initFlag")
  8266. if initFlag == 0 {
  8267. c.TestGetJiangXiBasBaseInit()
  8268. }
  8269. basStr := c.GetBasBaseInfo()
  8270. if len(basStr) == 0 {
  8271. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  8272. return
  8273. }
  8274. fmt.Println(basStr)
  8275. bas := strings.Split(basStr, "|")
  8276. basNumber := bas[1]
  8277. fmt.Println(basNumber)
  8278. card_sn := bas[3]
  8279. fmt.Println(card_sn)
  8280. 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, "")
  8281. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  8282. var dat map[string]interface{}
  8283. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8284. fmt.Println(dat)
  8285. } else {
  8286. fmt.Println(err)
  8287. }
  8288. userJSONBytes, _ := json.Marshal(dat)
  8289. var res ResultTwo
  8290. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8291. utils.ErrorLog("解析失败:%v", err)
  8292. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8293. return
  8294. }
  8295. if res.Infcode == 0 {
  8296. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  8297. if err == gorm.ErrRecordNotFound {
  8298. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  8299. return
  8300. } else if err != nil {
  8301. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  8302. return
  8303. } else {
  8304. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  8305. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  8306. infoStr := string(Iinfos)
  8307. idetinfoStr := string(Idetinfos)
  8308. var rf []*ResultFive
  8309. json.Unmarshal([]byte(infoStr), &rf)
  8310. var insutypes []*ResultFive
  8311. var insutype string
  8312. var is390 int = 0
  8313. var is310 int = 0
  8314. var insuplc_admdvs string
  8315. for _, item := range rf {
  8316. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  8317. insutypes = append(insutypes, item)
  8318. }
  8319. }
  8320. if len(insutypes) == 1 {
  8321. insutype = insutypes[0].Insutype
  8322. insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  8323. } else {
  8324. for _, i := range insutypes {
  8325. if i.Insutype == "390" {
  8326. is390 = 1
  8327. }
  8328. if i.Insutype == "310" {
  8329. is310 = 1
  8330. }
  8331. }
  8332. }
  8333. if is390 == 1 {
  8334. insutype = "390"
  8335. }
  8336. if is310 == 1 {
  8337. insutype = "310"
  8338. }
  8339. if len(insutypes) == 0 {
  8340. insutype = "310"
  8341. }
  8342. for _, item := range rf {
  8343. if item.Insutype == insutype && item.PsnInsuStas == "1" {
  8344. insuplc_admdvs = item.InsuplcAdmdvs
  8345. }
  8346. }
  8347. psn := &models.HisPsn{
  8348. PsnNo: res.Output.Baseinfo.PsnNo,
  8349. PatientId: patient.ID,
  8350. Certno: res.Output.Baseinfo.Certno,
  8351. Gend: res.Output.Baseinfo.Gend,
  8352. Naty: res.Output.Baseinfo.Naty,
  8353. PsnCertType: res.Output.Baseinfo.PsnCertType,
  8354. PsnName: res.Output.Baseinfo.PsnName,
  8355. Idetinfo: idetinfoStr,
  8356. Insuinfo: infoStr,
  8357. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  8358. CardInfo: basStr,
  8359. InsuplcAdmdvs: insuplc_admdvs,
  8360. VerifyNumber: "",
  8361. }
  8362. service.CreateHisPsn(psn)
  8363. c.ServeSuccessJSON(map[string]interface{}{
  8364. "patient": patient,
  8365. "number": basNumber,
  8366. "insutype": insutype,
  8367. })
  8368. }
  8369. } else {
  8370. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  8371. return
  8372. }
  8373. } else if miConfig.MdtrtareaAdmvs == "430800" {
  8374. fmt.Println(initFlag)
  8375. fmt.Println("initFlag")
  8376. if initFlag == 0 {
  8377. c.TestGetHnBasBaseInit()
  8378. }
  8379. basStr := c.GetBasBaseInfo()
  8380. if len(basStr) == 0 {
  8381. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  8382. return
  8383. }
  8384. fmt.Println(basStr)
  8385. bas := strings.Split(basStr, "|")
  8386. basNumber := bas[1]
  8387. fmt.Println(basNumber)
  8388. card_sn := bas[3]
  8389. card_no := bas[2]
  8390. fmt.Println(card_sn)
  8391. name := bas[4]
  8392. name = ConvertToString(name, "gbk", "utf-8")
  8393. 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)
  8394. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  8395. var dat map[string]interface{}
  8396. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8397. fmt.Println(dat)
  8398. } else {
  8399. fmt.Println(err)
  8400. }
  8401. userJSONBytes, _ := json.Marshal(dat)
  8402. var res ResultTwo
  8403. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8404. utils.ErrorLog("解析失败:%v", err)
  8405. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8406. return
  8407. }
  8408. if res.Infcode == 0 {
  8409. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  8410. if err == gorm.ErrRecordNotFound {
  8411. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  8412. return
  8413. } else if err != nil {
  8414. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  8415. return
  8416. } else {
  8417. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  8418. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  8419. infoStr := string(Iinfos)
  8420. idetinfoStr := string(Idetinfos)
  8421. psn := &models.HisPsn{
  8422. PsnNo: res.Output.Baseinfo.PsnNo,
  8423. PatientId: patient.ID,
  8424. Certno: res.Output.Baseinfo.Certno,
  8425. Gend: res.Output.Baseinfo.Gend,
  8426. Naty: res.Output.Baseinfo.Naty,
  8427. PsnCertType: res.Output.Baseinfo.PsnCertType,
  8428. PsnName: res.Output.Baseinfo.PsnName,
  8429. Idetinfo: idetinfoStr,
  8430. Insuinfo: infoStr,
  8431. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  8432. CardInfo: basStr,
  8433. VerifyNumber: "",
  8434. }
  8435. service.CreateHisPsn(psn)
  8436. var rf []*ResultFive
  8437. json.Unmarshal([]byte(infoStr), &rf)
  8438. var insutypes []*ResultFive
  8439. var insutype string
  8440. var is390 int = 0
  8441. var is310 int = 0
  8442. for _, item := range rf {
  8443. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  8444. insutypes = append(insutypes, item)
  8445. }
  8446. }
  8447. if len(insutypes) == 1 {
  8448. insutype = insutypes[0].Insutype
  8449. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  8450. } else {
  8451. for _, i := range insutypes {
  8452. if i.Insutype == "390" {
  8453. is390 = 1
  8454. }
  8455. if i.Insutype == "310" {
  8456. is310 = 1
  8457. }
  8458. }
  8459. }
  8460. if is390 == 1 {
  8461. insutype = "390"
  8462. }
  8463. if is310 == 1 {
  8464. insutype = "310"
  8465. }
  8466. if len(insutypes) == 0 {
  8467. insutype = "310"
  8468. }
  8469. c.ServeSuccessJSON(map[string]interface{}{
  8470. "patient": patient,
  8471. "number": basNumber,
  8472. "insutype": insutype,
  8473. })
  8474. }
  8475. } else {
  8476. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  8477. return
  8478. }
  8479. } else if miConfig.MdtrtareaAdmvs == "150499" {
  8480. var api string
  8481. 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 +
  8482. "&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
  8483. fmt.Println(api)
  8484. resp, requestErr := http.Get(api)
  8485. if requestErr != nil {
  8486. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8487. return
  8488. }
  8489. body, ioErr := ioutil.ReadAll(resp.Body)
  8490. if ioErr != nil {
  8491. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8492. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8493. return
  8494. }
  8495. var respJSON map[string]interface{}
  8496. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8497. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8498. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8499. return
  8500. }
  8501. var res ResultTwo //1101结果
  8502. var res10265 ResultTwo10265 //1101结果
  8503. var card_info string //卡信息
  8504. token := respJSON["data"].(map[string]interface{})["token"].(string)
  8505. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  8506. result, _ := json.Marshal(respJSON)
  8507. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  8508. utils.ErrorLog("解析失败:%v", err)
  8509. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8510. return
  8511. }
  8512. res.ErrMsg = res10265.ErrMsg
  8513. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  8514. res.Infcode = infocode
  8515. res.Output = res10265.Output
  8516. res.InfRefmsgid = res10265.InfRefmsgid
  8517. if res.Infcode == 0 {
  8518. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  8519. if err == gorm.ErrRecordNotFound {
  8520. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  8521. return
  8522. } else if err != nil {
  8523. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  8524. return
  8525. } else {
  8526. bas := strings.Split(card_info, "|")
  8527. basNumber := bas[2]
  8528. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  8529. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  8530. infoStr := string(Iinfos)
  8531. idetinfoStr := string(Idetinfos)
  8532. psn := &models.HisPsn{
  8533. PsnNo: res.Output.Baseinfo.PsnNo,
  8534. PatientId: patient.ID,
  8535. Certno: res.Output.Baseinfo.Certno,
  8536. Gend: res.Output.Baseinfo.Gend,
  8537. Naty: res.Output.Baseinfo.Naty,
  8538. PsnCertType: res.Output.Baseinfo.PsnCertType,
  8539. PsnName: res.Output.Baseinfo.PsnName,
  8540. Idetinfo: idetinfoStr,
  8541. Insuinfo: infoStr,
  8542. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  8543. CardInfo: card_info,
  8544. VerifyNumber: token,
  8545. }
  8546. service.CreateHisPsn(psn)
  8547. var rf []*ResultFive
  8548. json.Unmarshal([]byte(infoStr), &rf)
  8549. var insutypes []*ResultFive
  8550. var insutype string
  8551. var is390 int = 0
  8552. var is310 int = 0
  8553. for _, item := range rf {
  8554. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  8555. insutypes = append(insutypes, item)
  8556. }
  8557. }
  8558. if len(insutypes) == 1 {
  8559. insutype = insutypes[0].Insutype
  8560. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  8561. } else {
  8562. for _, i := range insutypes {
  8563. if i.Insutype == "390" {
  8564. is390 = 1
  8565. }
  8566. if i.Insutype == "310" {
  8567. is310 = 1
  8568. }
  8569. }
  8570. }
  8571. if is390 == 1 {
  8572. insutype = "390"
  8573. }
  8574. if is310 == 1 {
  8575. insutype = "310"
  8576. }
  8577. if len(insutypes) == 0 {
  8578. insutype = "310"
  8579. }
  8580. c.ServeSuccessJSON(map[string]interface{}{
  8581. "patient": patient,
  8582. "number": basNumber,
  8583. "insutype": insutype,
  8584. })
  8585. }
  8586. } else {
  8587. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  8588. return
  8589. }
  8590. } else if miConfig.MdtrtareaAdmvs == "450721" {
  8591. res := c.GetoleInfo()
  8592. if res.Infcode == 0 {
  8593. var result string
  8594. if res.Output.MdtrtCertType == "01" {
  8595. 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)
  8596. } else if res.Output.MdtrtCertType == "02" {
  8597. 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)
  8598. } else if res.Output.MdtrtCertType == "03" {
  8599. 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)
  8600. }
  8601. var dat map[string]interface{}
  8602. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8603. fmt.Println(dat)
  8604. } else {
  8605. fmt.Println(err)
  8606. }
  8607. userJSONBytes, _ := json.Marshal(dat)
  8608. var res2 ResultTwo
  8609. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  8610. utils.ErrorLog("解析失败:%v", err)
  8611. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8612. return
  8613. }
  8614. if res2.Infcode == 0 {
  8615. patient, err := service.GetPatientByNumber(res.Output.CertNo, c.GetAdminUserInfo().CurrentOrgId)
  8616. if err == gorm.ErrRecordNotFound {
  8617. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  8618. return
  8619. } else if err != nil {
  8620. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  8621. return
  8622. } else {
  8623. Iinfos, _ := json.Marshal(res2.Output.Iinfo)
  8624. Idetinfos, _ := json.Marshal(res2.Output.Idetinfo)
  8625. infoStr := string(Iinfos)
  8626. idetinfoStr := string(Idetinfos)
  8627. var rf []*ResultFive
  8628. json.Unmarshal([]byte(infoStr), &rf)
  8629. var insutypes []*ResultFive
  8630. var insutype string
  8631. var is390 int = 0
  8632. var is310 int = 0
  8633. //var insuplc_admdvs string
  8634. for _, item := range rf {
  8635. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  8636. insutypes = append(insutypes, item)
  8637. }
  8638. }
  8639. if len(insutypes) == 1 {
  8640. insutype = insutypes[0].Insutype
  8641. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  8642. } else {
  8643. for _, i := range insutypes {
  8644. if i.Insutype == "390" {
  8645. is390 = 1
  8646. }
  8647. if i.Insutype == "310" {
  8648. is310 = 1
  8649. }
  8650. }
  8651. }
  8652. if is390 == 1 {
  8653. insutype = "390"
  8654. }
  8655. if is310 == 1 {
  8656. insutype = "310"
  8657. }
  8658. if len(insutypes) == 0 {
  8659. insutype = "310"
  8660. }
  8661. psn := &models.HisPsn{
  8662. PsnNo: res2.Output.Baseinfo.PsnNo,
  8663. PatientId: patient.ID,
  8664. Certno: res2.Output.Baseinfo.Certno,
  8665. Gend: res2.Output.Baseinfo.Gend,
  8666. Naty: res2.Output.Baseinfo.Naty,
  8667. PsnCertType: res2.Output.Baseinfo.PsnCertType,
  8668. PsnName: res2.Output.Baseinfo.PsnName,
  8669. Idetinfo: idetinfoStr,
  8670. Insuinfo: infoStr,
  8671. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  8672. CardInfo: res.Output.CertNo + "|" + res.Output.CardSN,
  8673. VerifyNumber: res.Output.EcToken,
  8674. InsuplcAdmdvs: res.Output.InsuplcAdmdvs,
  8675. }
  8676. if res.Output.MdtrtCertType == "01" {
  8677. psn.VerifyNumber = res.Output.EcToken
  8678. //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)
  8679. } else if res.Output.MdtrtCertType == "02" {
  8680. psn.VerifyNumber = res.Output.MdtrtCertNo
  8681. //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)
  8682. } else if res.Output.MdtrtCertType == "03" {
  8683. psn.VerifyNumber = res.Output.MdtrtCertNo
  8684. //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)
  8685. }
  8686. var balc float64
  8687. for _, item := range rf {
  8688. if item.Insutype == insutype {
  8689. balc = item.Balc
  8690. }
  8691. }
  8692. service.CreateHisPsn(psn)
  8693. c.ServeSuccessJSON(map[string]interface{}{
  8694. "patient": patient,
  8695. "number": res.Output.CardNo,
  8696. "insutype": insutype,
  8697. "blac": balc,
  8698. "desc": idetinfoStr,
  8699. })
  8700. }
  8701. } else {
  8702. c.ServeSuccessJSON(map[string]interface{}{
  8703. "failed_code": -10,
  8704. "msg": res2.ErrMsg,
  8705. })
  8706. }
  8707. } else {
  8708. c.ServeSuccessJSON(map[string]interface{}{
  8709. "failed_code": -10,
  8710. "msg": res.ErrMsg,
  8711. })
  8712. }
  8713. } else if miConfig.MdtrtareaAdmvs == "341203" {
  8714. var api string
  8715. api = miConfig.SecretKey + "ahyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  8716. "&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
  8717. fmt.Println(api)
  8718. resp, requestErr := http.Get(api)
  8719. if requestErr != nil {
  8720. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8721. return
  8722. }
  8723. body, ioErr := ioutil.ReadAll(resp.Body)
  8724. if ioErr != nil {
  8725. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8726. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8727. return
  8728. }
  8729. var respJSON map[string]interface{}
  8730. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8731. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8732. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8733. return
  8734. }
  8735. var status string
  8736. status = respJSON["data"].(map[string]interface{})["status"].(string)
  8737. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  8738. //console.log()
  8739. fmt.Println("type===")
  8740. fmt.Println(card_type)
  8741. var token string
  8742. var res ResultTwo //1101结果
  8743. //var res10265 ResultTwoesultTwo10265 //1101结果
  8744. var card_info string //卡信息
  8745. var busi_card_info string
  8746. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  8747. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  8748. if status == "0" { //读卡成功
  8749. if card_type == "1" {
  8750. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  8751. result, _ := json.Marshal(respJSON)
  8752. if err := json.Unmarshal([]byte(result), &res); err != nil {
  8753. utils.ErrorLog("解析失败:%v", err)
  8754. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8755. return
  8756. }
  8757. } else {
  8758. token = respJSON["data"].(map[string]interface{})["token"].(string)
  8759. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  8760. result, _ := json.Marshal(respJSON)
  8761. if err := json.Unmarshal([]byte(result), &res); err != nil {
  8762. utils.ErrorLog("解析失败:%v", err)
  8763. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8764. return
  8765. }
  8766. }
  8767. if res.Infcode == 0 {
  8768. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  8769. if err == gorm.ErrRecordNotFound {
  8770. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  8771. return
  8772. } else if err != nil {
  8773. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  8774. return
  8775. } else {
  8776. if card_type == "1" {
  8777. bas := strings.Split(card_info, "|")
  8778. basNumber := bas[2]
  8779. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  8780. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  8781. infoStr := string(Iinfos)
  8782. idetinfoStr := string(Idetinfos)
  8783. psn := &models.HisPsn{
  8784. PsnNo: res.Output.Baseinfo.PsnNo,
  8785. PatientId: patient.ID,
  8786. Certno: res.Output.Baseinfo.Certno,
  8787. Gend: res.Output.Baseinfo.Gend,
  8788. Naty: res.Output.Baseinfo.Naty,
  8789. PsnCertType: res.Output.Baseinfo.PsnCertType,
  8790. PsnName: res.Output.Baseinfo.PsnName,
  8791. Idetinfo: idetinfoStr,
  8792. Insuinfo: infoStr,
  8793. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  8794. CardInfo: card_info,
  8795. VerifyNumber: busi_card_info,
  8796. }
  8797. service.CreateHisPsn(psn)
  8798. var rf []*ResultFive
  8799. json.Unmarshal([]byte(infoStr), &rf)
  8800. var insutypes []*ResultFive
  8801. var insutype string
  8802. var is390 int = 0
  8803. var is310 int = 0
  8804. for _, item := range rf {
  8805. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  8806. insutypes = append(insutypes, item)
  8807. }
  8808. }
  8809. if len(insutypes) == 1 {
  8810. insutype = insutypes[0].Insutype
  8811. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  8812. } else {
  8813. for _, i := range insutypes {
  8814. if i.Insutype == "390" {
  8815. is390 = 1
  8816. }
  8817. if i.Insutype == "310" {
  8818. is310 = 1
  8819. }
  8820. }
  8821. }
  8822. if is390 == 1 {
  8823. insutype = "390"
  8824. }
  8825. if is310 == 1 {
  8826. insutype = "310"
  8827. }
  8828. if len(insutypes) == 0 {
  8829. insutype = "310"
  8830. }
  8831. c.ServeSuccessJSON(map[string]interface{}{
  8832. "patient": patient,
  8833. "number": basNumber,
  8834. "insutype": insutype,
  8835. })
  8836. } else {
  8837. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  8838. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  8839. infoStr := string(Iinfos)
  8840. idetinfoStr := string(Idetinfos)
  8841. psn := &models.HisPsn{
  8842. PsnNo: res.Output.Baseinfo.PsnNo,
  8843. PatientId: patient.ID,
  8844. Certno: res.Output.Baseinfo.Certno,
  8845. Gend: res.Output.Baseinfo.Gend,
  8846. Naty: res.Output.Baseinfo.Naty,
  8847. PsnCertType: res.Output.Baseinfo.PsnCertType,
  8848. PsnName: res.Output.Baseinfo.PsnName,
  8849. Idetinfo: idetinfoStr,
  8850. Insuinfo: infoStr,
  8851. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  8852. CardInfo: card_info,
  8853. VerifyNumber: token,
  8854. }
  8855. service.CreateHisPsn(psn)
  8856. c.ServeSuccessJSON(map[string]interface{}{
  8857. "patient": patient,
  8858. "number": token,
  8859. })
  8860. }
  8861. }
  8862. } else {
  8863. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  8864. return
  8865. }
  8866. } else { //读卡失败
  8867. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  8868. return
  8869. }
  8870. } else {
  8871. if initFlag == 0 {
  8872. c.TestGetBasBaseInit()
  8873. }
  8874. basStr := c.GetBasBaseInfo()
  8875. if len(basStr) == 0 {
  8876. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  8877. return
  8878. }
  8879. fmt.Println(basStr)
  8880. bas := strings.Split(basStr, "|")
  8881. basNumber := bas[1]
  8882. fmt.Println(basNumber)
  8883. card_sn := bas[3]
  8884. fmt.Println(card_sn)
  8885. cardNumber := bas[2]
  8886. fmt.Println(cardNumber)
  8887. patient, _ := service.GetPatientByIDCard(basNumber, miConfig.UserOrgId)
  8888. var result string
  8889. if bas[0][:2] == "44" {
  8890. 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)
  8891. } else {
  8892. 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)
  8893. }
  8894. var dat map[string]interface{}
  8895. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8896. fmt.Println(dat)
  8897. } else {
  8898. fmt.Println(err)
  8899. }
  8900. userJSONBytes, _ := json.Marshal(dat)
  8901. var res ResultTwo
  8902. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8903. utils.ErrorLog("解析失败:%v", err)
  8904. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8905. return
  8906. }
  8907. if res.Infcode == 0 {
  8908. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  8909. if err == gorm.ErrRecordNotFound {
  8910. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  8911. return
  8912. } else if err != nil {
  8913. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  8914. return
  8915. } else {
  8916. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  8917. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  8918. infoStr := string(Iinfos)
  8919. idetinfoStr := string(Idetinfos)
  8920. var rf []*ResultFive
  8921. json.Unmarshal([]byte(infoStr), &rf)
  8922. var insutypes []*ResultFive
  8923. var insutype string
  8924. var is390 int = 0
  8925. var is310 int = 0
  8926. var insuplc_admdvs string
  8927. for _, item := range rf {
  8928. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  8929. insutypes = append(insutypes, item)
  8930. }
  8931. }
  8932. if len(insutypes) == 1 {
  8933. insutype = insutypes[0].Insutype
  8934. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  8935. } else {
  8936. for _, i := range insutypes {
  8937. if i.Insutype == "390" {
  8938. is390 = 1
  8939. }
  8940. if i.Insutype == "310" {
  8941. is310 = 1
  8942. }
  8943. }
  8944. }
  8945. if is390 == 1 {
  8946. insutype = "390"
  8947. }
  8948. if is310 == 1 {
  8949. insutype = "310"
  8950. }
  8951. if len(insutypes) == 0 {
  8952. insutype = "310"
  8953. }
  8954. for _, item := range rf {
  8955. if item.Insutype == insutype {
  8956. insuplc_admdvs = item.InsuplcAdmdvs
  8957. }
  8958. }
  8959. psn := &models.HisPsn{
  8960. PsnNo: res.Output.Baseinfo.PsnNo,
  8961. PatientId: patient.ID,
  8962. Certno: res.Output.Baseinfo.Certno,
  8963. Gend: res.Output.Baseinfo.Gend,
  8964. Naty: res.Output.Baseinfo.Naty,
  8965. PsnCertType: res.Output.Baseinfo.PsnCertType,
  8966. PsnName: res.Output.Baseinfo.PsnName,
  8967. Idetinfo: idetinfoStr,
  8968. Insuinfo: infoStr,
  8969. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  8970. CardInfo: basStr,
  8971. VerifyNumber: "",
  8972. InsuplcAdmdvs: insuplc_admdvs,
  8973. }
  8974. service.CreateHisPsn(psn)
  8975. c.ServeSuccessJSON(map[string]interface{}{
  8976. "patient": patient,
  8977. "number": basNumber,
  8978. })
  8979. }
  8980. } else {
  8981. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  8982. return
  8983. }
  8984. break
  8985. }
  8986. case 2:
  8987. if miConfig.MdtrtareaAdmvs == "430800" {
  8988. if initFlag == 0 {
  8989. c.TestGetHnBasBaseInit()
  8990. }
  8991. SFZStr := c.GetSFZBaseInfo()
  8992. if len(SFZStr) == 0 {
  8993. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  8994. return
  8995. }
  8996. fmt.Println(SFZStr)
  8997. id_card_str := strings.Split(SFZStr, "^")
  8998. card_no := id_card_str[0]
  8999. patient, _ := service.GetPatientByNumber(card_no, c.GetAdminUserInfo().CurrentOrgId)
  9000. //name := id_card_str[1]
  9001. //name = ConvertToString(name, "gbk", "utf-8")
  9002. 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)
  9003. var dat map[string]interface{}
  9004. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9005. fmt.Println(dat)
  9006. } else {
  9007. fmt.Println(err)
  9008. }
  9009. userJSONBytes, _ := json.Marshal(dat)
  9010. var res ResultTwo
  9011. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9012. utils.ErrorLog("解析失败:%v", err)
  9013. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9014. return
  9015. }
  9016. if res.Infcode == 0 {
  9017. patient, err := service.GetPatientByNumber(card_no, c.GetAdminUserInfo().CurrentOrgId)
  9018. if err == gorm.ErrRecordNotFound {
  9019. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  9020. return
  9021. } else if err != nil {
  9022. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  9023. return
  9024. } else {
  9025. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9026. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9027. infoStr := string(Iinfos)
  9028. idetinfoStr := string(Idetinfos)
  9029. var rf []*ResultFive
  9030. json.Unmarshal([]byte(infoStr), &rf)
  9031. var insutypes []*ResultFive
  9032. var insutype string
  9033. var is390 int = 0
  9034. var is310 int = 0
  9035. for _, item := range rf {
  9036. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  9037. insutypes = append(insutypes, item)
  9038. }
  9039. }
  9040. if len(insutypes) == 1 {
  9041. insutype = insutypes[0].Insutype
  9042. } else {
  9043. for _, i := range insutypes {
  9044. if i.Insutype == "390" {
  9045. is390 = 1
  9046. }
  9047. if i.Insutype == "310" {
  9048. is310 = 1
  9049. }
  9050. }
  9051. }
  9052. if is390 == 1 {
  9053. insutype = "390"
  9054. }
  9055. if is310 == 1 {
  9056. insutype = "310"
  9057. }
  9058. if len(insutypes) == 0 {
  9059. insutype = "310"
  9060. }
  9061. var InsuplcAdmdvs string
  9062. for _, item := range rf {
  9063. if item.Insutype == insutype {
  9064. InsuplcAdmdvs = item.InsuplcAdmdvs
  9065. }
  9066. }
  9067. psn := &models.HisPsn{
  9068. PsnNo: res.Output.Baseinfo.PsnNo,
  9069. PatientId: patient.ID,
  9070. Certno: res.Output.Baseinfo.Certno,
  9071. Gend: res.Output.Baseinfo.Gend,
  9072. Naty: res.Output.Baseinfo.Naty,
  9073. PsnCertType: res.Output.Baseinfo.PsnCertType,
  9074. PsnName: res.Output.Baseinfo.PsnName,
  9075. Idetinfo: idetinfoStr,
  9076. Insuinfo: infoStr,
  9077. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9078. CardInfo: SFZStr,
  9079. VerifyNumber: "",
  9080. InsuplcAdmdvs: InsuplcAdmdvs,
  9081. }
  9082. service.CreateHisPsn(psn)
  9083. c.ServeSuccessJSON(map[string]interface{}{
  9084. "patient": patient,
  9085. "number": card_no,
  9086. "insutype": insutype,
  9087. })
  9088. }
  9089. } else {
  9090. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9091. return
  9092. }
  9093. } else if miConfig.MdtrtareaAdmvs == "420200" {
  9094. var res ResultTwo
  9095. api := "http://192.168.0.197:9532/" + "hbyb/1101?cert_no=" + "" +
  9096. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  9097. "&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)
  9098. resp, requestErr := http.Get(api)
  9099. if requestErr != nil {
  9100. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9101. return
  9102. }
  9103. body, ioErr := ioutil.ReadAll(resp.Body)
  9104. if ioErr != nil {
  9105. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9106. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9107. return
  9108. }
  9109. var respJSON map[string]interface{}
  9110. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9111. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9112. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9113. return
  9114. }
  9115. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9116. result, _ := json.Marshal(respJSON)
  9117. fmt.Println("log")
  9118. fmt.Println(string(result))
  9119. if err := json.Unmarshal([]byte(result), &res); err != nil {
  9120. utils.ErrorLog("解析失败:%v", err)
  9121. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9122. return
  9123. }
  9124. if res.Infcode == 0 {
  9125. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  9126. if err == gorm.ErrRecordNotFound {
  9127. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  9128. return
  9129. } else if err != nil {
  9130. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  9131. return
  9132. } else {
  9133. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9134. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9135. infoStr := string(Iinfos)
  9136. idetinfoStr := string(Idetinfos)
  9137. psn := &models.HisPsn{
  9138. PsnNo: res.Output.Baseinfo.PsnNo,
  9139. PatientId: patient.ID,
  9140. Certno: res.Output.Baseinfo.Certno,
  9141. Gend: res.Output.Baseinfo.Gend,
  9142. Naty: res.Output.Baseinfo.Naty,
  9143. PsnCertType: res.Output.Baseinfo.PsnCertType,
  9144. PsnName: res.Output.Baseinfo.PsnName,
  9145. Idetinfo: idetinfoStr,
  9146. Insuinfo: infoStr,
  9147. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9148. }
  9149. service.CreateHisPsn(psn)
  9150. c.ServeSuccessJSON(map[string]interface{}{
  9151. "patient": patient,
  9152. "number": res.Output.Baseinfo.Certno,
  9153. })
  9154. }
  9155. } else {
  9156. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9157. return
  9158. }
  9159. } else if miConfig.MdtrtareaAdmvs == "421182" {
  9160. var res ResultTwo
  9161. api := miConfig.Url + "hbyb/1101?cert_no=" + "" +
  9162. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  9163. "&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)
  9164. resp, requestErr := http.Get(api)
  9165. if requestErr != nil {
  9166. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9167. return
  9168. }
  9169. body, ioErr := ioutil.ReadAll(resp.Body)
  9170. if ioErr != nil {
  9171. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9172. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9173. return
  9174. }
  9175. var respJSON map[string]interface{}
  9176. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9177. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9178. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9179. return
  9180. }
  9181. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9182. result, _ := json.Marshal(respJSON)
  9183. fmt.Println("log")
  9184. fmt.Println(string(result))
  9185. if err := json.Unmarshal([]byte(result), &res); err != nil {
  9186. utils.ErrorLog("解析失败:%v", err)
  9187. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9188. return
  9189. }
  9190. if res.Infcode == 0 {
  9191. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  9192. if err == gorm.ErrRecordNotFound {
  9193. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  9194. return
  9195. } else if err != nil {
  9196. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  9197. return
  9198. } else {
  9199. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9200. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9201. infoStr := string(Iinfos)
  9202. idetinfoStr := string(Idetinfos)
  9203. psn := &models.HisPsn{
  9204. PsnNo: res.Output.Baseinfo.PsnNo,
  9205. PatientId: patient.ID,
  9206. Certno: res.Output.Baseinfo.Certno,
  9207. Gend: res.Output.Baseinfo.Gend,
  9208. Naty: res.Output.Baseinfo.Naty,
  9209. PsnCertType: res.Output.Baseinfo.PsnCertType,
  9210. PsnName: res.Output.Baseinfo.PsnName,
  9211. Idetinfo: idetinfoStr,
  9212. Insuinfo: infoStr,
  9213. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9214. }
  9215. service.CreateHisPsn(psn)
  9216. c.ServeSuccessJSON(map[string]interface{}{
  9217. "patient": patient,
  9218. "number": res.Output.Baseinfo.Certno,
  9219. })
  9220. }
  9221. } else {
  9222. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9223. return
  9224. }
  9225. } else if miConfig.MdtrtareaAdmvs == "420902" {
  9226. var res ResultTwo
  9227. api := miConfig.Url + "hbyb/1101?cert_no=" + "" +
  9228. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  9229. "&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)
  9230. resp, requestErr := http.Get(api)
  9231. if requestErr != nil {
  9232. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9233. return
  9234. }
  9235. body, ioErr := ioutil.ReadAll(resp.Body)
  9236. if ioErr != nil {
  9237. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9238. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9239. return
  9240. }
  9241. var respJSON map[string]interface{}
  9242. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9243. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9244. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9245. return
  9246. }
  9247. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9248. result, _ := json.Marshal(respJSON)
  9249. fmt.Println("log")
  9250. fmt.Println(string(result))
  9251. if err := json.Unmarshal([]byte(result), &res); err != nil {
  9252. utils.ErrorLog("解析失败:%v", err)
  9253. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9254. return
  9255. }
  9256. if res.Infcode == 0 {
  9257. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  9258. if err == gorm.ErrRecordNotFound {
  9259. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  9260. return
  9261. } else if err != nil {
  9262. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  9263. return
  9264. } else {
  9265. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9266. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9267. infoStr := string(Iinfos)
  9268. idetinfoStr := string(Idetinfos)
  9269. var rf []*ResultFive
  9270. json.Unmarshal([]byte(infoStr), &rf)
  9271. var insutypes []*ResultFive
  9272. var insutype string
  9273. var is390 int = 0
  9274. var is310 int = 0
  9275. for _, item := range rf {
  9276. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  9277. insutypes = append(insutypes, item)
  9278. }
  9279. }
  9280. if len(insutypes) == 1 {
  9281. insutype = insutypes[0].Insutype
  9282. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  9283. } else {
  9284. for _, i := range insutypes {
  9285. if i.Insutype == "390" {
  9286. is390 = 1
  9287. }
  9288. if i.Insutype == "310" {
  9289. is310 = 1
  9290. }
  9291. }
  9292. }
  9293. if is390 == 1 {
  9294. insutype = "390"
  9295. }
  9296. if is310 == 1 {
  9297. insutype = "310"
  9298. }
  9299. if len(insutypes) == 0 {
  9300. insutype = "390"
  9301. }
  9302. var insuplc_admdvs string
  9303. for _, item := range rf {
  9304. if item.Insutype == insutype {
  9305. insuplc_admdvs = item.InsuplcAdmdvs
  9306. }
  9307. }
  9308. psn := &models.HisPsn{
  9309. PsnNo: res.Output.Baseinfo.PsnNo,
  9310. PatientId: patient.ID,
  9311. Certno: res.Output.Baseinfo.Certno,
  9312. Gend: res.Output.Baseinfo.Gend,
  9313. Naty: res.Output.Baseinfo.Naty,
  9314. PsnCertType: res.Output.Baseinfo.PsnCertType,
  9315. PsnName: res.Output.Baseinfo.PsnName,
  9316. Idetinfo: idetinfoStr,
  9317. Insuinfo: infoStr,
  9318. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9319. InsuplcAdmdvs: insuplc_admdvs,
  9320. }
  9321. service.CreateHisPsn(psn)
  9322. c.ServeSuccessJSON(map[string]interface{}{
  9323. "patient": patient,
  9324. "number": res.Output.Baseinfo.Certno,
  9325. })
  9326. }
  9327. } else {
  9328. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9329. return
  9330. }
  9331. } else if miConfig.MdtrtareaAdmvs == "450721" {
  9332. res := c.GetoleInfo()
  9333. if res.Infcode == 0 {
  9334. var result string
  9335. if res.Output.MdtrtCertType == "01" {
  9336. 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)
  9337. } else if res.Output.MdtrtCertType == "02" {
  9338. 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)
  9339. } else if res.Output.MdtrtCertType == "03" {
  9340. 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)
  9341. }
  9342. var dat map[string]interface{}
  9343. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9344. fmt.Println(dat)
  9345. } else {
  9346. fmt.Println(err)
  9347. }
  9348. userJSONBytes, _ := json.Marshal(dat)
  9349. var res2 ResultTwo
  9350. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  9351. utils.ErrorLog("解析失败:%v", err)
  9352. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9353. return
  9354. }
  9355. if res2.Infcode == 0 {
  9356. patient, err := service.GetPatientByNumber(res.Output.CertNo, c.GetAdminUserInfo().CurrentOrgId)
  9357. if err == gorm.ErrRecordNotFound {
  9358. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  9359. return
  9360. } else if err != nil {
  9361. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  9362. return
  9363. } else {
  9364. Iinfos, _ := json.Marshal(res2.Output.Iinfo)
  9365. Idetinfos, _ := json.Marshal(res2.Output.Idetinfo)
  9366. infoStr := string(Iinfos)
  9367. idetinfoStr := string(Idetinfos)
  9368. var rf []*ResultFive
  9369. json.Unmarshal([]byte(infoStr), &rf)
  9370. var insutypes []*ResultFive
  9371. var insutype string
  9372. var is390 int = 0
  9373. var is310 int = 0
  9374. //var insuplc_admdvs string
  9375. for _, item := range rf {
  9376. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  9377. insutypes = append(insutypes, item)
  9378. }
  9379. }
  9380. if len(insutypes) == 1 {
  9381. insutype = insutypes[0].Insutype
  9382. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  9383. } else {
  9384. for _, i := range insutypes {
  9385. if i.Insutype == "390" {
  9386. is390 = 1
  9387. }
  9388. if i.Insutype == "310" {
  9389. is310 = 1
  9390. }
  9391. }
  9392. }
  9393. if is390 == 1 {
  9394. insutype = "390"
  9395. }
  9396. if is310 == 1 {
  9397. insutype = "310"
  9398. }
  9399. if len(insutypes) == 0 {
  9400. insutype = "310"
  9401. }
  9402. psn := &models.HisPsn{
  9403. PsnNo: res2.Output.Baseinfo.PsnNo,
  9404. PatientId: patient.ID,
  9405. //Brdy: res2.Output.Baseinfo.Brdy,
  9406. Certno: res2.Output.Baseinfo.Certno,
  9407. Gend: res2.Output.Baseinfo.Gend,
  9408. Naty: res2.Output.Baseinfo.Naty,
  9409. PsnCertType: res2.Output.Baseinfo.PsnCertType,
  9410. PsnName: res2.Output.Baseinfo.PsnName,
  9411. Idetinfo: idetinfoStr,
  9412. Insuinfo: infoStr,
  9413. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9414. CardInfo: res.Output.CertNo + "|" + res.Output.CardSN,
  9415. VerifyNumber: res.Output.EcToken,
  9416. InsuplcAdmdvs: res.Output.InsuplcAdmdvs,
  9417. }
  9418. service.CreateHisPsn(psn)
  9419. var balc float64
  9420. for _, item := range rf {
  9421. if item.Insutype == insutype {
  9422. balc = item.Balc
  9423. }
  9424. }
  9425. c.ServeSuccessJSON(map[string]interface{}{
  9426. "patient": patient,
  9427. "number": res.Output.CardNo,
  9428. "insutype": insutype,
  9429. "blac": balc,
  9430. "desc": idetinfoStr,
  9431. })
  9432. }
  9433. } else {
  9434. c.ServeSuccessJSON(map[string]interface{}{
  9435. "failed_code": -10,
  9436. "msg": res2.ErrMsg,
  9437. })
  9438. }
  9439. } else {
  9440. c.ServeSuccessJSON(map[string]interface{}{
  9441. "failed_code": -10,
  9442. "msg": res.ErrMsg,
  9443. })
  9444. }
  9445. } else {
  9446. SFZStr := c.GetSFZBaseInfo()
  9447. id_card_str := strings.Split(SFZStr, "^")
  9448. id_card_number := id_card_str[0]
  9449. card_sn := ""
  9450. 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)
  9451. var dat map[string]interface{}
  9452. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9453. fmt.Println(dat)
  9454. } else {
  9455. fmt.Println(err)
  9456. }
  9457. userJSONBytes, _ := json.Marshal(dat)
  9458. var res ResultTwo
  9459. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9460. utils.ErrorLog("解析失败:%v", err)
  9461. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9462. return
  9463. }
  9464. if res.Infcode == 0 {
  9465. patient, err := service.GetPatientByNumber(id_card_number, c.GetAdminUserInfo().CurrentOrgId)
  9466. if err == gorm.ErrRecordNotFound {
  9467. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  9468. return
  9469. } else if err != nil {
  9470. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  9471. return
  9472. } else {
  9473. c.ServeSuccessJSON(map[string]interface{}{
  9474. "patient": patient,
  9475. "number": id_card_number,
  9476. })
  9477. }
  9478. } else {
  9479. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9480. return
  9481. }
  9482. }
  9483. break
  9484. case 3:
  9485. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  9486. var api string
  9487. if miConfig.MdtrtareaAdmvs == "320921" {
  9488. 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 +
  9489. "&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
  9490. fmt.Println(api)
  9491. } else {
  9492. 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 +
  9493. "&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)
  9494. }
  9495. resp, requestErr := http.Get(api)
  9496. if requestErr != nil {
  9497. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9498. return
  9499. }
  9500. body, ioErr := ioutil.ReadAll(resp.Body)
  9501. if ioErr != nil {
  9502. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9503. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9504. return
  9505. }
  9506. var respJSON map[string]interface{}
  9507. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9508. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9509. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9510. return
  9511. }
  9512. var status string
  9513. status = respJSON["data"].(map[string]interface{})["status"].(string)
  9514. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  9515. var token string
  9516. var res ResultTwo //1101结果
  9517. var res10265 ResultTwo10265 //1101结果
  9518. var card_info string //卡信息
  9519. var busi_card_info string
  9520. //card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  9521. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  9522. if status == "0" { //读卡成功
  9523. if card_type == "1" {
  9524. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  9525. result, _ := json.Marshal(respJSON)
  9526. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  9527. utils.ErrorLog("解析失败:%v", err)
  9528. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9529. return
  9530. }
  9531. res.ErrMsg = res10265.ErrMsg
  9532. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  9533. res.Infcode = infocode
  9534. res.Output = res10265.Output
  9535. res.InfRefmsgid = res10265.InfRefmsgid
  9536. } else {
  9537. //var card_info string //卡信息
  9538. //var busi_card_info string
  9539. token = respJSON["data"].(map[string]interface{})["token"].(string)
  9540. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  9541. //fmt.Println(card_info)
  9542. //fmt.Println(busi_card_info)
  9543. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  9544. result, _ := json.Marshal(respJSON)
  9545. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  9546. utils.ErrorLog("解析失败:%v", err)
  9547. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9548. return
  9549. }
  9550. res.ErrMsg = res10265.ErrMsg
  9551. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  9552. res.Infcode = infocode
  9553. res.Output = res10265.Output
  9554. res.InfRefmsgid = res10265.InfRefmsgid
  9555. }
  9556. if res.Infcode == 0 {
  9557. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  9558. if err == gorm.ErrRecordNotFound {
  9559. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  9560. return
  9561. } else if err != nil {
  9562. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  9563. return
  9564. } else {
  9565. if card_type == "1" {
  9566. bas := strings.Split(card_info, "|")
  9567. basNumber := bas[2]
  9568. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9569. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9570. infoStr := string(Iinfos)
  9571. idetinfoStr := string(Idetinfos)
  9572. psn := &models.HisPsn{
  9573. PsnNo: res.Output.Baseinfo.PsnNo,
  9574. PatientId: patient.ID,
  9575. Certno: res.Output.Baseinfo.Certno,
  9576. //Brdy: res.Output.Baseinfo.Brdy,
  9577. Gend: res.Output.Baseinfo.Gend,
  9578. Naty: res.Output.Baseinfo.Naty,
  9579. PsnCertType: res.Output.Baseinfo.PsnCertType,
  9580. PsnName: res.Output.Baseinfo.PsnName,
  9581. Idetinfo: idetinfoStr,
  9582. Insuinfo: infoStr,
  9583. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9584. CardInfo: card_info,
  9585. VerifyNumber: busi_card_info,
  9586. }
  9587. service.CreateHisPsn(psn)
  9588. c.ServeSuccessJSON(map[string]interface{}{
  9589. "patient": patient,
  9590. "number": basNumber,
  9591. })
  9592. } else {
  9593. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9594. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9595. infoStr := string(Iinfos)
  9596. idetinfoStr := string(Idetinfos)
  9597. psn := &models.HisPsn{
  9598. PsnNo: res.Output.Baseinfo.PsnNo,
  9599. PatientId: patient.ID,
  9600. Certno: res.Output.Baseinfo.Certno,
  9601. Gend: res.Output.Baseinfo.Gend,
  9602. Naty: res.Output.Baseinfo.Naty,
  9603. PsnCertType: res.Output.Baseinfo.PsnCertType,
  9604. PsnName: res.Output.Baseinfo.PsnName,
  9605. Idetinfo: idetinfoStr,
  9606. Insuinfo: infoStr,
  9607. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9608. CardInfo: card_info,
  9609. VerifyNumber: token,
  9610. }
  9611. service.CreateHisPsn(psn)
  9612. var rf []*ResultFive
  9613. json.Unmarshal([]byte(infoStr), &rf)
  9614. var insutypes []*ResultFive
  9615. var insutype string
  9616. var is390 int = 0
  9617. var is310 int = 0
  9618. for _, item := range rf {
  9619. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  9620. insutypes = append(insutypes, item)
  9621. }
  9622. }
  9623. if len(insutypes) == 1 {
  9624. insutype = insutypes[0].Insutype
  9625. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  9626. } else {
  9627. for _, i := range insutypes {
  9628. if i.Insutype == "390" {
  9629. is390 = 1
  9630. }
  9631. if i.Insutype == "310" {
  9632. is310 = 1
  9633. }
  9634. }
  9635. }
  9636. if is390 == 1 {
  9637. insutype = "390"
  9638. }
  9639. if is310 == 1 {
  9640. insutype = "310"
  9641. }
  9642. if len(insutypes) == 0 {
  9643. insutype = "310"
  9644. }
  9645. c.ServeSuccessJSON(map[string]interface{}{
  9646. "patient": patient,
  9647. "number": token,
  9648. "insutype": insutype,
  9649. })
  9650. }
  9651. }
  9652. } else {
  9653. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9654. return
  9655. }
  9656. } else { //读卡失败
  9657. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9658. return
  9659. }
  9660. }
  9661. break
  9662. case 4:
  9663. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  9664. var api string
  9665. if miConfig.MdtrtareaAdmvs == "320921" {
  9666. 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 +
  9667. "&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
  9668. fmt.Println(api)
  9669. } else {
  9670. 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 +
  9671. "&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)
  9672. }
  9673. resp, requestErr := http.Get(api)
  9674. if requestErr != nil {
  9675. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9676. return
  9677. }
  9678. body, ioErr := ioutil.ReadAll(resp.Body)
  9679. if ioErr != nil {
  9680. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9681. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9682. return
  9683. }
  9684. var respJSON map[string]interface{}
  9685. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9686. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9687. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9688. return
  9689. }
  9690. var status string
  9691. status = respJSON["data"].(map[string]interface{})["status"].(string)
  9692. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  9693. var token string
  9694. var res ResultTwo //1101结果
  9695. var res10265 ResultTwo10265 //1101结果
  9696. if status == "0" { //读卡成功
  9697. var card_info string //卡信息
  9698. var busi_card_info string
  9699. token = respJSON["data"].(map[string]interface{})["token"].(string)
  9700. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  9701. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  9702. fmt.Println(card_info)
  9703. fmt.Println(busi_card_info)
  9704. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  9705. result, _ := json.Marshal(respJSON)
  9706. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  9707. utils.ErrorLog("解析失败:%v", err)
  9708. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9709. return
  9710. }
  9711. res.ErrMsg = res10265.ErrMsg
  9712. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  9713. res.Infcode = infocode
  9714. res.Output = res10265.Output
  9715. res.InfRefmsgid = res10265.InfRefmsgid
  9716. if res.Infcode == 0 {
  9717. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  9718. if err == gorm.ErrRecordNotFound {
  9719. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  9720. return
  9721. } else if err != nil {
  9722. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  9723. return
  9724. } else {
  9725. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9726. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9727. infoStr := string(Iinfos)
  9728. idetinfoStr := string(Idetinfos)
  9729. b, age, _ := getBirthdateAndAge(res.Output.Baseinfo.Certno)
  9730. psn := &models.HisPsn{
  9731. PsnNo: res.Output.Baseinfo.PsnNo,
  9732. PatientId: patient.ID,
  9733. Certno: res.Output.Baseinfo.Certno,
  9734. Brdy: b,
  9735. Age: float64(age),
  9736. //Brdy: res.Output.Baseinfo.Brdy,
  9737. Gend: res.Output.Baseinfo.Gend,
  9738. Naty: res.Output.Baseinfo.Naty,
  9739. PsnCertType: res.Output.Baseinfo.PsnCertType,
  9740. PsnName: res.Output.Baseinfo.PsnName,
  9741. Idetinfo: idetinfoStr,
  9742. Insuinfo: infoStr,
  9743. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9744. CardInfo: card_info,
  9745. VerifyNumber: token,
  9746. }
  9747. var rf []*ResultFive
  9748. json.Unmarshal([]byte(infoStr), &rf)
  9749. var insutypes []*ResultFive
  9750. var insutype string
  9751. var is390 int = 0
  9752. var is310 int = 0
  9753. for _, item := range rf {
  9754. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  9755. insutypes = append(insutypes, item)
  9756. }
  9757. }
  9758. if len(insutypes) == 1 {
  9759. insutype = insutypes[0].Insutype
  9760. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  9761. } else {
  9762. for _, i := range insutypes {
  9763. if i.Insutype == "390" {
  9764. is390 = 1
  9765. }
  9766. if i.Insutype == "310" {
  9767. is310 = 1
  9768. }
  9769. }
  9770. }
  9771. if is390 == 1 {
  9772. insutype = "390"
  9773. }
  9774. if is310 == 1 {
  9775. insutype = "310"
  9776. }
  9777. if len(insutypes) == 0 {
  9778. insutype = "310"
  9779. }
  9780. service.CreateHisPsn(psn)
  9781. c.ServeSuccessJSON(map[string]interface{}{
  9782. "patient": patient,
  9783. "number": token,
  9784. "insutype": insutype,
  9785. })
  9786. }
  9787. } else {
  9788. c.ServeSuccessJSON(map[string]interface{}{
  9789. "failed_code": -10,
  9790. "msg": res.ErrMsg,
  9791. })
  9792. }
  9793. } else { //读卡失败
  9794. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9795. return
  9796. }
  9797. } else if miConfig.MdtrtareaAdmvs == "341203" {
  9798. var api string
  9799. api = miConfig.SecretKey + "ahyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  9800. "&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
  9801. resp, requestErr := http.Get(api)
  9802. if requestErr != nil {
  9803. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9804. return
  9805. }
  9806. body, ioErr := ioutil.ReadAll(resp.Body)
  9807. if ioErr != nil {
  9808. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9809. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9810. return
  9811. }
  9812. var respJSON map[string]interface{}
  9813. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9814. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9815. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9816. return
  9817. }
  9818. var status string
  9819. status = respJSON["data"].(map[string]interface{})["status"].(string)
  9820. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  9821. var token string
  9822. var res ResultTwo //1101结果
  9823. if status == "1" { //读卡成功
  9824. var card_info string //卡信息
  9825. var busi_card_info string
  9826. token = respJSON["data"].(map[string]interface{})["token"].(string)
  9827. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  9828. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  9829. fmt.Println(card_info)
  9830. fmt.Println(busi_card_info)
  9831. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  9832. result, _ := json.Marshal(respJSON)
  9833. if err := json.Unmarshal([]byte(result), &res); err != nil {
  9834. utils.ErrorLog("解析失败:%v", err)
  9835. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9836. return
  9837. }
  9838. if res.Infcode == 0 {
  9839. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  9840. if err == gorm.ErrRecordNotFound {
  9841. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  9842. return
  9843. } else if err != nil {
  9844. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  9845. return
  9846. } else {
  9847. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9848. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9849. infoStr := string(Iinfos)
  9850. idetinfoStr := string(Idetinfos)
  9851. psn := &models.HisPsn{
  9852. PsnNo: res.Output.Baseinfo.PsnNo,
  9853. PatientId: patient.ID,
  9854. Certno: res.Output.Baseinfo.Certno,
  9855. Gend: res.Output.Baseinfo.Gend,
  9856. Naty: res.Output.Baseinfo.Naty,
  9857. PsnCertType: res.Output.Baseinfo.PsnCertType,
  9858. PsnName: res.Output.Baseinfo.PsnName,
  9859. Idetinfo: idetinfoStr,
  9860. Insuinfo: infoStr,
  9861. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9862. CardInfo: card_info,
  9863. VerifyNumber: token,
  9864. }
  9865. var rf []*ResultFive
  9866. json.Unmarshal([]byte(infoStr), &rf)
  9867. var insutypes []*ResultFive
  9868. var insutype string
  9869. var is390 int = 0
  9870. var is310 int = 0
  9871. for _, item := range rf {
  9872. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  9873. insutypes = append(insutypes, item)
  9874. }
  9875. }
  9876. if len(insutypes) == 1 {
  9877. insutype = insutypes[0].Insutype
  9878. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  9879. } else {
  9880. for _, i := range insutypes {
  9881. if i.Insutype == "390" {
  9882. is390 = 1
  9883. }
  9884. if i.Insutype == "310" {
  9885. is310 = 1
  9886. }
  9887. }
  9888. }
  9889. if is390 == 1 {
  9890. insutype = "390"
  9891. }
  9892. if is310 == 1 {
  9893. insutype = "310"
  9894. }
  9895. if len(insutypes) == 0 {
  9896. insutype = "310"
  9897. }
  9898. service.CreateHisPsn(psn)
  9899. c.ServeSuccessJSON(map[string]interface{}{
  9900. "patient": patient,
  9901. "number": token,
  9902. "insutype": insutype,
  9903. })
  9904. }
  9905. } else {
  9906. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9907. return
  9908. }
  9909. } else { //读卡失败
  9910. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9911. return
  9912. }
  9913. } else if miConfig.MdtrtareaAdmvs == "430800" {
  9914. idNo := c.GetString("idNo")
  9915. userName := c.GetString("userName")
  9916. ecToken := c.GetString("ecToken")
  9917. insuOrg := c.GetString("insuOrg")
  9918. result2, requestLog2 := service.Hnyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, insuOrg, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, ecToken, "", idNo, userName)
  9919. saveLog(result2, requestLog2, "1101", "获取人员信息")
  9920. var res ResultTwo
  9921. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  9922. utils.ErrorLog("解析失败:%v", err)
  9923. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9924. return
  9925. }
  9926. if res.Infcode == 0 {
  9927. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  9928. if err == gorm.ErrRecordNotFound {
  9929. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  9930. return
  9931. } else if err != nil {
  9932. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  9933. return
  9934. } else {
  9935. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9936. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9937. infoStr := string(Iinfos)
  9938. idetinfoStr := string(Idetinfos)
  9939. psn := &models.HisPsn{
  9940. PsnNo: res.Output.Baseinfo.PsnNo,
  9941. PatientId: patient.ID,
  9942. Certno: res.Output.Baseinfo.Certno,
  9943. Gend: res.Output.Baseinfo.Gend,
  9944. Naty: res.Output.Baseinfo.Naty,
  9945. PsnCertType: res.Output.Baseinfo.PsnCertType,
  9946. PsnName: res.Output.Baseinfo.PsnName,
  9947. Idetinfo: idetinfoStr,
  9948. Insuinfo: infoStr,
  9949. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9950. CardInfo: "",
  9951. Stage: "1",
  9952. VerifyNumber: ecToken,
  9953. InsuplcAdmdvs: insuOrg,
  9954. }
  9955. service.CreateHisPsn(psn)
  9956. var rf []*ResultFive
  9957. json.Unmarshal([]byte(infoStr), &rf)
  9958. var insutypes []*ResultFive
  9959. var insutype string
  9960. var is390 int = 0
  9961. var is310 int = 0
  9962. for _, item := range rf {
  9963. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  9964. insutypes = append(insutypes, item)
  9965. }
  9966. }
  9967. if len(insutypes) == 1 {
  9968. insutype = insutypes[0].Insutype
  9969. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  9970. } else {
  9971. for _, i := range insutypes {
  9972. if i.Insutype == "390" {
  9973. is390 = 1
  9974. }
  9975. if i.Insutype == "310" {
  9976. is310 = 1
  9977. }
  9978. }
  9979. }
  9980. if is390 == 1 {
  9981. insutype = "390"
  9982. }
  9983. if is310 == 1 {
  9984. insutype = "310"
  9985. }
  9986. if len(insutypes) == 0 {
  9987. insutype = "310"
  9988. }
  9989. c.ServeSuccessJSON(map[string]interface{}{
  9990. "patient": patient,
  9991. "number": ecToken,
  9992. "insutype": insutype,
  9993. })
  9994. }
  9995. } else {
  9996. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9997. return
  9998. }
  9999. } else if miConfig.MdtrtareaAdmvs == "360302" {
  10000. //if initFlag == 0 {
  10001. //c.TestGetJiangXiBasBaseInit()
  10002. //}
  10003. //if initEleFlag == 0 {
  10004. // GetJxEleBaseInitInfo(c.GetAdminUserInfo().CurrentOrgId)
  10005. //}
  10006. //_, result2 := GetjxELekeyInfo(miConfig.Code, "1", roles.UserName)
  10007. _, result := GetjxELeInfoaaa(miConfig.Code, "1", roles.UserName)
  10008. //json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  10009. type ELeData struct {
  10010. Data struct {
  10011. IdNo string `json:"idNo"`
  10012. IdType string `json:"idType"`
  10013. UserName string `json:"userName"`
  10014. EcToken string `json:"ecToken"`
  10015. InsuOrg string `json:"insuOrg"`
  10016. Gender string `json:"gender"`
  10017. Birthday string `json:"birthday"`
  10018. Nationality string `json:"nationality"`
  10019. Email string `json:"email"`
  10020. Extra string `json:"extra"`
  10021. } `json:"data"`
  10022. Code int `json:"code"`
  10023. Message string `json:"message"`
  10024. }
  10025. var ele ELeData
  10026. err := json.Unmarshal([]byte(result), &ele)
  10027. if err != nil {
  10028. utils.ErrorLog("解析失败:%v", err)
  10029. }
  10030. token := ele.Data.EcToken
  10031. token = Remove0000(token)
  10032. 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)
  10033. saveLog(result2, requestLog2, "1101", "获取人员信息")
  10034. var res ResultTwo
  10035. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  10036. utils.ErrorLog("解析失败:%v", err)
  10037. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10038. return
  10039. }
  10040. if res.Infcode == 0 {
  10041. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  10042. if err == gorm.ErrRecordNotFound {
  10043. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  10044. return
  10045. } else if err != nil {
  10046. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  10047. return
  10048. } else {
  10049. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  10050. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  10051. infoStr := string(Iinfos)
  10052. idetinfoStr := string(Idetinfos)
  10053. psn := &models.HisPsn{
  10054. PsnNo: res.Output.Baseinfo.PsnNo,
  10055. PatientId: patient.ID,
  10056. Certno: res.Output.Baseinfo.Certno,
  10057. Gend: res.Output.Baseinfo.Gend,
  10058. Naty: res.Output.Baseinfo.Naty,
  10059. PsnCertType: res.Output.Baseinfo.PsnCertType,
  10060. PsnName: res.Output.Baseinfo.PsnName,
  10061. Idetinfo: idetinfoStr,
  10062. Insuinfo: infoStr,
  10063. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10064. CardInfo: "",
  10065. VerifyNumber: token,
  10066. }
  10067. service.CreateHisPsn(psn)
  10068. var rf []*ResultFive
  10069. json.Unmarshal([]byte(infoStr), &rf)
  10070. var insutypes []*ResultFive
  10071. var insutype string
  10072. var is390 int = 0
  10073. var is310 int = 0
  10074. for _, item := range rf {
  10075. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  10076. insutypes = append(insutypes, item)
  10077. }
  10078. }
  10079. if len(insutypes) == 1 {
  10080. insutype = insutypes[0].Insutype
  10081. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  10082. } else {
  10083. for _, i := range insutypes {
  10084. if i.Insutype == "390" {
  10085. is390 = 1
  10086. }
  10087. if i.Insutype == "310" {
  10088. is310 = 1
  10089. }
  10090. }
  10091. }
  10092. if is390 == 1 {
  10093. insutype = "390"
  10094. }
  10095. if is310 == 1 {
  10096. insutype = "310"
  10097. }
  10098. if len(insutypes) == 0 {
  10099. insutype = "310"
  10100. }
  10101. c.ServeSuccessJSON(map[string]interface{}{
  10102. "patient": patient,
  10103. "number": token,
  10104. "insutype": insutype,
  10105. })
  10106. }
  10107. } else {
  10108. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10109. return
  10110. }
  10111. } else if miConfig.MdtrtareaAdmvs == "430800" {
  10112. //if initFlag == 0 {
  10113. c.TestGetJiangXiBasBaseInit()
  10114. //}
  10115. //if initEleFlag == 0 {
  10116. // GetJxEleBaseInitInfo(c.GetAdminUserInfo().CurrentOrgId)
  10117. //}
  10118. json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  10119. type ELeData struct {
  10120. Data struct {
  10121. IdNo string `json:"idNo"`
  10122. IdType string `json:"idType"`
  10123. UserName string `json:"userName"`
  10124. EcToken string `json:"ecToken"`
  10125. InsuOrg string `json:"insuOrg"`
  10126. Gender string `json:"gender"`
  10127. Birthday string `json:"birthday"`
  10128. Nationality string `json:"nationality"`
  10129. Email string `json:"email"`
  10130. Extra string `json:"extra"`
  10131. } `json:"data"`
  10132. Code int `json:"code"`
  10133. Message string `json:"message"`
  10134. }
  10135. var ele ELeData
  10136. err := json.Unmarshal([]byte(json_result), &ele)
  10137. if err != nil {
  10138. utils.ErrorLog("解析失败:%v", err)
  10139. }
  10140. token := ele.Data.EcToken
  10141. token = Remove0000(token)
  10142. 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)
  10143. saveLog(result2, requestLog2, "1101", "获取人员信息")
  10144. var res ResultTwo
  10145. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  10146. utils.ErrorLog("解析失败:%v", err)
  10147. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10148. return
  10149. }
  10150. if res.Infcode == 0 {
  10151. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  10152. if err == gorm.ErrRecordNotFound {
  10153. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  10154. return
  10155. } else if err != nil {
  10156. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  10157. return
  10158. } else {
  10159. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  10160. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  10161. infoStr := string(Iinfos)
  10162. idetinfoStr := string(Idetinfos)
  10163. psn := &models.HisPsn{
  10164. PsnNo: res.Output.Baseinfo.PsnNo,
  10165. PatientId: patient.ID,
  10166. Certno: res.Output.Baseinfo.Certno,
  10167. Gend: res.Output.Baseinfo.Gend,
  10168. Naty: res.Output.Baseinfo.Naty,
  10169. PsnCertType: res.Output.Baseinfo.PsnCertType,
  10170. PsnName: res.Output.Baseinfo.PsnName,
  10171. Idetinfo: idetinfoStr,
  10172. Insuinfo: infoStr,
  10173. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10174. CardInfo: "",
  10175. VerifyNumber: token,
  10176. }
  10177. service.CreateHisPsn(psn)
  10178. var rf []*ResultFive
  10179. json.Unmarshal([]byte(infoStr), &rf)
  10180. var insutypes []*ResultFive
  10181. var insutype string
  10182. var is390 int = 0
  10183. var is310 int = 0
  10184. for _, item := range rf {
  10185. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  10186. insutypes = append(insutypes, item)
  10187. }
  10188. }
  10189. if len(insutypes) == 1 {
  10190. insutype = insutypes[0].Insutype
  10191. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  10192. } else {
  10193. for _, i := range insutypes {
  10194. if i.Insutype == "390" {
  10195. is390 = 1
  10196. }
  10197. if i.Insutype == "310" {
  10198. is310 = 1
  10199. }
  10200. }
  10201. }
  10202. if is390 == 1 {
  10203. insutype = "390"
  10204. }
  10205. if is310 == 1 {
  10206. insutype = "310"
  10207. }
  10208. if len(insutypes) == 0 {
  10209. insutype = "310"
  10210. }
  10211. c.ServeSuccessJSON(map[string]interface{}{
  10212. "patient": patient,
  10213. "number": token,
  10214. "insutype": insutype,
  10215. })
  10216. }
  10217. } else {
  10218. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10219. return
  10220. }
  10221. } else if miConfig.MdtrtareaAdmvs == "350500" {
  10222. type ELeData struct {
  10223. Code string `json:"code"`
  10224. Data struct {
  10225. Aac002 string `json:"aac002"`
  10226. Aaz500 string `json:"aaz500"`
  10227. ActCardNo string `json:"actCardNo"`
  10228. Bab520 string `json:"bab520"`
  10229. Bkz543 string `json:"bkz543"`
  10230. BusinessType string `json:"businessType"`
  10231. CertfCodg string `json:"certfCodg"`
  10232. EcIndexNo string `json:"ecIndexNo"`
  10233. EcToken string `json:"ecToken"`
  10234. ID0000 string `json:"id0000"`
  10235. IDNo string `json:"idNo"`
  10236. IDType string `json:"idType"`
  10237. Idcode string `json:"idcode"`
  10238. IdentityToken string `json:"identity_token"`
  10239. InsuOrg string `json:"insuOrg"`
  10240. OfficeID string `json:"officeId"`
  10241. OfficeName string `json:"officeName"`
  10242. OperatorID string `json:"operatorId"`
  10243. OperatorName string `json:"operatorName"`
  10244. OrgID string `json:"orgId"`
  10245. UserName string `json:"userName"`
  10246. } `json:"data"`
  10247. Infno interface{} `json:"infno"`
  10248. Message string `json:"message"`
  10249. OrgID string `json:"orgId"`
  10250. TransType string `json:"transType"`
  10251. }
  10252. inputInfo, outPutInfo, _ := service.ReadEleCard(miConfig.Code)
  10253. outPutInfo = Remove0000(outPutInfo)
  10254. if len(outPutInfo) > 0 {
  10255. var ele ELeData
  10256. err := json.Unmarshal([]byte(outPutInfo), &ele)
  10257. if err != nil {
  10258. utils.ErrorLog("解析失败:%v", err)
  10259. }
  10260. token := ele.Data.EcToken
  10261. fmt.Println(inputInfo)
  10262. fmt.Println(outPutInfo)
  10263. 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)
  10264. saveLog(result, requestLog, "1101", "获取人员信息")
  10265. var dat map[string]interface{}
  10266. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10267. fmt.Println(dat)
  10268. } else {
  10269. fmt.Println(err)
  10270. }
  10271. userJSONBytes, _ := json.Marshal(dat)
  10272. var res ResultTwo
  10273. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10274. utils.ErrorLog("解析失败:%v", err)
  10275. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10276. return
  10277. }
  10278. res.ErrMsg = errMsgLog
  10279. if res.Infcode == 0 {
  10280. patient, err := service.GetPatientByNumber(ele.Data.IDNo, c.GetAdminUserInfo().CurrentOrgId)
  10281. if err == gorm.ErrRecordNotFound {
  10282. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  10283. return
  10284. } else if err != nil {
  10285. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  10286. return
  10287. } else {
  10288. fmt.Println(res)
  10289. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  10290. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  10291. infoStr := string(Iinfos)
  10292. idetinfoStr := string(Idetinfos)
  10293. psn := &models.HisPsn{
  10294. PsnNo: res.Output.Baseinfo.PsnNo,
  10295. PatientId: patient.ID,
  10296. Certno: res.Output.Baseinfo.Certno,
  10297. Gend: res.Output.Baseinfo.Gend,
  10298. Naty: res.Output.Baseinfo.Naty,
  10299. PsnCertType: res.Output.Baseinfo.PsnCertType,
  10300. PsnName: res.Output.Baseinfo.PsnName,
  10301. Idetinfo: idetinfoStr,
  10302. Insuinfo: infoStr,
  10303. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10304. CardInfo: outPutInfo,
  10305. VerifyNumber: token,
  10306. InsuplcAdmdvs: ele.Data.InsuOrg,
  10307. }
  10308. service.CreateHisPsn(psn)
  10309. var rf []*ResultFive
  10310. json.Unmarshal([]byte(infoStr), &rf)
  10311. var insutypes []*ResultFive
  10312. var insutype string
  10313. var is390 int = 0
  10314. var is310 int = 0
  10315. for _, item := range rf {
  10316. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  10317. insutypes = append(insutypes, item)
  10318. }
  10319. }
  10320. if len(insutypes) == 1 {
  10321. insutype = insutypes[0].Insutype
  10322. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  10323. } else {
  10324. for _, i := range insutypes {
  10325. if i.Insutype == "390" {
  10326. is390 = 1
  10327. }
  10328. if i.Insutype == "310" {
  10329. is310 = 1
  10330. }
  10331. }
  10332. }
  10333. if is390 == 1 {
  10334. insutype = "390"
  10335. }
  10336. if is310 == 1 {
  10337. insutype = "310"
  10338. }
  10339. if len(insutypes) == 0 {
  10340. insutype = "310"
  10341. }
  10342. c.ServeSuccessJSON(map[string]interface{}{
  10343. "patient": patient,
  10344. "number": token,
  10345. "insutype": insutype,
  10346. })
  10347. }
  10348. } else {
  10349. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10350. return
  10351. }
  10352. }
  10353. } else if miConfig.MdtrtareaAdmvs == "150499" {
  10354. var api string
  10355. 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 +
  10356. "&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
  10357. resp, requestErr := http.Get(api)
  10358. if requestErr != nil {
  10359. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10360. return
  10361. }
  10362. body, ioErr := ioutil.ReadAll(resp.Body)
  10363. if ioErr != nil {
  10364. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10365. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10366. return
  10367. }
  10368. var respJSON map[string]interface{}
  10369. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  10370. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10371. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10372. return
  10373. }
  10374. var status string
  10375. status = respJSON["data"].(map[string]interface{})["status"].(string)
  10376. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  10377. var token string
  10378. var res ResultTwo //1101结果
  10379. var res10265 ResultTwo10265 //1101结果
  10380. if status == "0" { //读卡成功
  10381. var card_info string //卡信息
  10382. var busi_card_info string
  10383. token = respJSON["data"].(map[string]interface{})["token"].(string)
  10384. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  10385. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  10386. fmt.Println(card_info)
  10387. fmt.Println(busi_card_info)
  10388. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  10389. result, _ := json.Marshal(respJSON)
  10390. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  10391. utils.ErrorLog("解析失败:%v", err)
  10392. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10393. return
  10394. }
  10395. res.ErrMsg = res10265.ErrMsg
  10396. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  10397. res.Infcode = infocode
  10398. res.Output = res10265.Output
  10399. res.InfRefmsgid = res10265.InfRefmsgid
  10400. if res.Infcode == 0 {
  10401. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  10402. if err == gorm.ErrRecordNotFound {
  10403. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  10404. return
  10405. } else if err != nil {
  10406. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  10407. return
  10408. } else {
  10409. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  10410. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  10411. infoStr := string(Iinfos)
  10412. idetinfoStr := string(Idetinfos)
  10413. psn := &models.HisPsn{
  10414. PsnNo: res.Output.Baseinfo.PsnNo,
  10415. PatientId: patient.ID,
  10416. Certno: res.Output.Baseinfo.Certno,
  10417. Gend: res.Output.Baseinfo.Gend,
  10418. Naty: res.Output.Baseinfo.Naty,
  10419. PsnCertType: res.Output.Baseinfo.PsnCertType,
  10420. PsnName: res.Output.Baseinfo.PsnName,
  10421. Idetinfo: idetinfoStr,
  10422. Insuinfo: infoStr,
  10423. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10424. CardInfo: card_info,
  10425. VerifyNumber: token,
  10426. }
  10427. var rf []*ResultFive
  10428. json.Unmarshal([]byte(infoStr), &rf)
  10429. var insutypes []*ResultFive
  10430. var insutype string
  10431. var is390 int = 0
  10432. var is310 int = 0
  10433. for _, item := range rf {
  10434. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  10435. insutypes = append(insutypes, item)
  10436. }
  10437. }
  10438. if len(insutypes) == 1 {
  10439. insutype = insutypes[0].Insutype
  10440. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  10441. } else {
  10442. for _, i := range insutypes {
  10443. if i.Insutype == "390" {
  10444. is390 = 1
  10445. }
  10446. if i.Insutype == "310" {
  10447. is310 = 1
  10448. }
  10449. }
  10450. }
  10451. if is390 == 1 {
  10452. insutype = "390"
  10453. }
  10454. if is310 == 1 {
  10455. insutype = "310"
  10456. }
  10457. if len(insutypes) == 0 {
  10458. insutype = "310"
  10459. }
  10460. service.CreateHisPsn(psn)
  10461. c.ServeSuccessJSON(map[string]interface{}{
  10462. "patient": patient,
  10463. "number": token,
  10464. "insutype": insutype,
  10465. })
  10466. }
  10467. } else {
  10468. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10469. return
  10470. }
  10471. } else { //读卡失败
  10472. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10473. return
  10474. }
  10475. } else if miConfig.MdtrtareaAdmvs == "450721" {
  10476. res := c.GetoleInfo()
  10477. if res.Infcode == 0 {
  10478. var result string
  10479. if res.Output.MdtrtCertType == "01" {
  10480. 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)
  10481. } else if res.Output.MdtrtCertType == "02" {
  10482. 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)
  10483. } else if res.Output.MdtrtCertType == "03" {
  10484. 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)
  10485. }
  10486. var dat map[string]interface{}
  10487. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10488. fmt.Println(dat)
  10489. } else {
  10490. fmt.Println(err)
  10491. }
  10492. userJSONBytes, _ := json.Marshal(dat)
  10493. var res2 ResultTwo
  10494. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  10495. utils.ErrorLog("解析失败:%v", err)
  10496. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10497. return
  10498. }
  10499. if res2.Infcode == 0 {
  10500. patient, err := service.GetPatientByNumber(res.Output.CertNo, c.GetAdminUserInfo().CurrentOrgId)
  10501. if err == gorm.ErrRecordNotFound {
  10502. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  10503. return
  10504. } else if err != nil {
  10505. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  10506. return
  10507. } else {
  10508. Iinfos, _ := json.Marshal(res2.Output.Iinfo)
  10509. Idetinfos, _ := json.Marshal(res2.Output.Idetinfo)
  10510. infoStr := string(Iinfos)
  10511. idetinfoStr := string(Idetinfos)
  10512. var rf []*ResultFive
  10513. json.Unmarshal([]byte(infoStr), &rf)
  10514. var insutypes []*ResultFive
  10515. var insutype string
  10516. var is390 int = 0
  10517. var is310 int = 0
  10518. //var insuplc_admdvs string
  10519. for _, item := range rf {
  10520. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  10521. insutypes = append(insutypes, item)
  10522. }
  10523. }
  10524. if len(insutypes) == 1 {
  10525. insutype = insutypes[0].Insutype
  10526. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  10527. } else {
  10528. for _, i := range insutypes {
  10529. if i.Insutype == "390" {
  10530. is390 = 1
  10531. }
  10532. if i.Insutype == "310" {
  10533. is310 = 1
  10534. }
  10535. }
  10536. }
  10537. if is390 == 1 {
  10538. insutype = "390"
  10539. }
  10540. if is310 == 1 {
  10541. insutype = "310"
  10542. }
  10543. if len(insutypes) == 0 {
  10544. insutype = "310"
  10545. }
  10546. psn := &models.HisPsn{
  10547. PsnNo: res2.Output.Baseinfo.PsnNo,
  10548. PatientId: patient.ID,
  10549. Certno: res2.Output.Baseinfo.Certno,
  10550. Gend: res2.Output.Baseinfo.Gend,
  10551. Naty: res2.Output.Baseinfo.Naty,
  10552. PsnCertType: res2.Output.Baseinfo.PsnCertType,
  10553. PsnName: res2.Output.Baseinfo.PsnName,
  10554. Idetinfo: idetinfoStr,
  10555. Insuinfo: infoStr,
  10556. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10557. CardInfo: res.Output.CertNo + "|" + res.Output.CardSN,
  10558. VerifyNumber: res.Output.EcToken,
  10559. InsuplcAdmdvs: res.Output.InsuplcAdmdvs,
  10560. }
  10561. if res.Output.MdtrtCertType == "01" {
  10562. psn.VerifyNumber = res.Output.EcToken
  10563. //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)
  10564. } else if res.Output.MdtrtCertType == "02" {
  10565. psn.VerifyNumber = res.Output.CardNo
  10566. //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)
  10567. } else if res.Output.MdtrtCertType == "03" {
  10568. psn.VerifyNumber = res.Output.MdtrtCertNo
  10569. //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)
  10570. }
  10571. service.CreateHisPsn(psn)
  10572. var balc float64
  10573. for _, item := range rf {
  10574. if item.Insutype == insutype {
  10575. balc = item.Balc
  10576. }
  10577. }
  10578. c.ServeSuccessJSON(map[string]interface{}{
  10579. "patient": patient,
  10580. "number": res.Output.CardNo,
  10581. "insutype": insutype,
  10582. "blac": balc,
  10583. "desc": idetinfoStr,
  10584. })
  10585. }
  10586. } else {
  10587. c.ServeSuccessJSON(map[string]interface{}{
  10588. "failed_code": -10,
  10589. "msg": res2.ErrMsg,
  10590. })
  10591. }
  10592. } else {
  10593. c.ServeSuccessJSON(map[string]interface{}{
  10594. "failed_code": -10,
  10595. "msg": res.ErrMsg,
  10596. })
  10597. }
  10598. } else if miConfig.MdtrtareaAdmvs == "420902" {
  10599. var res ResultTwo
  10600. api := miConfig.Url + "hbyb/1101?cert_no=" + "" +
  10601. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  10602. "&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)
  10603. resp, requestErr := http.Get(api)
  10604. if requestErr != nil {
  10605. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10606. return
  10607. }
  10608. body, ioErr := ioutil.ReadAll(resp.Body)
  10609. if ioErr != nil {
  10610. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10611. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10612. return
  10613. }
  10614. var respJSON map[string]interface{}
  10615. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  10616. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10617. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10618. return
  10619. }
  10620. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10621. result, _ := json.Marshal(respJSON)
  10622. fmt.Println("log")
  10623. fmt.Println(string(result))
  10624. if err := json.Unmarshal([]byte(result), &res); err != nil {
  10625. utils.ErrorLog("解析失败:%v", err)
  10626. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10627. return
  10628. }
  10629. if res.Infcode == 0 {
  10630. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  10631. if err == gorm.ErrRecordNotFound {
  10632. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  10633. return
  10634. } else if err != nil {
  10635. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  10636. return
  10637. } else {
  10638. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  10639. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  10640. infoStr := string(Iinfos)
  10641. idetinfoStr := string(Idetinfos)
  10642. var rf []*ResultFive
  10643. json.Unmarshal([]byte(infoStr), &rf)
  10644. var insutypes []*ResultFive
  10645. var insutype string
  10646. var is390 int = 0
  10647. var is310 int = 0
  10648. for _, item := range rf {
  10649. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  10650. insutypes = append(insutypes, item)
  10651. }
  10652. }
  10653. if len(insutypes) == 1 {
  10654. insutype = insutypes[0].Insutype
  10655. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  10656. } else {
  10657. for _, i := range insutypes {
  10658. if i.Insutype == "390" {
  10659. is390 = 1
  10660. }
  10661. if i.Insutype == "310" {
  10662. is310 = 1
  10663. }
  10664. }
  10665. }
  10666. if is390 == 1 {
  10667. insutype = "390"
  10668. }
  10669. if is310 == 1 {
  10670. insutype = "310"
  10671. }
  10672. if len(insutypes) == 0 {
  10673. insutype = "390"
  10674. }
  10675. var insuplc_admdvs string
  10676. for _, item := range rf {
  10677. if item.Insutype == insutype {
  10678. insuplc_admdvs = item.InsuplcAdmdvs
  10679. }
  10680. }
  10681. psn := &models.HisPsn{
  10682. PsnNo: res.Output.Baseinfo.PsnNo,
  10683. PatientId: patient.ID,
  10684. Certno: res.Output.Baseinfo.Certno,
  10685. Gend: res.Output.Baseinfo.Gend,
  10686. Naty: res.Output.Baseinfo.Naty,
  10687. PsnCertType: res.Output.Baseinfo.PsnCertType,
  10688. PsnName: res.Output.Baseinfo.PsnName,
  10689. Idetinfo: idetinfoStr,
  10690. Insuinfo: infoStr,
  10691. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10692. InsuplcAdmdvs: insuplc_admdvs,
  10693. }
  10694. service.CreateHisPsn(psn)
  10695. c.ServeSuccessJSON(map[string]interface{}{
  10696. "patient": patient,
  10697. "number": res.Output.Baseinfo.Certno,
  10698. })
  10699. }
  10700. } else {
  10701. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10702. return
  10703. }
  10704. } else {
  10705. type ELeData struct {
  10706. Code string `json:"code"`
  10707. Data struct {
  10708. Aac002 string `json:"aac002"`
  10709. Aaz500 string `json:"aaz500"`
  10710. ActCardNo string `json:"actCardNo"`
  10711. Bab520 string `json:"bab520"`
  10712. Bkz543 string `json:"bkz543"`
  10713. BusinessType string `json:"businessType"`
  10714. CertfCodg string `json:"certfCodg"`
  10715. EcIndexNo string `json:"ecIndexNo"`
  10716. EcToken string `json:"ecToken"`
  10717. ID0000 string `json:"id0000"`
  10718. IDNo string `json:"idNo"`
  10719. IDType string `json:"idType"`
  10720. Idcode string `json:"idcode"`
  10721. IdentityToken string `json:"identity_token"`
  10722. InsuOrg string `json:"insuOrg"`
  10723. OfficeID string `json:"officeId"`
  10724. OfficeName string `json:"officeName"`
  10725. OperatorID string `json:"operatorId"`
  10726. OperatorName string `json:"operatorName"`
  10727. OrgID string `json:"orgId"`
  10728. UserName string `json:"userName"`
  10729. } `json:"data"`
  10730. Infno interface{} `json:"infno"`
  10731. Message string `json:"message"`
  10732. OrgID string `json:"orgId"`
  10733. TransType string `json:"transType"`
  10734. }
  10735. _, result := GetELeInfo(miConfig.Code, "1", roles.UserName, miConfig.MdtrtareaAdmvs)
  10736. fmt.Println(result)
  10737. outPutInfo := Remove0000(result)
  10738. fmt.Println(outPutInfo)
  10739. if len(outPutInfo) > 0 {
  10740. var ele ELeData
  10741. err := json.Unmarshal([]byte(outPutInfo), &ele)
  10742. if err != nil {
  10743. utils.ErrorLog("解析失败:%v", err)
  10744. }
  10745. token := ele.Data.EcToken
  10746. fmt.Println(outPutInfo)
  10747. 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)
  10748. saveLog(result, requestLog, "1101", "获取人员信息")
  10749. var dat map[string]interface{}
  10750. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10751. fmt.Println(dat)
  10752. } else {
  10753. fmt.Println(err)
  10754. }
  10755. userJSONBytes, _ := json.Marshal(dat)
  10756. var res ResultTwo
  10757. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10758. utils.ErrorLog("解析失败:%v", err)
  10759. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10760. return
  10761. }
  10762. if res.Infcode == 0 {
  10763. patient, err := service.GetPatientByNumber(ele.Data.IDNo, c.GetAdminUserInfo().CurrentOrgId)
  10764. if err == gorm.ErrRecordNotFound {
  10765. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  10766. return
  10767. } else if err != nil {
  10768. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  10769. return
  10770. } else {
  10771. fmt.Println(res)
  10772. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  10773. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  10774. infoStr := string(Iinfos)
  10775. idetinfoStr := string(Idetinfos)
  10776. psn := &models.HisPsn{
  10777. PsnNo: res.Output.Baseinfo.PsnNo,
  10778. PatientId: patient.ID,
  10779. Certno: res.Output.Baseinfo.Certno,
  10780. Gend: res.Output.Baseinfo.Gend,
  10781. Naty: res.Output.Baseinfo.Naty,
  10782. PsnCertType: res.Output.Baseinfo.PsnCertType,
  10783. PsnName: res.Output.Baseinfo.PsnName,
  10784. Idetinfo: idetinfoStr,
  10785. Insuinfo: infoStr,
  10786. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10787. CardInfo: outPutInfo,
  10788. VerifyNumber: token,
  10789. InsuplcAdmdvs: ele.Data.InsuOrg,
  10790. }
  10791. service.CreateHisPsn(psn)
  10792. var rf []*ResultFive
  10793. json.Unmarshal([]byte(infoStr), &rf)
  10794. var insutypes []*ResultFive
  10795. var insutype string
  10796. var is390 int = 0
  10797. var is310 int = 0
  10798. for _, item := range rf {
  10799. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  10800. insutypes = append(insutypes, item)
  10801. }
  10802. }
  10803. if len(insutypes) == 1 {
  10804. insutype = insutypes[0].Insutype
  10805. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  10806. } else {
  10807. for _, i := range insutypes {
  10808. if i.Insutype == "390" {
  10809. is390 = 1
  10810. }
  10811. if i.Insutype == "310" {
  10812. is310 = 1
  10813. }
  10814. }
  10815. }
  10816. if is390 == 1 {
  10817. insutype = "390"
  10818. }
  10819. if is310 == 1 {
  10820. insutype = "310"
  10821. }
  10822. if len(insutypes) == 0 {
  10823. insutype = "310"
  10824. }
  10825. c.ServeSuccessJSON(map[string]interface{}{
  10826. "patient": patient,
  10827. "number": token,
  10828. "insutype": insutype,
  10829. })
  10830. }
  10831. } else {
  10832. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10833. return
  10834. }
  10835. }
  10836. //fmt.Println(result)
  10837. //
  10838. //if initFlag == 0 {
  10839. // c.TestGetBasBaseInit()
  10840. //}
  10841. //token := c.GetEleBaseInfo()
  10842. //
  10843. //token = Remove0000(token)
  10844. //
  10845. //result2, requestLog2 := service.Gdyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, insuplc_admdvs_str, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, token, "", "")
  10846. //saveLog(result2, requestLog2, "1101", "获取人员信息")
  10847. ////
  10848. //var res ResultTwo
  10849. //if err := json.Unmarshal([]byte(result2), &res); err != nil {
  10850. // utils.ErrorLog("解析失败:%v", err)
  10851. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10852. // return
  10853. //}
  10854. //
  10855. //if res.Infcode == 0 {
  10856. // patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  10857. // if err == gorm.ErrRecordNotFound {
  10858. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  10859. // return
  10860. // } else if err != nil {
  10861. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  10862. // return
  10863. //
  10864. // } else {
  10865. // Iinfos, _ := json.Marshal(res.Output.Iinfo)
  10866. // Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  10867. // infoStr := string(Iinfos)
  10868. // idetinfoStr := string(Idetinfos)
  10869. //
  10870. //
  10871. //
  10872. //
  10873. // var rf []*ResultFive
  10874. // json.Unmarshal([]byte(infoStr), &rf)
  10875. //
  10876. // var insutypes []*ResultFive
  10877. // var insutype string
  10878. // var is390 int = 0
  10879. // var is310 int = 0
  10880. // var insuplc_admdvs string
  10881. //
  10882. // for _, item := range rf {
  10883. // if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  10884. // insutypes = append(insutypes, item)
  10885. // }
  10886. // }
  10887. //
  10888. // if len(insutypes) == 1 {
  10889. // insutype = insutypes[0].Insutype
  10890. // //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  10891. // } else {
  10892. // for _, i := range insutypes {
  10893. // if i.Insutype == "390" {
  10894. // is390 = 1
  10895. // }
  10896. //
  10897. // if i.Insutype == "310" {
  10898. // is310 = 1
  10899. // }
  10900. // }
  10901. // }
  10902. // if is390 == 1 {
  10903. // insutype = "390"
  10904. // }
  10905. //
  10906. // if is310 == 1 {
  10907. // insutype = "310"
  10908. // }
  10909. // if len(insutypes) == 0 {
  10910. // insutype = "310"
  10911. // }
  10912. // for _, item := range rf {
  10913. // if item.Insutype == insutype {
  10914. // insuplc_admdvs = item.InsuplcAdmdvs
  10915. // }
  10916. // }
  10917. // psn := &models.HisPsn{
  10918. // PsnNo: res.Output.Baseinfo.PsnNo,
  10919. // Age: res.Output.Baseinfo.Age,
  10920. // PatientId: patient.ID,
  10921. // Certno: res.Output.Baseinfo.Certno,
  10922. // Brdy: res.Output.Baseinfo.Brdy,
  10923. // Gend: res.Output.Baseinfo.Gend,
  10924. // Naty: res.Output.Baseinfo.Naty,
  10925. // PsnCertType: res.Output.Baseinfo.PsnCertType,
  10926. // PsnName: res.Output.Baseinfo.PsnName,
  10927. // Idetinfo: idetinfoStr,
  10928. // Insuinfo: infoStr,
  10929. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10930. // CardInfo: "",
  10931. // VerifyNumber: token,
  10932. // InsuplcAdmdvs: insuplc_admdvs,
  10933. // }
  10934. // service.CreateHisPsn(psn)
  10935. //
  10936. // c.ServeSuccessJSON(map[string]interface{}{
  10937. // "patient": patient,
  10938. // "number": token,
  10939. // })
  10940. // }
  10941. //} else {
  10942. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10943. // return
  10944. //}
  10945. }
  10946. break
  10947. case 5:
  10948. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  10949. var api string
  10950. if miConfig.MdtrtareaAdmvs == "320921" {
  10951. 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 +
  10952. "&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
  10953. fmt.Println(api)
  10954. } else {
  10955. 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 +
  10956. "&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)
  10957. }
  10958. resp, requestErr := http.Get(api)
  10959. if requestErr != nil {
  10960. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10961. return
  10962. }
  10963. body, ioErr := ioutil.ReadAll(resp.Body)
  10964. if ioErr != nil {
  10965. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10966. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10967. return
  10968. }
  10969. var respJSON map[string]interface{}
  10970. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  10971. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10972. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10973. return
  10974. }
  10975. var status string
  10976. status = respJSON["data"].(map[string]interface{})["status"].(string)
  10977. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  10978. var token string
  10979. var res ResultTwo //1101结果
  10980. var res10265 ResultTwo10265 //1101结果
  10981. if status == "0" { //读卡成功
  10982. var card_info string //卡信息
  10983. //var busi_card_info string
  10984. var auth_info string
  10985. token = respJSON["data"].(map[string]interface{})["token"].(string)
  10986. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  10987. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  10988. auth_info = respJSON["data"].(map[string]interface{})["eletwo"].(string)
  10989. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  10990. result, _ := json.Marshal(respJSON)
  10991. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  10992. utils.ErrorLog("解析失败:%v", err)
  10993. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10994. return
  10995. }
  10996. res.ErrMsg = res10265.ErrMsg
  10997. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  10998. res.Infcode = infocode
  10999. res.Output = res10265.Output
  11000. res.InfRefmsgid = res10265.InfRefmsgid
  11001. if res.Infcode == 0 {
  11002. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  11003. if err == gorm.ErrRecordNotFound {
  11004. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  11005. return
  11006. } else if err != nil {
  11007. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  11008. return
  11009. } else {
  11010. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  11011. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  11012. infoStr := string(Iinfos)
  11013. idetinfoStr := string(Idetinfos)
  11014. b, age, _ := getBirthdateAndAge(res.Output.Baseinfo.Certno)
  11015. psn := &models.HisPsn{
  11016. PsnNo: res.Output.Baseinfo.PsnNo,
  11017. PatientId: patient.ID,
  11018. Certno: res.Output.Baseinfo.Certno,
  11019. Gend: res.Output.Baseinfo.Gend,
  11020. Brdy: b,
  11021. Age: float64(age),
  11022. Naty: res.Output.Baseinfo.Naty,
  11023. PsnCertType: res.Output.Baseinfo.PsnCertType,
  11024. PsnName: res.Output.Baseinfo.PsnName,
  11025. Idetinfo: idetinfoStr,
  11026. Insuinfo: infoStr,
  11027. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  11028. CardInfo: card_info,
  11029. VerifyNumber: token,
  11030. AuthInfo: auth_info,
  11031. }
  11032. var rf []*ResultFive
  11033. json.Unmarshal([]byte(infoStr), &rf)
  11034. var insutypes []*ResultFive
  11035. var insutype string
  11036. var is390 int = 0
  11037. var is310 int = 0
  11038. for _, item := range rf {
  11039. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  11040. insutypes = append(insutypes, item)
  11041. }
  11042. }
  11043. if len(insutypes) == 1 {
  11044. insutype = insutypes[0].Insutype
  11045. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  11046. } else {
  11047. for _, i := range insutypes {
  11048. if i.Insutype == "390" {
  11049. is390 = 1
  11050. }
  11051. if i.Insutype == "310" {
  11052. is310 = 1
  11053. }
  11054. }
  11055. }
  11056. if is390 == 1 {
  11057. insutype = "390"
  11058. }
  11059. if is310 == 1 {
  11060. insutype = "310"
  11061. }
  11062. if len(insutypes) == 0 {
  11063. insutype = "310"
  11064. }
  11065. service.CreateHisPsn(psn)
  11066. c.ServeSuccessJSON(map[string]interface{}{
  11067. "patient": patient,
  11068. "number": token,
  11069. "insutype": insutype,
  11070. })
  11071. }
  11072. } else {
  11073. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  11074. return
  11075. }
  11076. } else { //读卡失败
  11077. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  11078. return
  11079. }
  11080. }
  11081. break
  11082. }
  11083. }
  11084. var initFlag int64 = 0
  11085. var initEleFlag int64 = 0
  11086. func (c *HisApiController) TestGetBasBaseInit() {
  11087. DllDef := syscall.MustLoadDLL("SSCard.dll")
  11088. Iinit := DllDef.MustFindProc("Init")
  11089. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  11090. fmt.Println("http://hosp-sz.gd.hsip.gov.cn/gdyb_api/prd/api/card/initDll")
  11091. ret, _, err := Iinit.Call(StrPtr("http://hosp-sz.gd.hsip.gov.cn/gdyb_api/prd/api/card/initDll"), StrPtr(miConfig.InsuplcAdmdvs))
  11092. if ret != 0 {
  11093. fmt.Println("SSCard的报错原因:", err)
  11094. fmt.Println("SSCard的运算结果为:", ret)
  11095. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  11096. return
  11097. }
  11098. result := int(ret)
  11099. fmt.Println("SSCard的运算结果为1:", result)
  11100. initFlag = 1
  11101. return
  11102. }
  11103. func (c *HisApiController) HandleJiangXiReadCard() {
  11104. fmt.Println("~~~~~~")
  11105. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  11106. admin_user_id, _ := c.GetInt64("admin_user_id")
  11107. id_card_type, _ := c.GetInt64("id_card_type")
  11108. //certificates, _ := c.GetInt64("certificates")
  11109. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  11110. if initFlag == 0 {
  11111. c.TestGetJiangXiBasBaseInit()
  11112. }
  11113. basStr := c.GetBasBaseInfo()
  11114. if len(basStr) == 0 {
  11115. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  11116. return
  11117. }
  11118. fmt.Println(basStr)
  11119. bas := strings.Split(basStr, "|")
  11120. basNumber := bas[1]
  11121. fmt.Println(basNumber)
  11122. card_sn := bas[3]
  11123. fmt.Println(card_sn)
  11124. 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, "")
  11125. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  11126. var dat map[string]interface{}
  11127. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11128. fmt.Println(dat)
  11129. } else {
  11130. fmt.Println(err)
  11131. }
  11132. userJSONBytes, _ := json.Marshal(dat)
  11133. var res ResultTwo
  11134. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11135. utils.ErrorLog("解析失败:%v", err)
  11136. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11137. return
  11138. }
  11139. if res.Infcode == 0 {
  11140. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  11141. if err == gorm.ErrRecordNotFound {
  11142. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  11143. return
  11144. } else if err != nil {
  11145. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  11146. return
  11147. } else {
  11148. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  11149. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  11150. infoStr := string(Iinfos)
  11151. idetinfoStr := string(Idetinfos)
  11152. psn := &models.HisPsn{
  11153. PsnNo: res.Output.Baseinfo.PsnNo,
  11154. PatientId: patient.ID,
  11155. Certno: res.Output.Baseinfo.Certno,
  11156. Gend: res.Output.Baseinfo.Gend,
  11157. Naty: res.Output.Baseinfo.Naty,
  11158. PsnCertType: res.Output.Baseinfo.PsnCertType,
  11159. PsnName: res.Output.Baseinfo.PsnName,
  11160. Idetinfo: idetinfoStr,
  11161. Insuinfo: infoStr,
  11162. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  11163. CardInfo: basStr,
  11164. VerifyNumber: "",
  11165. }
  11166. service.CreateHisPsn(psn)
  11167. c.ServeSuccessJSON(map[string]interface{}{
  11168. "patient": patient,
  11169. "number": basNumber,
  11170. })
  11171. }
  11172. } else {
  11173. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  11174. return
  11175. }
  11176. }
  11177. func (c *HisApiController) TestGetHnBasBaseInit() {
  11178. DllDef := syscall.MustLoadDLL("SSCard.dll")
  11179. Iinit := DllDef.MustFindProc("Init")
  11180. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  11181. //http://10.77.211.236/CSB/hsa-fsi-1303
  11182. ret, _, err := Iinit.Call(StrPtr("http://10.93.32.89:20001/hsa-hgs-adapt/api/card/initDll"), StrPtr("430100|10.93.32.89:20001"))
  11183. if ret != 0 {
  11184. fmt.Println("SSCard的报错原因:", err)
  11185. fmt.Println("SSCard的运算结果为:", ret)
  11186. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  11187. return
  11188. }
  11189. result := int(ret)
  11190. fmt.Println("SSCard的运算结果为1:", result)
  11191. initFlag = 1
  11192. return
  11193. }
  11194. func (c *HisApiController) TestGetJiangXiBasBaseInit() {
  11195. DllDef := syscall.MustLoadDLL("SSCard.dll")
  11196. Iinit := DllDef.MustFindProc("Init")
  11197. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  11198. //http://10.77.211.236/CSB/hsa-fsi-1303
  11199. ret, _, err := Iinit.Call(StrPtr("http://10.77.224.18:9001/1.0.0/agent-card-init"), StrPtr("360302"))
  11200. if ret != 0 {
  11201. fmt.Println("SSCard的报错原因:", err)
  11202. fmt.Println("SSCard的运算结果为:", ret)
  11203. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  11204. return
  11205. }
  11206. result := int(ret)
  11207. fmt.Println("SSCard的运算结果为1:", result)
  11208. initFlag = 1
  11209. return
  11210. }
  11211. func (c *HisApiController) GetSFZBaseInfo() string {
  11212. DllDef := syscall.MustLoadDLL("SSCard.dll")
  11213. readCard := DllDef.MustFindProc("ReadSFZ")
  11214. if readCard == nil {
  11215. fmt.Println("readcard is nil")
  11216. readCard = DllDef.MustFindProc("ReadSFZ")
  11217. }
  11218. str := make([]byte, 8096)
  11219. str1 := make([]byte, 8096)
  11220. r, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(8096), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(8096))
  11221. fmt.Println(r)
  11222. return Remove0000(string(str))
  11223. }
  11224. func (c *HisApiController) GetEleBaseInfo() string {
  11225. DllDef := syscall.MustLoadDLL("SSCard.dll")
  11226. readCard := DllDef.MustFindProc("GetQRBase")
  11227. fmt.Println(readCard)
  11228. if readCard == nil {
  11229. fmt.Println("readcard is nil")
  11230. readCard = DllDef.MustFindProc("GetQRBase")
  11231. }
  11232. str := make([]byte, 1024)
  11233. str1 := make([]byte, 1024)
  11234. ret2, _, _ := readCard.Call(uintptr(180), (uintptr)(unsafe.Pointer(&str[0])), uintptr(1024), (uintptr)(unsafe.Pointer(&str1[0])), uintptr(1024))
  11235. fmt.Println(ret2)
  11236. fmt.Println(string(str1))
  11237. fmt.Println(string(str))
  11238. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  11239. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  11240. if ret2 != 0 {
  11241. return ""
  11242. }
  11243. return string(str)
  11244. }
  11245. func GetHnEleBaseInfo(code string, operator_id int64, operator_name string) (string, string) {
  11246. DllDef := syscall.MustLoadDLL("NationECCode.dll")
  11247. readCard := DllDef.MustFindProc("NationEcTrans")
  11248. fmt.Println(readCard)
  11249. fmt.Println("!!!!!")
  11250. pBusiCardInfo := make([]byte, 2048)
  11251. input := make(map[string]interface{})
  11252. inputData := make(map[string]interface{})
  11253. inputData["orgId"] = code
  11254. inputData["businessType"] = "01101"
  11255. inputData["operatorId"] = "1"
  11256. inputData["operatorName"] = "admin"
  11257. inputData["officeId"] = "001"
  11258. inputData["officeName"] = "血透室"
  11259. inputData["deviceType"] = ""
  11260. input["data"] = inputData
  11261. input["orgId"] = code
  11262. input["transType"] = "ec.query"
  11263. bytesData, _ := json.Marshal(input)
  11264. ret2, _, _ := readCard.Call(StrPtr("https://10.93.32.89:20001/localcfc/api/hsecfc/localQrCodeQuery"), StrPtr(string(bytesData)), (uintptr)(unsafe.Pointer(&pBusiCardInfo[0])))
  11265. fmt.Println(ret2)
  11266. fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  11267. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  11268. return DeleteExtraSpace(""), DeleteExtraSpace(string(pBusiCardInfo))
  11269. }
  11270. func GetgdEleBaseInfo(code string, operator_id int64, operator_name string) (string, string) {
  11271. DllDef := syscall.MustLoadDLL("NationECCode.dll")
  11272. readCard := DllDef.MustFindProc("NationEcTrans")
  11273. fmt.Println(readCard)
  11274. fmt.Println("!!!!!")
  11275. pBusiCardInfo := make([]byte, 2048)
  11276. input := make(map[string]interface{})
  11277. inputData := make(map[string]interface{})
  11278. inputData["orgId"] = code
  11279. inputData["businessType"] = "01101"
  11280. inputData["operatorId"] = "9"
  11281. inputData["operatorName"] = "admin"
  11282. inputData["officeId"] = "001"
  11283. inputData["officeName"] = "血透室"
  11284. inputData["deviceType"] = ""
  11285. input["data"] = inputData
  11286. input["orgId"] = code
  11287. input["transType"] = "ec.query"
  11288. bytesData, _ := json.Marshal(input)
  11289. 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])))
  11290. fmt.Println(ret2)
  11291. fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  11292. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  11293. return DeleteExtraSpace(""), ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8")
  11294. }
  11295. func GetgdEleBaseInfoTwo(code string, operator_id int64, operator_name string) (string, string) {
  11296. DllDef := syscall.MustLoadDLL("NationECCode.dll")
  11297. readCard := DllDef.MustFindProc("NationEcTrans")
  11298. fmt.Println(readCard)
  11299. fmt.Println("!!!!!")
  11300. pBusiCardInfo := make([]byte, 2048)
  11301. input := make(map[string]interface{})
  11302. inputData := make(map[string]interface{})
  11303. inputData["orgId"] = code
  11304. inputData["businessType"] = "01301"
  11305. inputData["operatorId"] = "9"
  11306. inputData["operatorName"] = "admin"
  11307. inputData["officeId"] = "001"
  11308. inputData["officeName"] = "血透室"
  11309. inputData["deviceType"] = ""
  11310. input["data"] = inputData
  11311. input["orgId"] = code
  11312. input["transType"] = "ec.query"
  11313. bytesData, _ := json.Marshal(input)
  11314. 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])))
  11315. fmt.Println(ret2)
  11316. fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  11317. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  11318. return DeleteExtraSpace(""), ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8")
  11319. }
  11320. func GetJxEleBaseInfo(org_id int64) string {
  11321. DllDef := syscall.MustLoadDLL("SSCard.dll")
  11322. readCard := DllDef.MustFindProc("NationEcTrans")
  11323. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  11324. if readCard == nil {
  11325. fmt.Println("readcard is nil")
  11326. readCard = DllDef.MustFindProc("NationEcTrans")
  11327. }
  11328. str1 := make([]byte, 1024)
  11329. data := make(map[string]interface{})
  11330. inputData := make(map[string]interface{})
  11331. inputData["orgId"] = miConfig.Code
  11332. inputData["businessType"] = "01101"
  11333. inputData["operatorId"] = "test001"
  11334. inputData["operatorName"] = "cn"
  11335. inputData["officeId"] = "32760"
  11336. inputData["officeName"] = "waike"
  11337. inputData["deviceType"] = ""
  11338. data["data"] = inputData
  11339. data["transType"] = "ec.query"
  11340. data["extra "] = ""
  11341. data["orgId"] = miConfig.Code
  11342. bytesData, _ := json.Marshal(data)
  11343. //bytesData, _ := json.Marshal(data)
  11344. //bytesData = []byte(ConvertToString(string(bytesData), "utf-8", "gbk"))
  11345. ret2, _, _ := readCard.Call(StrPtr("http://10.77.224.18:9001/1.0.0/localQrCodeQuery"), (uintptr)(unsafe.Pointer(&bytesData[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  11346. fmt.Println(ret2)
  11347. fmt.Println(string(str1))
  11348. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  11349. if ret2 != 0 {
  11350. return ""
  11351. }
  11352. return Remove0000(ConvertToString(string(str1), "gbk", "utf-8"))
  11353. }
  11354. func GetJxEleBaseInitInfo(org_id int64) string {
  11355. DllDef := syscall.MustLoadDLL("SSCard.dll")
  11356. readCard := DllDef.MustFindProc("NationEcTrans")
  11357. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  11358. if readCard == nil {
  11359. fmt.Println("readcard is nil")
  11360. readCard = DllDef.MustFindProc("NationEcTrans")
  11361. }
  11362. str1 := make([]byte, 2048)
  11363. data := make(map[string]interface{})
  11364. inputData := make(map[string]interface{})
  11365. inputData["orgId"] = miConfig.Code
  11366. inputData["businessType"] = "01101"
  11367. inputData["operatorId"] = "1"
  11368. inputData["operatorName"] = "huangchuang"
  11369. inputData["officeId"] = "101"
  11370. inputData["officeName"] = "xuetou"
  11371. inputData["deviceType"] = ""
  11372. data["data"] = inputData
  11373. data["transType"] = "ec.query"
  11374. data["orgId"] = miConfig.Code
  11375. bytesData, _ := json.Marshal(data)
  11376. bytesData = []byte(ConvertToString(string(bytesData), "utf-8", "gbk"))
  11377. ret2, _, _ := readCard.Call(StrPtr("http://10.77.224.18:9001/1.0.0/getEncDynamicKey"), (uintptr)(unsafe.Pointer(&bytesData[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  11378. fmt.Println("http://10.77.224.18:9001/1.0.0/getEncDynamicKey")
  11379. fmt.Println(ret2)
  11380. fmt.Println(string(str1))
  11381. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  11382. if ret2 != 0 {
  11383. return ""
  11384. }
  11385. if len(Remove0000(ConvertToString(string(str1), "gbk", "utf-8"))) > 0 {
  11386. initEleFlag = 1
  11387. }
  11388. return Remove0000(ConvertToString(string(str1), "gbk", "utf-8"))
  11389. }
  11390. //func (c *HisApiController)GetgxBasBaseInfotwo() {
  11391. // // 构建命令
  11392. // cmd := exec.Command("python", "b.py")
  11393. //
  11394. // // 执行命令并等待完成
  11395. // output, err := cmd.CombinedOutput()
  11396. // if err != nil {
  11397. // fmt.Println("Error executing Python script:", err)
  11398. // return
  11399. // }
  11400. //
  11401. // // 打印Python脚本的输出
  11402. // fmt.Println(string(output))
  11403. //}
  11404. func (c *HisApiController) GetgxBasBaseInfo(code string) string {
  11405. DllDef := syscall.MustLoadDLL("yh_interface_xyb.dll")
  11406. readCard := DllDef.MustFindProc("gxyb_call")
  11407. if readCard == nil {
  11408. fmt.Println("readcard is nil")
  11409. readCard = DllDef.MustFindProc("gxyb_call")
  11410. }
  11411. str := make([]byte, 1024)
  11412. str1 := make([]byte, 1024)
  11413. //data := make(map[string]interface{})
  11414. currentTime := time.Now()
  11415. // 格式化时间为 "YYYYMMDDHH24MISS"
  11416. formattedTime := currentTime.Format("20060102150405")
  11417. inputData := make(map[string]interface{})
  11418. inputData2 := make(map[string]interface{})
  11419. inputData["transNo"] = "1401"
  11420. inputData["transType"] = "passwordCheck"
  11421. inputData["timestamp"] = formattedTime
  11422. inputData2["fixmedinsCode"] = code
  11423. inputData2["psnNo"] = ""
  11424. inputData["data"] = inputData2
  11425. jsonBytes, err := json.Marshal(inputData)
  11426. if err != nil {
  11427. fmt.Println("Error encoding map to JSON:", err)
  11428. }
  11429. ret2, _, _ := readCard.Call(StrPtr("1401"), (uintptr)(unsafe.Pointer(&jsonBytes[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  11430. fmt.Println(string(str1))
  11431. fmt.Println(string(str))
  11432. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  11433. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  11434. if ret2 != 0 {
  11435. return ""
  11436. }
  11437. return string(str)
  11438. }
  11439. func (c *HisApiController) GetoleInfo() Response {
  11440. ole.CoInitializeEx(0, ole.COINIT_MULTITHREADED)
  11441. defer ole.CoUninitialize()
  11442. // Replace with the ProgID or CLSID of your COM object
  11443. progID := "YinHai.XJ.Actual.Interface.New"
  11444. // Create COM object
  11445. unknown, err := oleutil.CreateObject(progID)
  11446. if err != nil {
  11447. fmt.Println("Unable to create COM object:", err)
  11448. }
  11449. defer unknown.Release()
  11450. // Query for the IDispatch interface
  11451. dispatch, err := unknown.QueryInterface(ole.IID_IDispatch)
  11452. if err != nil {
  11453. fmt.Println("Unable to get IDispatch interface:", err)
  11454. }
  11455. defer dispatch.Release()
  11456. // Prepare parameters
  11457. transNo := "1401"
  11458. transType := "passwordCheck"
  11459. timestamp := time.Now().Unix()
  11460. fixmedinsCode := "H45072101171"
  11461. psnNo := ""
  11462. data := fmt.Sprintf(`{"transNo":"%s","transType":"%s","timestamp":"%s","data":{"fixmedinsCode":"%s","psnNo":"%s"}}`, transNo, transType, timestamp, fixmedinsCode, psnNo)
  11463. result2 := ""
  11464. // Call COM object's method using the IDispatch interface
  11465. resulr, err := oleutil.CallMethod(dispatch, "gxyb_call", "1401", data, &result2)
  11466. fmt.Println(resulr)
  11467. fmt.Println(result2)
  11468. if err != nil {
  11469. fmt.Println("调用COM对象方法失败:", err)
  11470. }
  11471. var response Response
  11472. err2 := json.Unmarshal([]byte(result2), &response)
  11473. if err2 != nil {
  11474. fmt.Println("解析JSON失败:", err)
  11475. }
  11476. return response
  11477. }
  11478. func (c *HisApiController) GetBasBaseInfo() string {
  11479. DllDef := syscall.MustLoadDLL("SSCard.dll")
  11480. readCard := DllDef.MustFindProc("ReadCardBas")
  11481. if readCard == nil {
  11482. fmt.Println("readcard is nil")
  11483. readCard = DllDef.MustFindProc("ReadCardBas")
  11484. }
  11485. str := make([]byte, 1024)
  11486. str1 := make([]byte, 1024)
  11487. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), uintptr(1024), (uintptr)(unsafe.Pointer(&str1[0])), uintptr(1024))
  11488. fmt.Println(string(str1))
  11489. fmt.Println(string(str))
  11490. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  11491. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  11492. if ret2 != 0 {
  11493. return ""
  11494. }
  11495. return string(str)
  11496. }
  11497. func (c *HisApiController) GetFjBasBaseInfo() (string, string, string, string, string) {
  11498. DllDef := syscall.MustLoadDLL("chs_fjs_standard.dll")
  11499. readCard := DllDef.MustFindProc("read_cardinfo")
  11500. if readCard == nil {
  11501. fmt.Println("readcard is nil")
  11502. readCard = DllDef.MustFindProc("read_cardinfo")
  11503. }
  11504. str := make([]byte, 1024) //卡号
  11505. str1 := make([]byte, 1024) //卡识别码
  11506. str2 := make([]byte, 1024) //身份证号
  11507. str3 := make([]byte, 1024) //姓名
  11508. str4 := make([]byte, 1024) //错误信息
  11509. 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])))
  11510. fmt.Println(string(str1))
  11511. fmt.Println(string(str))
  11512. fmt.Println(string(str2))
  11513. fmt.Println(string(str3))
  11514. fmt.Println(string(str4))
  11515. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  11516. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  11517. fmt.Println(":", ConvertToString(string(str2), "gbk", "utf-8"))
  11518. fmt.Println(":", ConvertToString(string(str3), "gbk", "utf-8"))
  11519. fmt.Println(":", ConvertToString(string(str4), "gbk", "utf-8"))
  11520. if ret2 != 0 {
  11521. return "", "", "", "", ""
  11522. }
  11523. return string(str), string(str1), string(str2), string(str3), string(str4)
  11524. }
  11525. type CustomFundPay struct {
  11526. FundPayType string `json:"fund_pay_type"`
  11527. FundPayamt float64 `json:"fund_payamt"`
  11528. InscpScpAmt float64 `json:"inscp_scp_amt"`
  11529. }
  11530. //func (c *HisApiController) GetBatchSettleList() {
  11531. // start_time_str := c.GetString("start_time")
  11532. // //end_time_str := c.GetString("end_time")
  11533. // admin_user_id, _ := c.GetInt64("admin_user_id")
  11534. //
  11535. // orders,_ := service.GetHisOrderByIDThree(start_time_str)
  11536. //
  11537. // for _, item := range orders {
  11538. // order, _ := service.GetHisOrderByIDTwo(item.ID)
  11539. // roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  11540. // his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  11541. // admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  11542. // curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  11543. // //depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  11544. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  11545. // pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  11546. // doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  11547. //
  11548. // if order.ID == 0 {
  11549. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  11550. // return
  11551. // }
  11552. //
  11553. // //last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  11554. // //max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  11555. // //count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  11556. // //fmt.Println(count)
  11557. // //var zero string
  11558. // //number := count + 1
  11559. // //if number >= 1000 {
  11560. // // zero = "0000" + strconv.FormatInt(number, 10)
  11561. // //} else if number >= 10000 {
  11562. // // zero = "000" + strconv.FormatInt(number, 10)
  11563. // //} else if number >= 100000 {
  11564. // // zero = "00" + strconv.FormatInt(number, 10)
  11565. // //} else if number >= 1000000 {
  11566. // // zero = "0" + strconv.FormatInt(number, 10)
  11567. // //} else {
  11568. // // zero = strconv.FormatInt(number, 10)
  11569. // //}
  11570. // //fmt.Println(zero)
  11571. //
  11572. // struct4101 := service.Struct4101{
  11573. // PsnNo: order.PsnNo,
  11574. // MdtrtId: order.MdtrtId,
  11575. // SetlId: order.SetlId,
  11576. // PsnName: order.PsnName,
  11577. // Gend: order.Gend,
  11578. // Brdy: his.Brdy,
  11579. // Age: his.Age,
  11580. // Naty: order.Naty,
  11581. // PatnCertType: "01",
  11582. // Certno: order.Certno,
  11583. // Prfs: "90",
  11584. // ConerName: roles[0].UserName,
  11585. // PatnRlts: "99",
  11586. // ConerAddr: miConfig.OrgName,
  11587. // ConerTel: admin.Mobile,
  11588. // HiType: order.Insutype,
  11589. // Insuplc: miConfig.InsuplcAdmdvs,
  11590. // MaindiagFlag: "1",
  11591. // BillCode: order.SetlId,
  11592. // BillNo: order.SetlId,
  11593. // BizSn: order.Number,
  11594. // PsnSelfPay: order.PsnPartAmt,
  11595. // PsnOwnPay: order.PsnPartAmt,
  11596. // AcctPay: order.AcctPay,
  11597. // PsnCashpay: order.PsnCashPay,
  11598. // HiPaymtd: "1",
  11599. // Hsorg: miConfig.InsuplcAdmdvs,
  11600. // HsorgOpter: miConfig.InsuplcAdmdvs,
  11601. // MedinsFillPsn: curRoles.UserName,
  11602. // MedinsFillDept: miConfig.OrgName,
  11603. // IptMedType: "2",
  11604. // }
  11605. // struct4101.SetlBegnDate = order.SetlTime
  11606. // struct4101.SetlEndDate = order.SetlTime
  11607. // time_arr := strings.Split(order.SetlTime, " ")
  11608. // struct4101.AdmTime = time_arr[0]
  11609. // struct4101.AdmEndTime = time_arr[0]
  11610. //
  11611. // var rf []CustomFundPay
  11612. // json.Unmarshal([]byte(order.SetlDetail), &rf)
  11613. //
  11614. // var tempFunPays []service.CustomStruct
  11615. // for _, item := range rf {
  11616. // var tempFunPay service.CustomStruct
  11617. // tempFunPay.FundPayamt = item.FundPayamt
  11618. // tempFunPay.FundPayType = item.FundPayType
  11619. // tempFunPays = append(tempFunPays, tempFunPay)
  11620. // }
  11621. // struct4101.CustomStruct = tempFunPays
  11622. //
  11623. // var tempDiaginfos []service.DiaginfoStructTwo
  11624. // var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  11625. // var tempOpspdiseinfos []service.OpspdiseinfoStruct
  11626. //
  11627. // diagnosis_ids := strings.Split(his.Diagnosis, ",")
  11628. // var config []*models.HisXtDiagnoseConfig
  11629. // for _, item := range diagnosis_ids {
  11630. // id, _ := strconv.ParseInt(item, 10, 64)
  11631. // diagnosisConfig, _ := service.FindDiagnoseById(id)
  11632. // config = append(config, &diagnosisConfig)
  11633. // }
  11634. //
  11635. // for index, item := range config {
  11636. // if index == 0 {
  11637. // var tempDiaginfo service.DiaginfoStructTwo
  11638. // tempDiaginfo.DiagCode = item.CountryCode
  11639. // tempDiaginfo.DiagName = item.CountryContentName
  11640. // tempDiaginfo.DiagType = "1"
  11641. // tempDiaginfo.MaindiagFlag = "1"
  11642. // tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  11643. // } else {
  11644. // var tempDiaginfo service.DiaginfoStructTwo
  11645. // tempDiaginfo.DiagCode = item.CountryCode
  11646. // tempDiaginfo.DiagName = item.CountryContentName
  11647. // tempDiaginfo.DiagType = "1"
  11648. // tempDiaginfo.MaindiagFlag = "0"
  11649. // tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  11650. // }
  11651. // }
  11652. // struct4101.Diseinfo = tempDiaginfos
  11653. //
  11654. // sickConfigTwo, _ := service.FindSickById(his.SickType)
  11655. // tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  11656. // tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  11657. // tempOpspdiseinfo2.OprnOprtCode = sickConfigTwo.ContentCode
  11658. // tempOpspdiseinfo2.OprnOprtName = sickConfigTwo.CountryContentName
  11659. // tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  11660. // struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  11661. //
  11662. // var iteminfo service.IteminfoStruct
  11663. //
  11664. // var bedCostTotal float64 = 0 //床位总费
  11665. // var bedCostSelfTotal float64 = 0 //床位自费
  11666. // var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  11667. //
  11668. // var operationCostTotal float64 = 0 //手术费
  11669. // var operationCostSelfTotal float64 = 0 //手术费
  11670. // var operationCostPartSelfTotal float64 = 0 //手术费
  11671. //
  11672. // var otherCostTotal float64 = 0 //其他费用
  11673. // var otherCostSelfTotal float64 = 0 //其他费用
  11674. // var otherCostPartSelfTotal float64 = 0 //其他费用
  11675. //
  11676. // var materialCostTotal float64 = 0 //材料费
  11677. // var materialCostSelfTotal float64 = 0 //材料费
  11678. // var materialCostPartSelfTotal float64 = 0 //材料费
  11679. //
  11680. // var westernMedicineCostTotal float64 = 0 //西药费
  11681. // var westernMedicineCostSelfTotal float64 = 0 //西药费
  11682. // var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  11683. //
  11684. // var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  11685. // var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  11686. // var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  11687. //
  11688. // var checkCostTotal float64 = 0 //检查费
  11689. // var checkCostSelfTotal float64 = 0 //检查费
  11690. // var checkCostPartSelfTotal float64 = 0 //检查费
  11691. //
  11692. // var laboratoryCostTotal float64 = 0 //化验费
  11693. // var laboratoryCostSelfTotal float64 = 0 //化验费
  11694. // var laboratoryCostPartSelfTotal float64 = 0 //化验费
  11695. //
  11696. // var treatCostTotal float64 = 0 //治疗费用
  11697. // var treatCostSelfTotal float64 = 0 //治疗费用
  11698. // var treatCostPartSelfTotal float64 = 0 //治疗费用
  11699. //
  11700. // decimal.DivisionPrecision = 2
  11701. //
  11702. // var bed_fulamt_ownpay_amt float64 = 0
  11703. // var operation_fulamt_ownpay_amt float64 = 0
  11704. // var other_fulamt_ownpay_amt float64 = 0
  11705. // var westernMedicine_fulamt_ownpay_amt float64 = 0
  11706. // var chineseTraditional_fulamt_ownpay_amt float64 = 0
  11707. // var check_fulamt_ownpay_amt float64 = 0
  11708. // var material_fulamt_ownpay_amt float64 = 0
  11709. // var laboratory_fulamt_ownpay_amt float64 = 0
  11710. // var treat_fulamt_ownpay_amt float64 = 0
  11711. //
  11712. // var bed_claa_sunmfee float64 = 0
  11713. // var bed_clab_amt float64 = 0
  11714. // var bed_other_amt float64 = 0
  11715. //
  11716. // var operation_claa_sunmfee float64 = 0
  11717. // var operation_clab_amt float64 = 0
  11718. // var operation_other_amt float64 = 0
  11719. //
  11720. // var other_claa_sunmfee float64 = 0
  11721. // var other_clab_amt float64 = 0
  11722. // var other_other_amt float64 = 0
  11723. //
  11724. // var westernMedicine_claa_sunmfee float64 = 0
  11725. // var westernMedicine_clab_amt float64 = 0
  11726. // var westernMedicine_other_amt float64 = 0
  11727. //
  11728. // var chineseTraditional_claa_sunmfee float64 = 0
  11729. // var chineseTraditional_clab_amt float64 = 0
  11730. // var chineseTraditional_other_amt float64 = 0
  11731. //
  11732. // var check_claa_sunmfee float64 = 0
  11733. // var check_clab_amt float64 = 0
  11734. // var check_other_amt float64 = 0
  11735. //
  11736. // var material_claa_sunmfee float64 = 0
  11737. // var material_clab_amt float64 = 0
  11738. // var material_other_amt float64 = 0
  11739. //
  11740. // var laboratory_claa_sunmfee float64 = 0
  11741. // var laboratory_clab_amt float64 = 0
  11742. // var laboratory_other_amt float64 = 0
  11743. //
  11744. // var treat_claa_sunmfee float64 = 0
  11745. // var treat_clab_amt float64 = 0
  11746. // var treat_other_amt float64 = 0
  11747. //
  11748. // for _, item := range order.HisOrderInfo {
  11749. // if item.MedChrgitmType == "01" { //床位费
  11750. // bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11751. // bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11752. // bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11753. // bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  11754. // if item.ChrgitmLv == "1" {
  11755. // bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11756. // }
  11757. // if item.ChrgitmLv == "2" {
  11758. // bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11759. //
  11760. // }
  11761. // if item.ChrgitmLv == "3" {
  11762. // bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11763. // }
  11764. //
  11765. // }
  11766. //
  11767. // if item.MedChrgitmType == "03" { //检查费
  11768. // checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11769. // checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11770. // checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11771. // check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  11772. // if item.ChrgitmLv == "1" {
  11773. //
  11774. // check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11775. //
  11776. // }
  11777. // if item.ChrgitmLv == "2" {
  11778. // check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11779. //
  11780. // }
  11781. // if item.ChrgitmLv == "3" {
  11782. // check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11783. // }
  11784. // }
  11785. //
  11786. // if item.MedChrgitmType == "04" { //化验费
  11787. // laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11788. // laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11789. // laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11790. // laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  11791. // if item.ChrgitmLv == "1" {
  11792. //
  11793. // laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11794. //
  11795. // }
  11796. // if item.ChrgitmLv == "2" {
  11797. // laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11798. //
  11799. // }
  11800. // if item.ChrgitmLv == "3" {
  11801. // laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11802. // }
  11803. // }
  11804. //
  11805. // if item.MedChrgitmType == "05" { //治疗费
  11806. // treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11807. // treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11808. // treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11809. // treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  11810. // if item.ChrgitmLv == "1" {
  11811. //
  11812. // treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11813. //
  11814. // }
  11815. // if item.ChrgitmLv == "2" {
  11816. // treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11817. //
  11818. // }
  11819. // if item.ChrgitmLv == "3" {
  11820. // treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11821. // }
  11822. // }
  11823. //
  11824. // if item.MedChrgitmType == "06" { //手术费
  11825. // operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11826. // operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11827. // operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11828. // operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  11829. //
  11830. // if item.ChrgitmLv == "1" {
  11831. //
  11832. // operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11833. //
  11834. // }
  11835. // if item.ChrgitmLv == "2" {
  11836. // operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11837. //
  11838. // }
  11839. // if item.ChrgitmLv == "3" {
  11840. // operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11841. // }
  11842. // }
  11843. //
  11844. // if item.MedChrgitmType == "08" { //材料费
  11845. // materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11846. // materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11847. // materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11848. // material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  11849. // if item.ChrgitmLv == "1" {
  11850. //
  11851. // material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11852. //
  11853. // }
  11854. // if item.ChrgitmLv == "2" {
  11855. // material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11856. //
  11857. // }
  11858. // if item.ChrgitmLv == "3" {
  11859. // material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11860. // }
  11861. // }
  11862. //
  11863. // if item.MedChrgitmType == "09" { //西药费
  11864. // westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11865. // westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11866. // westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11867. // westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  11868. // if item.ChrgitmLv == "1" {
  11869. //
  11870. // westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11871. //
  11872. // }
  11873. // if item.ChrgitmLv == "2" {
  11874. // westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11875. //
  11876. // }
  11877. // if item.ChrgitmLv == "3" {
  11878. // westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11879. // }
  11880. // }
  11881. //
  11882. // if item.MedChrgitmType == "11" { //中成费
  11883. // chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11884. // chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11885. // chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11886. // chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  11887. // if item.ChrgitmLv == "1" {
  11888. //
  11889. // chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11890. //
  11891. // }
  11892. // if item.ChrgitmLv == "2" {
  11893. // chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11894. //
  11895. // }
  11896. // if item.ChrgitmLv == "3" {
  11897. // chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11898. // }
  11899. // }
  11900. //
  11901. // if item.MedChrgitmType == "14" { //其他费
  11902. // otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11903. // otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11904. // otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11905. // other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  11906. // if item.ChrgitmLv == "1" {
  11907. // other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11908. //
  11909. // }
  11910. // if item.ChrgitmLv == "2" {
  11911. // other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11912. //
  11913. // }
  11914. // if item.ChrgitmLv == "3" {
  11915. // other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11916. // }
  11917. // }
  11918. //
  11919. // }
  11920. //
  11921. // var iteminfoStructs []service.IteminfoStruct
  11922. //
  11923. // if bedCostTotal != 0 {
  11924. // iteminfo.MedChrgitm = "01"
  11925. // iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  11926. // iteminfo.Amt = bedCostTotal
  11927. // iteminfo.ClaaSumfee = bed_claa_sunmfee
  11928. // iteminfo.ClabAmt = bed_clab_amt
  11929. // iteminfo.OthAmt = bed_other_amt
  11930. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  11931. // }
  11932. //
  11933. // if checkCostTotal != 0 {
  11934. // iteminfo.MedChrgitm = "03"
  11935. // iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  11936. // iteminfo.Amt = checkCostTotal
  11937. // iteminfo.ClaaSumfee = check_claa_sunmfee
  11938. // iteminfo.ClabAmt = check_clab_amt
  11939. // iteminfo.OthAmt = check_other_amt
  11940. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  11941. //
  11942. // }
  11943. //
  11944. // if laboratoryCostTotal != 0 {
  11945. // iteminfo.MedChrgitm = "04"
  11946. // iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  11947. // iteminfo.Amt = laboratoryCostTotal
  11948. // iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  11949. // iteminfo.ClabAmt = laboratory_clab_amt
  11950. // iteminfo.OthAmt = laboratory_other_amt
  11951. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  11952. //
  11953. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  11954. //
  11955. // }
  11956. //
  11957. // if treatCostTotal != 0 {
  11958. // iteminfo.MedChrgitm = "05"
  11959. // iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  11960. // iteminfo.Amt = treatCostTotal
  11961. // iteminfo.ClaaSumfee = treat_claa_sunmfee
  11962. // iteminfo.ClabAmt = treat_clab_amt
  11963. // iteminfo.OthAmt = treat_other_amt
  11964. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  11965. // //(struct4101.IteminfoStruct, iteminfo)
  11966. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  11967. // }
  11968. //
  11969. // if operationCostTotal != 0 {
  11970. // iteminfo.MedChrgitm = "06"
  11971. // iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  11972. // iteminfo.Amt = operationCostTotal
  11973. // iteminfo.ClaaSumfee = operation_claa_sunmfee
  11974. // iteminfo.ClabAmt = operation_clab_amt
  11975. // iteminfo.OthAmt = operation_other_amt
  11976. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  11977. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  11978. // }
  11979. //
  11980. // if materialCostTotal != 0 {
  11981. // iteminfo.MedChrgitm = "08"
  11982. // iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  11983. // iteminfo.Amt = materialCostTotal
  11984. // iteminfo.ClaaSumfee = material_claa_sunmfee
  11985. // iteminfo.ClabAmt = material_clab_amt
  11986. // iteminfo.OthAmt = material_other_amt
  11987. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  11988. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  11989. // }
  11990. //
  11991. // if westernMedicineCostTotal != 0 {
  11992. // iteminfo.MedChrgitm = "09"
  11993. // iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  11994. // iteminfo.Amt = westernMedicineCostTotal
  11995. // iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  11996. // iteminfo.ClabAmt = westernMedicine_clab_amt
  11997. // iteminfo.OthAmt = westernMedicine_other_amt
  11998. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  11999. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  12000. //
  12001. // }
  12002. // if chineseTraditionalMedicineCostTotal != 0 {
  12003. // iteminfo.MedChrgitm = "11"
  12004. // iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  12005. // iteminfo.Amt = westernMedicineCostTotal
  12006. // iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  12007. // iteminfo.ClabAmt = westernMedicine_clab_amt
  12008. // iteminfo.OthAmt = westernMedicine_other_amt
  12009. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  12010. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  12011. //
  12012. // }
  12013. // if otherCostTotal != 0 {
  12014. // iteminfo.MedChrgitm = "14"
  12015. // iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  12016. // iteminfo.Amt = otherCostTotal
  12017. // iteminfo.ClaaSumfee = other_claa_sunmfee
  12018. // iteminfo.ClabAmt = other_clab_amt
  12019. // iteminfo.OthAmt = other_other_amt
  12020. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  12021. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  12022. //
  12023. // }
  12024. // struct4101.IteminfoStruct = iteminfoStructs
  12025. // struct4101.Ntly = "中国"
  12026. // struct4101.AdmCaty = "A03.06"
  12027. //
  12028. // struct4101.DoctorName = doctor.UserName
  12029. // struct4101.DoctorCode = doctor.DoctorNumber
  12030. //
  12031. // var res ResultSeventeen
  12032. //
  12033. // if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  12034. // struct4101.BillCode = order.Number
  12035. // struct4101.BillNo = order.SetlId
  12036. // var resOther ResultSeventeenOther
  12037. // var pp models.PublicParams
  12038. // pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  12039. // pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  12040. // pp.FixmedinsName = miConfig.OrgName
  12041. // pp.FixmedinsCode = miConfig.Code
  12042. // pp.RequestUrl = miConfig.Url
  12043. // pp.Cainfo = miConfig.Cainfo
  12044. // pp.SecretKey = miConfig.SecretKey
  12045. // pp.AccessKey = miConfig.AccessKey
  12046. // pp.OpterName = curRoles.UserName
  12047. //
  12048. // client := &http.Client{}
  12049. // var req *http.Request
  12050. // data := make(map[string]interface{})
  12051. // data["struct4101"] = struct4101
  12052. // data["pp"] = pp
  12053. // bytesData, _ := json.Marshal(data)
  12054. // if miConfig.MdtrtareaAdmvs == "320921" {
  12055. // req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  12056. // } else {
  12057. // req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  12058. // }
  12059. // resp, _ := client.Do(req)
  12060. // defer resp.Body.Close()
  12061. // body, ioErr := ioutil.ReadAll(resp.Body)
  12062. // if ioErr != nil {
  12063. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12064. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12065. // return
  12066. // }
  12067. // var respJSON map[string]interface{}
  12068. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  12069. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12070. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12071. // return
  12072. // }
  12073. //
  12074. // respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  12075. // userJSONBytes, _ := json.Marshal(respJSON)
  12076. // fmt.Println("log")
  12077. // fmt.Println(string(userJSONBytes))
  12078. // if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  12079. // utils.ErrorLog("解析失败:%v", err)
  12080. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12081. // return
  12082. // }
  12083. // res.InfRefmsgid = resOther.InfRefmsgid
  12084. // res.Output = resOther.Output
  12085. // res.ErrMsg = resOther.ErrMsg
  12086. // infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  12087. // res.Infcode = infocode
  12088. // } else if miConfig.MdtrtareaAdmvs == "360302" {
  12089. //
  12090. // var pp models.PublicParams
  12091. // pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  12092. // pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  12093. // pp.FixmedinsName = miConfig.OrgName
  12094. // pp.FixmedinsCode = miConfig.Code
  12095. // pp.RequestUrl = miConfig.Url
  12096. // pp.Cainfo = miConfig.Cainfo
  12097. // pp.SecretKey = miConfig.SecretKey
  12098. // pp.AccessKey = miConfig.AccessKey
  12099. // pp.OpterName = curRoles.UserName
  12100. // result, _ := service.Jxyb4101(struct4101, pp)
  12101. // var dat map[string]interface{}
  12102. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12103. // fmt.Println(dat)
  12104. // } else {
  12105. // fmt.Println(err)
  12106. // }
  12107. // userJSONBytes, _ := json.Marshal(dat)
  12108. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12109. // utils.ErrorLog("解析失败:%v", err)
  12110. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12111. // return
  12112. // }
  12113. //
  12114. // } else if miConfig.MdtrtareaAdmvs == "430800" {
  12115. // var pp models.PublicParams
  12116. // pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  12117. // pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  12118. // pp.FixmedinsName = miConfig.OrgName
  12119. // pp.FixmedinsCode = miConfig.Code
  12120. // pp.RequestUrl = miConfig.Url
  12121. // pp.Cainfo = miConfig.Cainfo
  12122. // pp.SecretKey = miConfig.SecretKey
  12123. // pp.AccessKey = miConfig.AccessKey
  12124. // pp.OpterName = curRoles.UserName
  12125. // result, _ := service.Hnyb4101(struct4101, pp)
  12126. // var dat map[string]interface{}
  12127. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12128. // fmt.Println(dat)
  12129. // } else {
  12130. // fmt.Println(err)
  12131. // }
  12132. // userJSONBytes, _ := json.Marshal(dat)
  12133. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12134. // utils.ErrorLog("解析失败:%v", err)
  12135. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12136. // return
  12137. // }
  12138. //
  12139. // } else if miConfig.MdtrtareaAdmvs == "150499" {
  12140. // var resOther ResultSeventeenOther
  12141. //
  12142. // var pp models.PublicParams
  12143. // pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  12144. // pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  12145. // pp.FixmedinsName = miConfig.OrgName
  12146. // pp.FixmedinsCode = miConfig.Code
  12147. // pp.RequestUrl = miConfig.Url
  12148. // pp.Cainfo = miConfig.Cainfo
  12149. // pp.SecretKey = miConfig.SecretKey
  12150. // pp.AccessKey = miConfig.AccessKey
  12151. // pp.OpterName = curRoles.UserName
  12152. // client := &http.Client{}
  12153. // var req *http.Request
  12154. // data := make(map[string]interface{})
  12155. // data["struct4101"] = struct4101
  12156. // data["pp"] = pp
  12157. // bytesData, _ := json.Marshal(data)
  12158. // req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/4101", bytes.NewReader(bytesData))
  12159. // resp, _ := client.Do(req)
  12160. // defer resp.Body.Close()
  12161. // body, ioErr := ioutil.ReadAll(resp.Body)
  12162. // if ioErr != nil {
  12163. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12164. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12165. // return
  12166. // }
  12167. // var respJSON map[string]interface{}
  12168. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  12169. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12170. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12171. // return
  12172. // }
  12173. //
  12174. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12175. // userJSONBytes, _ := json.Marshal(respJSON)
  12176. // if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  12177. // utils.ErrorLog("解析失败:%v", err)
  12178. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12179. // return
  12180. // }
  12181. // res.InfRefmsgid = resOther.InfRefmsgid
  12182. // res.Output = resOther.Output
  12183. // res.ErrMsg = resOther.ErrMsg
  12184. // infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  12185. // res.Infcode = infocode
  12186. //
  12187. // } else if miConfig.MdtrtareaAdmvs == "350500" {
  12188. // var pp models.PublicParams
  12189. // pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  12190. // pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  12191. // pp.FixmedinsName = miConfig.OrgName
  12192. // pp.FixmedinsCode = miConfig.Code
  12193. // pp.RequestUrl = miConfig.Url
  12194. // pp.Cainfo = miConfig.Cainfo
  12195. // pp.SecretKey = miConfig.SecretKey
  12196. // pp.AccessKey = miConfig.AccessKey
  12197. // pp.OpterName = curRoles.UserName
  12198. // result, requestLog, errMsgLog := service.Fjyb4101(struct4101, pp)
  12199. // fmt.Println(requestLog)
  12200. // fmt.Println(errMsgLog)
  12201. //
  12202. // saveLog(result, requestLog, "4101a", "上传清单")
  12203. //
  12204. // var dat map[string]interface{}
  12205. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12206. // fmt.Println(dat)
  12207. // } else {
  12208. // fmt.Println(err)
  12209. // }
  12210. // userJSONBytes, _ := json.Marshal(dat)
  12211. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12212. // utils.ErrorLog("解析失败:%v", err)
  12213. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12214. // return
  12215. // }
  12216. //
  12217. // } else {
  12218. //
  12219. // result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId)
  12220. // var dat map[string]interface{}
  12221. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12222. // fmt.Println(dat)
  12223. // } else {
  12224. // fmt.Println(err)
  12225. // }
  12226. // userJSONBytes, _ := json.Marshal(dat)
  12227. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12228. // utils.ErrorLog("解析失败:%v", err)
  12229. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12230. // return
  12231. // }
  12232. // }
  12233. //
  12234. // if res.Infcode != 0 {
  12235. // adminUser := c.GetAdminUserInfo()
  12236. // errlog := &models.HisOrderError{
  12237. // UserOrgId: adminUser.CurrentOrgId,
  12238. // Ctime: time.Now().Unix(),
  12239. // Mtime: time.Now().Unix(),
  12240. // ErrMsg: res.ErrMsg,
  12241. // Status: 1,
  12242. // PatientId: order.ID,
  12243. // Stage: 10265,
  12244. // }
  12245. // service.CreateErrMsgLog(errlog)
  12246. // continue
  12247. // } else {
  12248. // //order.FaPiaoNumber = zero
  12249. // //order.FaPiaoCode = last_order.FaPiaoCode
  12250. // //service.UpdateOrder(order)
  12251. // hisFundSettleListResult := &models.HisFundSettleListResult{
  12252. // Number: res.Output.SetlListId,
  12253. // Status: 1,
  12254. // Ctime: time.Now().Unix(),
  12255. // Mtime: time.Now().Unix(),
  12256. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  12257. // IsUpload: 1,
  12258. // OrderId: order.ID,
  12259. // }
  12260. // service.CreateUploadRecord(hisFundSettleListResult)
  12261. // c.ServeSuccessJSON(map[string]interface{}{
  12262. // "msg": "上传成功",
  12263. // "result": hisFundSettleListResult,
  12264. // })
  12265. // continue
  12266. // }
  12267. // }
  12268. //}
  12269. func (c *HisApiController) GetbatchSettleList() {
  12270. //order_id, _ := c.GetInt64("order_id")
  12271. admin_user_id, _ := c.GetInt64("admin_user_id")
  12272. orders, _ := service.GetAllHisOrderTwo10485()
  12273. for _, item := range orders {
  12274. order, _ := service.GetHisOrderByIDTwo(item.ID)
  12275. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  12276. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  12277. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  12278. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  12279. //depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  12280. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  12281. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  12282. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  12283. //last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  12284. //max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  12285. //count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  12286. //fmt.Println(count)
  12287. //var zero string
  12288. //number := count + 1
  12289. //if number >= 1000 {
  12290. // zero = "0000" + strconv.FormatInt(number, 10)
  12291. //} else if number >= 10000 {
  12292. // zero = "000" + strconv.FormatInt(number, 10)
  12293. //} else if number >= 100000 {
  12294. // zero = "00" + strconv.FormatInt(number, 10)
  12295. //} else if number >= 1000000 {
  12296. // zero = "0" + strconv.FormatInt(number, 10)
  12297. //} else {
  12298. // zero = strconv.FormatInt(number, 10)
  12299. //}
  12300. //fmt.Println(zero)
  12301. struct4101 := service.Struct4101{
  12302. PsnNo: order.PsnNo,
  12303. MdtrtId: order.MdtrtId,
  12304. SetlId: order.SetlId,
  12305. PsnName: order.PsnName,
  12306. Gend: order.Gend,
  12307. Brdy: his.Brdy,
  12308. Age: his.Age,
  12309. Naty: order.Naty,
  12310. PatnCertType: "01",
  12311. Certno: order.Certno,
  12312. Prfs: "90",
  12313. ConerName: roles[0].UserName,
  12314. PatnRlts: "99",
  12315. ConerAddr: miConfig.OrgName,
  12316. ConerTel: admin.Mobile,
  12317. HiType: order.Insutype,
  12318. Insuplc: miConfig.InsuplcAdmdvs,
  12319. MaindiagFlag: "1",
  12320. BillCode: order.SetlId,
  12321. BillNo: order.SetlId,
  12322. BizSn: order.Number,
  12323. PsnSelfPay: order.PsnPartAmt,
  12324. PsnOwnPay: order.PsnPartAmt,
  12325. AcctPay: order.AcctPay,
  12326. PsnCashpay: order.PsnCashPay,
  12327. HiPaymtd: "1",
  12328. Hsorg: miConfig.InsuplcAdmdvs,
  12329. HsorgOpter: miConfig.InsuplcAdmdvs,
  12330. MedinsFillPsn: curRoles.UserName,
  12331. MedinsFillDept: miConfig.OrgName,
  12332. IptMedType: "2",
  12333. }
  12334. struct4101.SetlBegnDate = order.SetlTime
  12335. struct4101.SetlEndDate = order.SetlTime
  12336. time_arr := strings.Split(order.SetlTime, " ")
  12337. struct4101.AdmTime = time_arr[0]
  12338. struct4101.AdmEndTime = time_arr[0]
  12339. //var rf []CustomFundPay
  12340. //json.Unmarshal([]byte(order.SetlDetail), &rf)
  12341. //
  12342. //var tempFunPays []service.CustomStruct
  12343. //for _, item := range rf {
  12344. // var tempFunPay service.CustomStruct
  12345. // tempFunPay.FundPayamt = item.FundPayamt
  12346. // tempFunPay.FundPayType = item.FundPayType
  12347. // tempFunPays = append(tempFunPays, tempFunPay)
  12348. //}
  12349. //struct4101.CustomStruct = tempFunPays
  12350. var tempDiaginfos []service.DiaginfoStructTwo
  12351. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  12352. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  12353. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  12354. var config []*models.HisXtDiagnoseConfig
  12355. for _, item := range diagnosis_ids {
  12356. id, _ := strconv.ParseInt(item, 10, 64)
  12357. diagnosisConfig, _ := service.FindDiagnoseById(id)
  12358. config = append(config, &diagnosisConfig)
  12359. }
  12360. for index, item := range config {
  12361. if index == 0 {
  12362. var tempDiaginfo service.DiaginfoStructTwo
  12363. tempDiaginfo.DiagCode = item.CountryCode
  12364. tempDiaginfo.DiagName = item.CountryContentName
  12365. tempDiaginfo.DiagType = "1"
  12366. tempDiaginfo.MaindiagFlag = "1"
  12367. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  12368. } else {
  12369. var tempDiaginfo service.DiaginfoStructTwo
  12370. tempDiaginfo.DiagCode = item.CountryCode
  12371. tempDiaginfo.DiagName = item.CountryContentName
  12372. tempDiaginfo.DiagType = "1"
  12373. tempDiaginfo.MaindiagFlag = "0"
  12374. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  12375. }
  12376. }
  12377. struct4101.Diseinfo = tempDiaginfos
  12378. sickConfigTwo, _ := service.FindSickById(his.SickType)
  12379. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  12380. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  12381. tempOpspdiseinfo2.OprnOprtCode = sickConfigTwo.ContentCode
  12382. tempOpspdiseinfo2.OprnOprtName = sickConfigTwo.CountryContentName
  12383. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  12384. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  12385. var iteminfo service.IteminfoStruct
  12386. var bedCostTotal float64 = 0 //床位总费
  12387. var bedCostSelfTotal float64 = 0 //床位自费
  12388. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  12389. var operationCostTotal float64 = 0 //手术费
  12390. var operationCostSelfTotal float64 = 0 //手术费
  12391. var operationCostPartSelfTotal float64 = 0 //手术费
  12392. var otherCostTotal float64 = 0 //其他费用
  12393. var otherCostSelfTotal float64 = 0 //其他费用
  12394. var otherCostPartSelfTotal float64 = 0 //其他费用
  12395. var materialCostTotal float64 = 0 //材料费
  12396. var materialCostSelfTotal float64 = 0 //材料费
  12397. var materialCostPartSelfTotal float64 = 0 //材料费
  12398. var westernMedicineCostTotal float64 = 0 //西药费
  12399. var westernMedicineCostSelfTotal float64 = 0 //西药费
  12400. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  12401. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  12402. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  12403. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  12404. var checkCostTotal float64 = 0 //检查费
  12405. var checkCostSelfTotal float64 = 0 //检查费
  12406. var checkCostPartSelfTotal float64 = 0 //检查费
  12407. var laboratoryCostTotal float64 = 0 //化验费
  12408. var laboratoryCostSelfTotal float64 = 0 //化验费
  12409. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  12410. var treatCostTotal float64 = 0 //治疗费用
  12411. var treatCostSelfTotal float64 = 0 //治疗费用
  12412. var treatCostPartSelfTotal float64 = 0 //治疗费用
  12413. decimal.DivisionPrecision = 2
  12414. var bed_fulamt_ownpay_amt float64 = 0
  12415. var operation_fulamt_ownpay_amt float64 = 0
  12416. var other_fulamt_ownpay_amt float64 = 0
  12417. var westernMedicine_fulamt_ownpay_amt float64 = 0
  12418. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  12419. var check_fulamt_ownpay_amt float64 = 0
  12420. var material_fulamt_ownpay_amt float64 = 0
  12421. var laboratory_fulamt_ownpay_amt float64 = 0
  12422. var treat_fulamt_ownpay_amt float64 = 0
  12423. var bed_claa_sunmfee float64 = 0
  12424. var bed_clab_amt float64 = 0
  12425. var bed_other_amt float64 = 0
  12426. var operation_claa_sunmfee float64 = 0
  12427. var operation_clab_amt float64 = 0
  12428. var operation_other_amt float64 = 0
  12429. var other_claa_sunmfee float64 = 0
  12430. var other_clab_amt float64 = 0
  12431. var other_other_amt float64 = 0
  12432. var westernMedicine_claa_sunmfee float64 = 0
  12433. var westernMedicine_clab_amt float64 = 0
  12434. var westernMedicine_other_amt float64 = 0
  12435. var chineseTraditional_claa_sunmfee float64 = 0
  12436. var chineseTraditional_clab_amt float64 = 0
  12437. var chineseTraditional_other_amt float64 = 0
  12438. var check_claa_sunmfee float64 = 0
  12439. var check_clab_amt float64 = 0
  12440. var check_other_amt float64 = 0
  12441. var material_claa_sunmfee float64 = 0
  12442. var material_clab_amt float64 = 0
  12443. var material_other_amt float64 = 0
  12444. var laboratory_claa_sunmfee float64 = 0
  12445. var laboratory_clab_amt float64 = 0
  12446. var laboratory_other_amt float64 = 0
  12447. var treat_claa_sunmfee float64 = 0
  12448. var treat_clab_amt float64 = 0
  12449. var treat_other_amt float64 = 0
  12450. for _, item := range order.HisOrderInfo {
  12451. if item.MedChrgitmType == "01" { //床位费
  12452. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12453. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12454. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12455. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  12456. if item.ChrgitmLv == "1" {
  12457. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12458. }
  12459. if item.ChrgitmLv == "2" {
  12460. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12461. }
  12462. if item.ChrgitmLv == "3" {
  12463. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12464. }
  12465. }
  12466. if item.MedChrgitmType == "03" { //检查费
  12467. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12468. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12469. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12470. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  12471. if item.ChrgitmLv == "1" {
  12472. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12473. }
  12474. if item.ChrgitmLv == "2" {
  12475. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12476. }
  12477. if item.ChrgitmLv == "3" {
  12478. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12479. }
  12480. }
  12481. if item.MedChrgitmType == "04" { //化验费
  12482. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12483. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12484. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12485. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  12486. if item.ChrgitmLv == "1" {
  12487. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12488. }
  12489. if item.ChrgitmLv == "2" {
  12490. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12491. }
  12492. if item.ChrgitmLv == "3" {
  12493. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12494. }
  12495. }
  12496. if item.MedChrgitmType == "05" { //治疗费
  12497. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12498. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12499. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12500. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  12501. if item.ChrgitmLv == "1" {
  12502. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12503. }
  12504. if item.ChrgitmLv == "2" {
  12505. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12506. }
  12507. if item.ChrgitmLv == "3" {
  12508. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12509. }
  12510. }
  12511. if item.MedChrgitmType == "06" { //手术费
  12512. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12513. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12514. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12515. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  12516. if item.ChrgitmLv == "1" {
  12517. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12518. }
  12519. if item.ChrgitmLv == "2" {
  12520. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12521. }
  12522. if item.ChrgitmLv == "3" {
  12523. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12524. }
  12525. }
  12526. if item.MedChrgitmType == "08" { //材料费
  12527. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12528. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12529. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12530. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  12531. if item.ChrgitmLv == "1" {
  12532. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12533. }
  12534. if item.ChrgitmLv == "2" {
  12535. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12536. }
  12537. if item.ChrgitmLv == "3" {
  12538. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12539. }
  12540. }
  12541. if item.MedChrgitmType == "09" { //西药费
  12542. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12543. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12544. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12545. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  12546. if item.ChrgitmLv == "1" {
  12547. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12548. }
  12549. if item.ChrgitmLv == "2" {
  12550. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12551. }
  12552. if item.ChrgitmLv == "3" {
  12553. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12554. }
  12555. }
  12556. if item.MedChrgitmType == "11" { //中成费
  12557. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12558. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12559. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12560. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  12561. if item.ChrgitmLv == "1" {
  12562. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12563. }
  12564. if item.ChrgitmLv == "2" {
  12565. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12566. }
  12567. if item.ChrgitmLv == "3" {
  12568. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12569. }
  12570. }
  12571. if item.MedChrgitmType == "14" { //其他费
  12572. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12573. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12574. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12575. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  12576. if item.ChrgitmLv == "1" {
  12577. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12578. }
  12579. if item.ChrgitmLv == "2" {
  12580. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12581. }
  12582. if item.ChrgitmLv == "3" {
  12583. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12584. }
  12585. }
  12586. }
  12587. var iteminfoStructs []service.IteminfoStruct
  12588. if bedCostTotal != 0 {
  12589. iteminfo.MedChrgitm = "01"
  12590. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  12591. iteminfo.Amt = bedCostTotal
  12592. iteminfo.ClaaSumfee = bed_claa_sunmfee
  12593. iteminfo.ClabAmt = bed_clab_amt
  12594. iteminfo.OthAmt = bed_other_amt
  12595. iteminfoStructs = append(iteminfoStructs, iteminfo)
  12596. }
  12597. if checkCostTotal != 0 {
  12598. iteminfo.MedChrgitm = "03"
  12599. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  12600. iteminfo.Amt = checkCostTotal
  12601. iteminfo.ClaaSumfee = check_claa_sunmfee
  12602. iteminfo.ClabAmt = check_clab_amt
  12603. iteminfo.OthAmt = check_other_amt
  12604. iteminfoStructs = append(iteminfoStructs, iteminfo)
  12605. }
  12606. if laboratoryCostTotal != 0 {
  12607. iteminfo.MedChrgitm = "04"
  12608. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  12609. iteminfo.Amt = laboratoryCostTotal
  12610. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  12611. iteminfo.ClabAmt = laboratory_clab_amt
  12612. iteminfo.OthAmt = laboratory_other_amt
  12613. iteminfoStructs = append(iteminfoStructs, iteminfo)
  12614. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  12615. }
  12616. if treatCostTotal != 0 {
  12617. iteminfo.MedChrgitm = "05"
  12618. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  12619. iteminfo.Amt = treatCostTotal
  12620. iteminfo.ClaaSumfee = treat_claa_sunmfee
  12621. iteminfo.ClabAmt = treat_clab_amt
  12622. iteminfo.OthAmt = treat_other_amt
  12623. iteminfoStructs = append(iteminfoStructs, iteminfo)
  12624. //(struct4101.IteminfoStruct, iteminfo)
  12625. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  12626. }
  12627. if operationCostTotal != 0 {
  12628. iteminfo.MedChrgitm = "06"
  12629. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  12630. iteminfo.Amt = operationCostTotal
  12631. iteminfo.ClaaSumfee = operation_claa_sunmfee
  12632. iteminfo.ClabAmt = operation_clab_amt
  12633. iteminfo.OthAmt = operation_other_amt
  12634. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  12635. iteminfoStructs = append(iteminfoStructs, iteminfo)
  12636. }
  12637. if materialCostTotal != 0 {
  12638. iteminfo.MedChrgitm = "08"
  12639. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  12640. iteminfo.Amt = materialCostTotal
  12641. iteminfo.ClaaSumfee = material_claa_sunmfee
  12642. iteminfo.ClabAmt = material_clab_amt
  12643. iteminfo.OthAmt = material_other_amt
  12644. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  12645. iteminfoStructs = append(iteminfoStructs, iteminfo)
  12646. }
  12647. if westernMedicineCostTotal != 0 {
  12648. iteminfo.MedChrgitm = "09"
  12649. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  12650. iteminfo.Amt = westernMedicineCostTotal
  12651. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  12652. iteminfo.ClabAmt = westernMedicine_clab_amt
  12653. iteminfo.OthAmt = westernMedicine_other_amt
  12654. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  12655. iteminfoStructs = append(iteminfoStructs, iteminfo)
  12656. }
  12657. if chineseTraditionalMedicineCostTotal != 0 {
  12658. iteminfo.MedChrgitm = "11"
  12659. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  12660. iteminfo.Amt = westernMedicineCostTotal
  12661. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  12662. iteminfo.ClabAmt = westernMedicine_clab_amt
  12663. iteminfo.OthAmt = westernMedicine_other_amt
  12664. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  12665. iteminfoStructs = append(iteminfoStructs, iteminfo)
  12666. }
  12667. if otherCostTotal != 0 {
  12668. iteminfo.MedChrgitm = "14"
  12669. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  12670. iteminfo.Amt = otherCostTotal
  12671. iteminfo.ClaaSumfee = other_claa_sunmfee
  12672. iteminfo.ClabAmt = other_clab_amt
  12673. iteminfo.OthAmt = other_other_amt
  12674. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  12675. iteminfoStructs = append(iteminfoStructs, iteminfo)
  12676. }
  12677. struct4101.IteminfoStruct = iteminfoStructs
  12678. struct4101.Ntly = "中国"
  12679. struct4101.AdmCaty = "A03.06"
  12680. struct4101.DoctorName = doctor.UserName
  12681. struct4101.DoctorCode = doctor.DoctorNumber
  12682. var res ResultSeventeen
  12683. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  12684. struct4101.BillCode = order.Number
  12685. struct4101.BillNo = order.SetlId
  12686. var resOther ResultSeventeenOther
  12687. var pp models.PublicParams
  12688. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  12689. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  12690. pp.FixmedinsName = miConfig.OrgName
  12691. pp.FixmedinsCode = miConfig.Code
  12692. pp.RequestUrl = miConfig.Url
  12693. pp.Cainfo = miConfig.Cainfo
  12694. pp.SecretKey = miConfig.SecretKey
  12695. pp.AccessKey = miConfig.AccessKey
  12696. pp.OpterName = curRoles.UserName
  12697. client := &http.Client{}
  12698. var req *http.Request
  12699. data := make(map[string]interface{})
  12700. data["struct4101"] = struct4101
  12701. data["pp"] = pp
  12702. bytesData, _ := json.Marshal(data)
  12703. if miConfig.MdtrtareaAdmvs == "320921" {
  12704. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  12705. } else {
  12706. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  12707. }
  12708. resp, _ := client.Do(req)
  12709. defer resp.Body.Close()
  12710. body, ioErr := ioutil.ReadAll(resp.Body)
  12711. if ioErr != nil {
  12712. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12713. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12714. return
  12715. }
  12716. var respJSON map[string]interface{}
  12717. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  12718. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12719. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12720. return
  12721. }
  12722. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  12723. userJSONBytes, _ := json.Marshal(respJSON)
  12724. fmt.Println("log")
  12725. fmt.Println(string(userJSONBytes))
  12726. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  12727. utils.ErrorLog("解析失败:%v", err)
  12728. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12729. return
  12730. }
  12731. res.InfRefmsgid = resOther.InfRefmsgid
  12732. res.Output = resOther.Output
  12733. res.ErrMsg = resOther.ErrMsg
  12734. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  12735. res.Infcode = infocode
  12736. } else if miConfig.MdtrtareaAdmvs == "360302" {
  12737. var pp models.PublicParams
  12738. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  12739. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  12740. pp.FixmedinsName = miConfig.OrgName
  12741. pp.FixmedinsCode = miConfig.Code
  12742. pp.RequestUrl = miConfig.Url
  12743. pp.Cainfo = miConfig.Cainfo
  12744. pp.SecretKey = miConfig.SecretKey
  12745. pp.AccessKey = miConfig.AccessKey
  12746. pp.OpterName = curRoles.UserName
  12747. result, _ := service.Jxyb4101(struct4101, pp)
  12748. var dat map[string]interface{}
  12749. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12750. fmt.Println(dat)
  12751. } else {
  12752. fmt.Println(err)
  12753. }
  12754. userJSONBytes, _ := json.Marshal(dat)
  12755. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12756. utils.ErrorLog("解析失败:%v", err)
  12757. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12758. return
  12759. }
  12760. } else if miConfig.MdtrtareaAdmvs == "430800" {
  12761. var pp models.PublicParams
  12762. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  12763. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  12764. pp.FixmedinsName = miConfig.OrgName
  12765. pp.FixmedinsCode = miConfig.Code
  12766. pp.RequestUrl = miConfig.Url
  12767. pp.Cainfo = miConfig.Cainfo
  12768. pp.SecretKey = miConfig.SecretKey
  12769. pp.AccessKey = miConfig.AccessKey
  12770. pp.OpterName = curRoles.UserName
  12771. result, _ := service.Hnyb4101(struct4101, pp)
  12772. var dat map[string]interface{}
  12773. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12774. fmt.Println(dat)
  12775. } else {
  12776. fmt.Println(err)
  12777. }
  12778. userJSONBytes, _ := json.Marshal(dat)
  12779. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12780. utils.ErrorLog("解析失败:%v", err)
  12781. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12782. return
  12783. }
  12784. } else if miConfig.MdtrtareaAdmvs == "150499" {
  12785. var resOther ResultSeventeenOther
  12786. var pp models.PublicParams
  12787. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  12788. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  12789. pp.FixmedinsName = miConfig.OrgName
  12790. pp.FixmedinsCode = miConfig.Code
  12791. pp.RequestUrl = miConfig.Url
  12792. pp.Cainfo = miConfig.Cainfo
  12793. pp.SecretKey = miConfig.SecretKey
  12794. pp.AccessKey = miConfig.AccessKey
  12795. pp.OpterName = curRoles.UserName
  12796. client := &http.Client{}
  12797. var req *http.Request
  12798. data := make(map[string]interface{})
  12799. data["struct4101"] = struct4101
  12800. data["pp"] = pp
  12801. bytesData, _ := json.Marshal(data)
  12802. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/4101", bytes.NewReader(bytesData))
  12803. resp, _ := client.Do(req)
  12804. defer resp.Body.Close()
  12805. body, ioErr := ioutil.ReadAll(resp.Body)
  12806. if ioErr != nil {
  12807. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12808. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12809. return
  12810. }
  12811. var respJSON map[string]interface{}
  12812. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  12813. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12814. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12815. return
  12816. }
  12817. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12818. userJSONBytes, _ := json.Marshal(respJSON)
  12819. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  12820. utils.ErrorLog("解析失败:%v", err)
  12821. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12822. return
  12823. }
  12824. res.InfRefmsgid = resOther.InfRefmsgid
  12825. res.Output = resOther.Output
  12826. res.ErrMsg = resOther.ErrMsg
  12827. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  12828. res.Infcode = infocode
  12829. } else if miConfig.MdtrtareaAdmvs == "350500" {
  12830. var pp models.PublicParams
  12831. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  12832. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  12833. pp.FixmedinsName = miConfig.OrgName
  12834. pp.FixmedinsCode = miConfig.Code
  12835. pp.RequestUrl = miConfig.Url
  12836. pp.Cainfo = miConfig.Cainfo
  12837. pp.SecretKey = miConfig.SecretKey
  12838. pp.AccessKey = miConfig.AccessKey
  12839. pp.OpterName = curRoles.UserName
  12840. result, requestLog, errMsgLog := service.Fjyb4101(struct4101, pp)
  12841. fmt.Println(requestLog)
  12842. fmt.Println(errMsgLog)
  12843. saveLog(result, requestLog, "4101a", "上传清单")
  12844. var dat map[string]interface{}
  12845. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12846. fmt.Println(dat)
  12847. } else {
  12848. fmt.Println(err)
  12849. }
  12850. userJSONBytes, _ := json.Marshal(dat)
  12851. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12852. utils.ErrorLog("解析失败:%v", err)
  12853. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12854. return
  12855. }
  12856. } else if miConfig.MdtrtareaAdmvs == "441799" {
  12857. var pp models.PublicParams
  12858. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  12859. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  12860. pp.FixmedinsName = miConfig.OrgName
  12861. pp.FixmedinsCode = miConfig.Code
  12862. pp.RequestUrl = miConfig.Url
  12863. pp.Cainfo = miConfig.Cainfo
  12864. pp.SecretKey = miConfig.SecretKey
  12865. pp.AccessKey = miConfig.AccessKey
  12866. pp.OpterName = curRoles.UserName
  12867. client := &http.Client{}
  12868. var req *http.Request
  12869. data := make(map[string]interface{})
  12870. data["struct4101"] = struct4101
  12871. data["pp"] = pp
  12872. bytesData, _ := json.Marshal(data)
  12873. req, _ = http.NewRequest("POST", miConfig.Url+"gdyb/4101", bytes.NewReader(bytesData))
  12874. resp, _ := client.Do(req)
  12875. defer resp.Body.Close()
  12876. body, ioErr := ioutil.ReadAll(resp.Body)
  12877. if ioErr != nil {
  12878. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12879. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12880. return
  12881. }
  12882. var respJSON map[string]interface{}
  12883. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  12884. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12885. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12886. return
  12887. }
  12888. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12889. userJSONBytes, _ := json.Marshal(respJSON)
  12890. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12891. utils.ErrorLog("解析失败:%v", err)
  12892. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12893. return
  12894. }
  12895. } else {
  12896. result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId, admin_user_id)
  12897. var dat map[string]interface{}
  12898. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12899. fmt.Println(dat)
  12900. } else {
  12901. fmt.Println(err)
  12902. }
  12903. userJSONBytes, _ := json.Marshal(dat)
  12904. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12905. utils.ErrorLog("解析失败:%v", err)
  12906. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12907. return
  12908. }
  12909. }
  12910. if res.Infcode != 0 {
  12911. errlog := &models.HisOrderError{
  12912. UserOrgId: order.UserOrgId,
  12913. Ctime: time.Now().Unix(),
  12914. Mtime: time.Now().Unix(),
  12915. ErrMsg: res.ErrMsg + "解析失败",
  12916. Status: 1,
  12917. PatientId: order.ID,
  12918. Stage: 10485,
  12919. }
  12920. service.CreateErrMsgLog(errlog)
  12921. continue
  12922. //c.ServeSuccessJSON(map[string]interface{}{
  12923. // "failed_code": -10,
  12924. // "msg": res.ErrMsg,
  12925. //})
  12926. } else {
  12927. //order.FaPiaoNumber = zero
  12928. //order.FaPiaoCode = last_order.FaPiaoCode
  12929. //service.UpdateOrder(order)
  12930. hisFundSettleListResult := &models.HisFundSettleListResult{
  12931. Number: res.Output.SetlListId,
  12932. Status: 1,
  12933. Ctime: time.Now().Unix(),
  12934. Mtime: time.Now().Unix(),
  12935. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  12936. IsUpload: 1,
  12937. OrderId: order.ID,
  12938. }
  12939. service.CreateUploadRecord(hisFundSettleListResult)
  12940. continue
  12941. }
  12942. }
  12943. }
  12944. func (c *HisApiController) GetSettleList() {
  12945. order_id, _ := c.GetInt64("order_id")
  12946. admin_user_id, _ := c.GetInt64("admin_user_id")
  12947. order, _ := service.GetHisOrderByIDTwo(order_id)
  12948. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  12949. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  12950. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  12951. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  12952. //depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  12953. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  12954. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  12955. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  12956. if order.ID == 0 {
  12957. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  12958. return
  12959. }
  12960. //last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  12961. //max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  12962. //count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  12963. //fmt.Println(count)
  12964. //var zero string
  12965. //number := count + 1
  12966. //if number >= 1000 {
  12967. // zero = "0000" + strconv.FormatInt(number, 10)
  12968. //} else if number >= 10000 {
  12969. // zero = "000" + strconv.FormatInt(number, 10)
  12970. //} else if number >= 100000 {
  12971. // zero = "00" + strconv.FormatInt(number, 10)
  12972. //} else if number >= 1000000 {
  12973. // zero = "0" + strconv.FormatInt(number, 10)
  12974. //} else {
  12975. // zero = strconv.FormatInt(number, 10)
  12976. //}
  12977. //fmt.Println(zero)
  12978. struct4101 := service.Struct4101{
  12979. PsnNo: order.PsnNo,
  12980. MdtrtId: order.MdtrtId,
  12981. SetlId: order.SetlId,
  12982. PsnName: order.PsnName,
  12983. Gend: order.Gend,
  12984. Brdy: his.Brdy,
  12985. Age: his.Age,
  12986. Naty: order.Naty,
  12987. PatnCertType: "01",
  12988. Certno: order.Certno,
  12989. Prfs: "90",
  12990. ConerName: roles[0].UserName,
  12991. PatnRlts: "99",
  12992. ConerAddr: miConfig.OrgName,
  12993. ConerTel: admin.Mobile,
  12994. HiType: order.Insutype,
  12995. Insuplc: miConfig.InsuplcAdmdvs,
  12996. MaindiagFlag: "1",
  12997. BillCode: order.SetlId,
  12998. BillNo: order.SetlId,
  12999. BizSn: order.Number,
  13000. PsnSelfPay: order.PsnPartAmt,
  13001. PsnOwnPay: order.PsnPartAmt,
  13002. AcctPay: order.AcctPay,
  13003. PsnCashpay: order.PsnCashPay,
  13004. HiPaymtd: "1",
  13005. Hsorg: miConfig.InsuplcAdmdvs,
  13006. HsorgOpter: miConfig.InsuplcAdmdvs,
  13007. MedinsFillPsn: curRoles.UserName,
  13008. MedinsFillDept: miConfig.OrgName,
  13009. IptMedType: "2",
  13010. }
  13011. struct4101.SetlBegnDate = order.SetlTime
  13012. struct4101.SetlEndDate = order.SetlTime
  13013. time_arr := strings.Split(order.SetlTime, " ")
  13014. struct4101.AdmTime = time_arr[0]
  13015. struct4101.AdmEndTime = time_arr[0]
  13016. //
  13017. //var rf []CustomFundPay
  13018. //json.Unmarshal([]byte(order.SetlDetail), &rf)
  13019. //
  13020. //var tempFunPays []service.CustomStruct
  13021. //for _, item := range rf {
  13022. // var tempFunPay service.CustomStruct
  13023. // tempFunPay.FundPayamt = item.FundPayamt
  13024. // tempFunPay.FundPayType = item.FundPayType
  13025. // tempFunPays = append(tempFunPays, tempFunPay)
  13026. //}
  13027. //struct4101.CustomStruct = tempFunPays
  13028. var tempDiaginfos []service.DiaginfoStructTwo
  13029. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  13030. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  13031. diagnosis_ids := strings.Split(order.Diagnosis, ",")
  13032. var config []*models.HisXtDiagnoseConfig
  13033. for _, item := range diagnosis_ids {
  13034. id, _ := strconv.ParseInt(item, 10, 64)
  13035. diagnosisConfig, _ := service.FindDiagnoseById(id)
  13036. config = append(config, &diagnosisConfig)
  13037. }
  13038. if miConfig.Code == "H15049901371" {
  13039. //for _, item := range config {
  13040. // if item.ID == 138 {
  13041. diagnosisConfig, _ := service.FindDiagnoseById(138)
  13042. var tempDiaginfo service.DiaginfoStructTwo
  13043. tempDiaginfo.DiagCode = diagnosisConfig.CountryCode
  13044. tempDiaginfo.DiagName = diagnosisConfig.CountryContentName
  13045. tempDiaginfo.DiagType = "1"
  13046. tempDiaginfo.MaindiagFlag = "1"
  13047. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  13048. //}
  13049. //}
  13050. for _, item := range config {
  13051. if item.ID != 138 {
  13052. var tempDiaginfo service.DiaginfoStructTwo
  13053. tempDiaginfo.DiagCode = item.CountryCode
  13054. tempDiaginfo.DiagName = item.CountryContentName
  13055. tempDiaginfo.DiagType = "1"
  13056. tempDiaginfo.MaindiagFlag = "0"
  13057. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  13058. }
  13059. }
  13060. } else {
  13061. for index, item := range config {
  13062. if index == 0 {
  13063. var tempDiaginfo service.DiaginfoStructTwo
  13064. tempDiaginfo.DiagCode = item.CountryCode
  13065. tempDiaginfo.DiagName = item.CountryContentName
  13066. tempDiaginfo.DiagType = "1"
  13067. tempDiaginfo.MaindiagFlag = "1"
  13068. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  13069. } else {
  13070. var tempDiaginfo service.DiaginfoStructTwo
  13071. tempDiaginfo.DiagCode = item.CountryCode
  13072. tempDiaginfo.DiagName = item.CountryContentName
  13073. tempDiaginfo.DiagType = "1"
  13074. tempDiaginfo.MaindiagFlag = "0"
  13075. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  13076. }
  13077. }
  13078. }
  13079. struct4101.Diseinfo = tempDiaginfos
  13080. sickConfigTwo, _ := service.FindSickById(his.SickType)
  13081. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  13082. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  13083. tempOpspdiseinfo2.OprnOprtCode = sickConfigTwo.ContentCode
  13084. tempOpspdiseinfo2.OprnOprtName = sickConfigTwo.CountryContentName
  13085. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  13086. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  13087. var iteminfo service.IteminfoStruct
  13088. var bedCostTotal float64 = 0 //床位总费
  13089. var bedCostSelfTotal float64 = 0 //床位自费
  13090. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  13091. var operationCostTotal float64 = 0 //手术费
  13092. var operationCostSelfTotal float64 = 0 //手术费
  13093. var operationCostPartSelfTotal float64 = 0 //手术费
  13094. var otherCostTotal float64 = 0 //其他费用
  13095. var otherCostSelfTotal float64 = 0 //其他费用
  13096. var otherCostPartSelfTotal float64 = 0 //其他费用
  13097. var materialCostTotal float64 = 0 //材料费
  13098. var materialCostSelfTotal float64 = 0 //材料费
  13099. var materialCostPartSelfTotal float64 = 0 //材料费
  13100. var westernMedicineCostTotal float64 = 0 //西药费
  13101. var westernMedicineCostSelfTotal float64 = 0 //西药费
  13102. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  13103. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  13104. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  13105. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  13106. var checkCostTotal float64 = 0 //检查费
  13107. var checkCostSelfTotal float64 = 0 //检查费
  13108. var checkCostPartSelfTotal float64 = 0 //检查费
  13109. var laboratoryCostTotal float64 = 0 //化验费
  13110. var laboratoryCostSelfTotal float64 = 0 //化验费
  13111. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  13112. var treatCostTotal float64 = 0 //治疗费用
  13113. var treatCostSelfTotal float64 = 0 //治疗费用
  13114. var treatCostPartSelfTotal float64 = 0 //治疗费用
  13115. decimal.DivisionPrecision = 2
  13116. var bed_fulamt_ownpay_amt float64 = 0
  13117. var operation_fulamt_ownpay_amt float64 = 0
  13118. var other_fulamt_ownpay_amt float64 = 0
  13119. var westernMedicine_fulamt_ownpay_amt float64 = 0
  13120. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  13121. var check_fulamt_ownpay_amt float64 = 0
  13122. var material_fulamt_ownpay_amt float64 = 0
  13123. var laboratory_fulamt_ownpay_amt float64 = 0
  13124. var treat_fulamt_ownpay_amt float64 = 0
  13125. var bed_claa_sunmfee float64 = 0
  13126. var bed_clab_amt float64 = 0
  13127. var bed_other_amt float64 = 0
  13128. var operation_claa_sunmfee float64 = 0
  13129. var operation_clab_amt float64 = 0
  13130. var operation_other_amt float64 = 0
  13131. var other_claa_sunmfee float64 = 0
  13132. var other_clab_amt float64 = 0
  13133. var other_other_amt float64 = 0
  13134. var westernMedicine_claa_sunmfee float64 = 0
  13135. var westernMedicine_clab_amt float64 = 0
  13136. var westernMedicine_other_amt float64 = 0
  13137. var chineseTraditional_claa_sunmfee float64 = 0
  13138. var chineseTraditional_clab_amt float64 = 0
  13139. var chineseTraditional_other_amt float64 = 0
  13140. var check_claa_sunmfee float64 = 0
  13141. var check_clab_amt float64 = 0
  13142. var check_other_amt float64 = 0
  13143. var material_claa_sunmfee float64 = 0
  13144. var material_clab_amt float64 = 0
  13145. var material_other_amt float64 = 0
  13146. var laboratory_claa_sunmfee float64 = 0
  13147. var laboratory_clab_amt float64 = 0
  13148. var laboratory_other_amt float64 = 0
  13149. var treat_claa_sunmfee float64 = 0
  13150. var treat_clab_amt float64 = 0
  13151. var treat_other_amt float64 = 0
  13152. for _, item := range order.HisOrderInfo {
  13153. if item.MedChrgitmType == "01" { //床位费
  13154. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13155. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13156. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13157. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  13158. if item.ChrgitmLv == "1" {
  13159. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13160. }
  13161. if item.ChrgitmLv == "2" {
  13162. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13163. }
  13164. if item.ChrgitmLv == "3" {
  13165. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13166. }
  13167. }
  13168. if item.MedChrgitmType == "03" { //检查费
  13169. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13170. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13171. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13172. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  13173. if item.ChrgitmLv == "1" {
  13174. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13175. }
  13176. if item.ChrgitmLv == "2" {
  13177. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13178. }
  13179. if item.ChrgitmLv == "3" {
  13180. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13181. }
  13182. }
  13183. if item.MedChrgitmType == "04" { //化验费
  13184. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13185. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13186. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13187. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  13188. if item.ChrgitmLv == "1" {
  13189. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13190. }
  13191. if item.ChrgitmLv == "2" {
  13192. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13193. }
  13194. if item.ChrgitmLv == "3" {
  13195. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13196. }
  13197. }
  13198. if item.MedChrgitmType == "05" { //治疗费
  13199. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13200. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13201. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13202. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  13203. if item.ChrgitmLv == "1" {
  13204. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13205. }
  13206. if item.ChrgitmLv == "2" {
  13207. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13208. }
  13209. if item.ChrgitmLv == "3" {
  13210. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13211. }
  13212. }
  13213. if item.MedChrgitmType == "06" { //手术费
  13214. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13215. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13216. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13217. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  13218. if item.ChrgitmLv == "1" {
  13219. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13220. }
  13221. if item.ChrgitmLv == "2" {
  13222. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13223. }
  13224. if item.ChrgitmLv == "3" {
  13225. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13226. }
  13227. }
  13228. if item.MedChrgitmType == "08" { //材料费
  13229. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13230. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13231. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13232. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  13233. if item.ChrgitmLv == "1" {
  13234. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13235. }
  13236. if item.ChrgitmLv == "2" {
  13237. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13238. }
  13239. if item.ChrgitmLv == "3" {
  13240. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13241. }
  13242. }
  13243. if item.MedChrgitmType == "09" { //西药费
  13244. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13245. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13246. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13247. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  13248. if item.ChrgitmLv == "1" {
  13249. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13250. }
  13251. if item.ChrgitmLv == "2" {
  13252. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13253. }
  13254. if item.ChrgitmLv == "3" {
  13255. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13256. }
  13257. }
  13258. if item.MedChrgitmType == "11" { //中成费
  13259. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13260. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13261. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13262. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  13263. if item.ChrgitmLv == "1" {
  13264. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13265. }
  13266. if item.ChrgitmLv == "2" {
  13267. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13268. }
  13269. if item.ChrgitmLv == "3" {
  13270. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13271. }
  13272. }
  13273. if item.MedChrgitmType == "14" { //其他费
  13274. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13275. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13276. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13277. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  13278. if item.ChrgitmLv == "1" {
  13279. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13280. }
  13281. if item.ChrgitmLv == "2" {
  13282. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13283. }
  13284. if item.ChrgitmLv == "3" {
  13285. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13286. }
  13287. }
  13288. }
  13289. var iteminfoStructs []service.IteminfoStruct
  13290. if bedCostTotal != 0 {
  13291. iteminfo.MedChrgitm = "01"
  13292. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  13293. iteminfo.Amt = bedCostTotal
  13294. iteminfo.ClaaSumfee = bed_claa_sunmfee
  13295. iteminfo.ClabAmt = bed_clab_amt
  13296. iteminfo.OthAmt = bed_other_amt
  13297. iteminfoStructs = append(iteminfoStructs, iteminfo)
  13298. }
  13299. if checkCostTotal != 0 {
  13300. iteminfo.MedChrgitm = "03"
  13301. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  13302. iteminfo.Amt = checkCostTotal
  13303. iteminfo.ClaaSumfee = check_claa_sunmfee
  13304. iteminfo.ClabAmt = check_clab_amt
  13305. iteminfo.OthAmt = check_other_amt
  13306. iteminfoStructs = append(iteminfoStructs, iteminfo)
  13307. }
  13308. if laboratoryCostTotal != 0 {
  13309. iteminfo.MedChrgitm = "04"
  13310. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  13311. iteminfo.Amt = laboratoryCostTotal
  13312. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  13313. iteminfo.ClabAmt = laboratory_clab_amt
  13314. iteminfo.OthAmt = laboratory_other_amt
  13315. iteminfoStructs = append(iteminfoStructs, iteminfo)
  13316. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  13317. }
  13318. if treatCostTotal != 0 {
  13319. iteminfo.MedChrgitm = "05"
  13320. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  13321. iteminfo.Amt = treatCostTotal
  13322. iteminfo.ClaaSumfee = treat_claa_sunmfee
  13323. iteminfo.ClabAmt = treat_clab_amt
  13324. iteminfo.OthAmt = treat_other_amt
  13325. iteminfoStructs = append(iteminfoStructs, iteminfo)
  13326. //(struct4101.IteminfoStruct, iteminfo)
  13327. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  13328. }
  13329. if operationCostTotal != 0 {
  13330. iteminfo.MedChrgitm = "06"
  13331. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  13332. iteminfo.Amt = operationCostTotal
  13333. iteminfo.ClaaSumfee = operation_claa_sunmfee
  13334. iteminfo.ClabAmt = operation_clab_amt
  13335. iteminfo.OthAmt = operation_other_amt
  13336. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  13337. iteminfoStructs = append(iteminfoStructs, iteminfo)
  13338. }
  13339. if materialCostTotal != 0 {
  13340. iteminfo.MedChrgitm = "08"
  13341. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  13342. iteminfo.Amt = materialCostTotal
  13343. iteminfo.ClaaSumfee = material_claa_sunmfee
  13344. iteminfo.ClabAmt = material_clab_amt
  13345. iteminfo.OthAmt = material_other_amt
  13346. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  13347. iteminfoStructs = append(iteminfoStructs, iteminfo)
  13348. }
  13349. if westernMedicineCostTotal != 0 {
  13350. iteminfo.MedChrgitm = "09"
  13351. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  13352. iteminfo.Amt = westernMedicineCostTotal
  13353. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  13354. iteminfo.ClabAmt = westernMedicine_clab_amt
  13355. iteminfo.OthAmt = westernMedicine_other_amt
  13356. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  13357. iteminfoStructs = append(iteminfoStructs, iteminfo)
  13358. }
  13359. if chineseTraditionalMedicineCostTotal != 0 {
  13360. iteminfo.MedChrgitm = "11"
  13361. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  13362. iteminfo.Amt = westernMedicineCostTotal
  13363. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  13364. iteminfo.ClabAmt = westernMedicine_clab_amt
  13365. iteminfo.OthAmt = westernMedicine_other_amt
  13366. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  13367. iteminfoStructs = append(iteminfoStructs, iteminfo)
  13368. }
  13369. if otherCostTotal != 0 {
  13370. iteminfo.MedChrgitm = "14"
  13371. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  13372. iteminfo.Amt = otherCostTotal
  13373. iteminfo.ClaaSumfee = other_claa_sunmfee
  13374. iteminfo.ClabAmt = other_clab_amt
  13375. iteminfo.OthAmt = other_other_amt
  13376. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  13377. iteminfoStructs = append(iteminfoStructs, iteminfo)
  13378. }
  13379. struct4101.IteminfoStruct = iteminfoStructs
  13380. struct4101.Ntly = "中国"
  13381. struct4101.AdmCaty = "A03.06"
  13382. struct4101.DoctorName = doctor.UserName
  13383. struct4101.DoctorCode = doctor.DoctorNumber
  13384. var res ResultSeventeen
  13385. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  13386. struct4101.BillCode = order.Number
  13387. struct4101.BillNo = order.SetlId
  13388. var resOther ResultSeventeenOther
  13389. var pp models.PublicParams
  13390. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  13391. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  13392. pp.FixmedinsName = miConfig.OrgName
  13393. pp.FixmedinsCode = miConfig.Code
  13394. pp.RequestUrl = miConfig.Url
  13395. pp.Cainfo = miConfig.Cainfo
  13396. pp.SecretKey = miConfig.SecretKey
  13397. pp.AccessKey = miConfig.AccessKey
  13398. pp.OpterName = curRoles.UserName
  13399. client := &http.Client{}
  13400. var req *http.Request
  13401. data := make(map[string]interface{})
  13402. data["struct4101"] = struct4101
  13403. data["pp"] = pp
  13404. bytesData, _ := json.Marshal(data)
  13405. if miConfig.MdtrtareaAdmvs == "320921" {
  13406. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  13407. } else {
  13408. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  13409. }
  13410. resp, _ := client.Do(req)
  13411. defer resp.Body.Close()
  13412. body, ioErr := ioutil.ReadAll(resp.Body)
  13413. if ioErr != nil {
  13414. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13415. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13416. return
  13417. }
  13418. var respJSON map[string]interface{}
  13419. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  13420. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13421. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13422. return
  13423. }
  13424. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  13425. userJSONBytes, _ := json.Marshal(respJSON)
  13426. fmt.Println("log")
  13427. fmt.Println(string(userJSONBytes))
  13428. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  13429. utils.ErrorLog("解析失败:%v", err)
  13430. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13431. return
  13432. }
  13433. res.InfRefmsgid = resOther.InfRefmsgid
  13434. res.Output = resOther.Output
  13435. res.ErrMsg = resOther.ErrMsg
  13436. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  13437. res.Infcode = infocode
  13438. } else if miConfig.MdtrtareaAdmvs == "360302" {
  13439. var pp models.PublicParams
  13440. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  13441. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  13442. pp.FixmedinsName = miConfig.OrgName
  13443. pp.FixmedinsCode = miConfig.Code
  13444. pp.RequestUrl = miConfig.Url
  13445. pp.Cainfo = miConfig.Cainfo
  13446. pp.SecretKey = miConfig.SecretKey
  13447. pp.AccessKey = miConfig.AccessKey
  13448. pp.OpterName = curRoles.UserName
  13449. result, _ := service.Jxyb4101(struct4101, pp)
  13450. var dat map[string]interface{}
  13451. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13452. fmt.Println(dat)
  13453. } else {
  13454. fmt.Println(err)
  13455. }
  13456. userJSONBytes, _ := json.Marshal(dat)
  13457. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13458. utils.ErrorLog("解析失败:%v", err)
  13459. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13460. return
  13461. }
  13462. } else if miConfig.MdtrtareaAdmvs == "430800" {
  13463. var pp models.PublicParams
  13464. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  13465. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  13466. pp.FixmedinsName = miConfig.OrgName
  13467. pp.FixmedinsCode = miConfig.Code
  13468. pp.RequestUrl = miConfig.Url
  13469. pp.Cainfo = miConfig.Cainfo
  13470. pp.SecretKey = miConfig.SecretKey
  13471. pp.AccessKey = miConfig.AccessKey
  13472. pp.OpterName = curRoles.UserName
  13473. result, _ := service.Hnyb4101(struct4101, pp)
  13474. var dat map[string]interface{}
  13475. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13476. fmt.Println(dat)
  13477. } else {
  13478. fmt.Println(err)
  13479. }
  13480. userJSONBytes, _ := json.Marshal(dat)
  13481. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13482. utils.ErrorLog("解析失败:%v", err)
  13483. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13484. return
  13485. }
  13486. } else if miConfig.MdtrtareaAdmvs == "150499" {
  13487. var resOther ResultSeventeenOther
  13488. var pp models.PublicParams
  13489. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  13490. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  13491. pp.FixmedinsName = miConfig.OrgName
  13492. pp.FixmedinsCode = miConfig.Code
  13493. pp.RequestUrl = miConfig.Url
  13494. pp.Cainfo = miConfig.Cainfo
  13495. pp.SecretKey = miConfig.SecretKey
  13496. pp.AccessKey = miConfig.AccessKey
  13497. pp.OpterName = curRoles.UserName
  13498. client := &http.Client{}
  13499. var req *http.Request
  13500. data := make(map[string]interface{})
  13501. data["struct4101"] = struct4101
  13502. data["pp"] = pp
  13503. bytesData, _ := json.Marshal(data)
  13504. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/4101", bytes.NewReader(bytesData))
  13505. resp, _ := client.Do(req)
  13506. defer resp.Body.Close()
  13507. body, ioErr := ioutil.ReadAll(resp.Body)
  13508. if ioErr != nil {
  13509. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13510. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13511. return
  13512. }
  13513. var respJSON map[string]interface{}
  13514. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  13515. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13516. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13517. return
  13518. }
  13519. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13520. userJSONBytes, _ := json.Marshal(respJSON)
  13521. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  13522. utils.ErrorLog("解析失败:%v", err)
  13523. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13524. return
  13525. }
  13526. res.InfRefmsgid = resOther.InfRefmsgid
  13527. res.Output = resOther.Output
  13528. res.ErrMsg = resOther.ErrMsg
  13529. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  13530. res.Infcode = infocode
  13531. } else if miConfig.MdtrtareaAdmvs == "350500" {
  13532. var pp models.PublicParams
  13533. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  13534. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  13535. pp.FixmedinsName = miConfig.OrgName
  13536. pp.FixmedinsCode = miConfig.Code
  13537. pp.RequestUrl = miConfig.Url
  13538. pp.Cainfo = miConfig.Cainfo
  13539. pp.SecretKey = miConfig.SecretKey
  13540. pp.AccessKey = miConfig.AccessKey
  13541. pp.OpterName = curRoles.UserName
  13542. result, requestLog, errMsgLog := service.Fjyb4101(struct4101, pp)
  13543. fmt.Println(requestLog)
  13544. fmt.Println(errMsgLog)
  13545. saveLog(result, requestLog, "4101a", "上传清单")
  13546. var dat map[string]interface{}
  13547. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13548. fmt.Println(dat)
  13549. } else {
  13550. fmt.Println(err)
  13551. }
  13552. userJSONBytes, _ := json.Marshal(dat)
  13553. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13554. utils.ErrorLog("解析失败:%v", err)
  13555. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13556. return
  13557. }
  13558. } else if miConfig.MdtrtareaAdmvs == "441799" {
  13559. var pp models.PublicParams
  13560. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  13561. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  13562. pp.FixmedinsName = miConfig.OrgName
  13563. pp.FixmedinsCode = miConfig.Code
  13564. pp.RequestUrl = miConfig.Url
  13565. pp.Cainfo = miConfig.Cainfo
  13566. pp.SecretKey = miConfig.SecretKey
  13567. pp.AccessKey = miConfig.AccessKey
  13568. pp.OpterName = curRoles.UserName
  13569. client := &http.Client{}
  13570. var req *http.Request
  13571. data := make(map[string]interface{})
  13572. data["struct4101"] = struct4101
  13573. data["pp"] = pp
  13574. bytesData, _ := json.Marshal(data)
  13575. req, _ = http.NewRequest("POST", miConfig.Url+"gdyb/4101", bytes.NewReader(bytesData))
  13576. resp, _ := client.Do(req)
  13577. defer resp.Body.Close()
  13578. body, ioErr := ioutil.ReadAll(resp.Body)
  13579. if ioErr != nil {
  13580. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13581. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13582. return
  13583. }
  13584. var respJSON map[string]interface{}
  13585. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  13586. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13587. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13588. return
  13589. }
  13590. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13591. userJSONBytes, _ := json.Marshal(respJSON)
  13592. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13593. utils.ErrorLog("解析失败:%v", err)
  13594. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13595. return
  13596. }
  13597. } else {
  13598. result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId, admin_user_id)
  13599. var dat map[string]interface{}
  13600. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13601. fmt.Println(dat)
  13602. } else {
  13603. fmt.Println(err)
  13604. }
  13605. userJSONBytes, _ := json.Marshal(dat)
  13606. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13607. utils.ErrorLog("解析失败:%v", err)
  13608. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13609. return
  13610. }
  13611. }
  13612. if res.Infcode != 0 {
  13613. c.ServeSuccessJSON(map[string]interface{}{
  13614. "failed_code": -10,
  13615. "msg": res.ErrMsg,
  13616. })
  13617. return
  13618. } else {
  13619. //order.FaPiaoNumber = zero
  13620. //order.FaPiaoCode = last_order.FaPiaoCode
  13621. //service.UpdateOrder(order)
  13622. hisFundSettleListResult := &models.HisFundSettleListResult{
  13623. Number: res.Output.SetlListId,
  13624. Status: 1,
  13625. Ctime: time.Now().Unix(),
  13626. Mtime: time.Now().Unix(),
  13627. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13628. IsUpload: 1,
  13629. OrderId: order_id,
  13630. }
  13631. service.CreateUploadRecord(hisFundSettleListResult)
  13632. c.ServeSuccessJSON(map[string]interface{}{
  13633. "msg": "上传成功",
  13634. "result": hisFundSettleListResult,
  13635. })
  13636. return
  13637. }
  13638. }
  13639. func (c *HisApiController) GetSettleListHospital() {
  13640. order_id, _ := c.GetInt64("order_id")
  13641. admin_user_id, _ := c.GetInt64("admin_user_id")
  13642. order, _ := service.GetHisOrderByIDTwo(order_id)
  13643. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  13644. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  13645. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  13646. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  13647. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  13648. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  13649. if order.ID == 0 {
  13650. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  13651. return
  13652. }
  13653. last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  13654. max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  13655. count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  13656. fmt.Println(count)
  13657. var zero string
  13658. number := count + 1
  13659. if number >= 1000 {
  13660. zero = "0000" + strconv.FormatInt(number, 10)
  13661. } else if number >= 10000 {
  13662. zero = "000" + strconv.FormatInt(number, 10)
  13663. } else if number >= 100000 {
  13664. zero = "00" + strconv.FormatInt(number, 10)
  13665. } else if number >= 1000000 {
  13666. zero = "0" + strconv.FormatInt(number, 10)
  13667. } else {
  13668. zero = strconv.FormatInt(number, 10)
  13669. }
  13670. fmt.Println(zero)
  13671. struct4101 := service.Struct4101{
  13672. PsnNo: order.PsnNo,
  13673. MdtrtId: order.MdtrtId,
  13674. SetlId: order.SetlId,
  13675. PsnName: order.PsnName,
  13676. Gend: order.Gend,
  13677. Brdy: his.Brdy,
  13678. Age: int64(order.Age),
  13679. Naty: order.Naty,
  13680. PatnCertType: "01",
  13681. Certno: order.Certno,
  13682. Prfs: "90",
  13683. ConerName: roles[0].UserName,
  13684. PatnRlts: "99",
  13685. ConerAddr: miConfig.OrgName,
  13686. ConerTel: admin.Mobile,
  13687. HiType: order.Insutype,
  13688. Insuplc: miConfig.InsuplcAdmdvs,
  13689. MaindiagFlag: "1",
  13690. BillCode: order.SetlId,
  13691. BillNo: order.SetlId,
  13692. BizSn: order.Number,
  13693. PsnSelfPay: order.PsnPartAmt,
  13694. PsnOwnPay: order.PsnPartAmt,
  13695. AcctPay: order.AcctPay,
  13696. PsnCashpay: order.PsnCashPay,
  13697. HiPaymtd: "1",
  13698. Hsorg: miConfig.InsuplcAdmdvs,
  13699. HsorgOpter: miConfig.InsuplcAdmdvs,
  13700. MedinsFillPsn: curRoles.UserName,
  13701. MedinsFillDept: depart.Name,
  13702. IptMedType: "2",
  13703. AdmTime: his.InHosptialTime,
  13704. AdmEndTime: his.OutHosptialTime,
  13705. }
  13706. struct4101.SetlBegnDate = order.SetlTime
  13707. struct4101.SetlEndDate = order.SetlTime
  13708. //var rf []CustomFundPay
  13709. //json.Unmarshal([]byte(order.SetlDetail), &rf)
  13710. //
  13711. //var tempFunPays []service.CustomStruct
  13712. //for _, item := range rf {
  13713. // var tempFunPay service.CustomStruct
  13714. // tempFunPay.FundPayamt = item.FundPayamt
  13715. // tempFunPay.FundPayType = item.FundPayType
  13716. // tempFunPays = append(tempFunPays, tempFunPay)
  13717. //}
  13718. //struct4101.CustomStruct = tempFunPays
  13719. var tempDiaginfos []service.DiaginfoStructTwo
  13720. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  13721. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  13722. //infos, _ := service.FindLastPatientPrescriptionInfoTwo2(c.GetAdminUserInfo().CurrentOrgId, his.PatientId, strings.Split(his.InHosptialTime, " ")[0], strings.Split(his.OutHosptialTime, " ")[0])
  13723. //for _, item := range infos {
  13724. // his.Diagnosis = his.Diagnosis + "," + item.Diagnosis
  13725. //}
  13726. diagnosis_ids_arr := strings.Split(his.Diagnosis, ",")
  13727. diagnosis_ids_arr = RemoveRepeatedPurviewElement2(diagnosis_ids_arr)
  13728. //diagnosis_ids := strings.Split(his.Diagnosis, ",")
  13729. fmt.Println(diagnosis_ids_arr)
  13730. if order.UserOrgId == 10210 {
  13731. var diagnosis_ids_arr_two []int64
  13732. diagnosis_ids_arr_two = append(diagnosis_ids_arr_two, 704)
  13733. var config []*models.HisXtDiagnoseConfig
  13734. for _, id := range diagnosis_ids_arr_two {
  13735. //id, _ := strconv.ParseInt(item, 10, 64)
  13736. diagnosisConfig, _ := service.FindDiagnoseById(id)
  13737. if diagnosisConfig.ID > 0 {
  13738. config = append(config, &diagnosisConfig)
  13739. }
  13740. }
  13741. for index, item := range config {
  13742. if item.ID > 0 {
  13743. if index == 0 {
  13744. var tempDiaginfo service.DiaginfoStructTwo
  13745. tempDiaginfo.DiagCode = item.CountryCode
  13746. tempDiaginfo.DiagName = item.CountryContentName
  13747. tempDiaginfo.DiagType = "1"
  13748. tempDiaginfo.MaindiagFlag = "1"
  13749. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  13750. } else {
  13751. var tempDiaginfo service.DiaginfoStructTwo
  13752. tempDiaginfo.DiagCode = item.CountryCode
  13753. tempDiaginfo.DiagName = item.CountryContentName
  13754. tempDiaginfo.DiagType = "1"
  13755. tempDiaginfo.MaindiagFlag = "0"
  13756. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  13757. }
  13758. }
  13759. }
  13760. struct4101.Diseinfo = tempDiaginfos
  13761. } else {
  13762. var config []*models.HisXtDiagnoseConfig
  13763. for _, item := range diagnosis_ids_arr {
  13764. id, _ := strconv.ParseInt(item, 10, 64)
  13765. diagnosisConfig, _ := service.FindDiagnoseById(id)
  13766. if diagnosisConfig.ID > 0 {
  13767. config = append(config, &diagnosisConfig)
  13768. }
  13769. }
  13770. for index, item := range config {
  13771. if item.ID > 0 {
  13772. if index == 0 {
  13773. var tempDiaginfo service.DiaginfoStructTwo
  13774. tempDiaginfo.DiagCode = item.CountryCode
  13775. tempDiaginfo.DiagName = item.CountryContentName
  13776. tempDiaginfo.DiagType = "1"
  13777. tempDiaginfo.MaindiagFlag = "1"
  13778. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  13779. } else {
  13780. var tempDiaginfo service.DiaginfoStructTwo
  13781. tempDiaginfo.DiagCode = item.CountryCode
  13782. tempDiaginfo.DiagName = item.CountryContentName
  13783. tempDiaginfo.DiagType = "1"
  13784. tempDiaginfo.MaindiagFlag = "0"
  13785. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  13786. }
  13787. }
  13788. }
  13789. struct4101.Diseinfo = tempDiaginfos
  13790. }
  13791. sickConfigTwo, _ := service.FindSickById(his.SickType)
  13792. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  13793. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  13794. tempOpspdiseinfo2.OprnOprtCode = ""
  13795. tempOpspdiseinfo2.OprnOprtName = ""
  13796. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  13797. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  13798. var iteminfo service.IteminfoStruct
  13799. var bedCostTotal float64 = 0 //床位总费
  13800. var bedCostSelfTotal float64 = 0 //床位自费
  13801. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  13802. var operationCostTotal float64 = 0 //手术费
  13803. var operationCostSelfTotal float64 = 0 //手术费
  13804. var operationCostPartSelfTotal float64 = 0 //手术费
  13805. var otherCostTotal float64 = 0 //其他费用
  13806. var otherCostSelfTotal float64 = 0 //其他费用
  13807. var otherCostPartSelfTotal float64 = 0 //其他费用
  13808. var materialCostTotal float64 = 0 //材料费
  13809. var materialCostSelfTotal float64 = 0 //材料费
  13810. var materialCostPartSelfTotal float64 = 0 //材料费
  13811. var westernMedicineCostTotal float64 = 0 //西药费
  13812. var westernMedicineCostSelfTotal float64 = 0 //西药费
  13813. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  13814. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  13815. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  13816. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  13817. var checkCostTotal float64 = 0 //检查费
  13818. var checkCostSelfTotal float64 = 0 //检查费
  13819. var checkCostPartSelfTotal float64 = 0 //检查费
  13820. var laboratoryCostTotal float64 = 0 //化验费
  13821. var laboratoryCostSelfTotal float64 = 0 //化验费
  13822. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  13823. var treatCostTotal float64 = 0 //治疗费用
  13824. var treatCostSelfTotal float64 = 0 //治疗费用
  13825. var treatCostPartSelfTotal float64 = 0 //治疗费用
  13826. decimal.DivisionPrecision = 2
  13827. var bed_fulamt_ownpay_amt float64 = 0
  13828. var operation_fulamt_ownpay_amt float64 = 0
  13829. var other_fulamt_ownpay_amt float64 = 0
  13830. var westernMedicine_fulamt_ownpay_amt float64 = 0
  13831. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  13832. var check_fulamt_ownpay_amt float64 = 0
  13833. var material_fulamt_ownpay_amt float64 = 0
  13834. var laboratory_fulamt_ownpay_amt float64 = 0
  13835. var treat_fulamt_ownpay_amt float64 = 0
  13836. var bed_claa_sunmfee float64 = 0
  13837. var bed_clab_amt float64 = 0
  13838. var bed_other_amt float64 = 0
  13839. var operation_claa_sunmfee float64 = 0
  13840. var operation_clab_amt float64 = 0
  13841. var operation_other_amt float64 = 0
  13842. var other_claa_sunmfee float64 = 0
  13843. var other_clab_amt float64 = 0
  13844. var other_other_amt float64 = 0
  13845. var westernMedicine_claa_sunmfee float64 = 0
  13846. var westernMedicine_clab_amt float64 = 0
  13847. var westernMedicine_other_amt float64 = 0
  13848. var chineseTraditional_claa_sunmfee float64 = 0
  13849. var chineseTraditional_clab_amt float64 = 0
  13850. var chineseTraditional_other_amt float64 = 0
  13851. var check_claa_sunmfee float64 = 0
  13852. var check_clab_amt float64 = 0
  13853. var check_other_amt float64 = 0
  13854. var material_claa_sunmfee float64 = 0
  13855. var material_clab_amt float64 = 0
  13856. var material_other_amt float64 = 0
  13857. var laboratory_claa_sunmfee float64 = 0
  13858. var laboratory_clab_amt float64 = 0
  13859. var laboratory_other_amt float64 = 0
  13860. var treat_claa_sunmfee float64 = 0
  13861. var treat_clab_amt float64 = 0
  13862. var treat_other_amt float64 = 0
  13863. for _, item := range order.HisOrderInfo {
  13864. if item.MedChrgitmType == "01" { //床位费
  13865. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13866. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13867. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13868. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  13869. if item.ChrgitmLv == "1" {
  13870. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13871. }
  13872. if item.ChrgitmLv == "2" {
  13873. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13874. }
  13875. if item.ChrgitmLv == "3" {
  13876. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13877. }
  13878. }
  13879. if item.MedChrgitmType == "03" { //检查费
  13880. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13881. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13882. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13883. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  13884. if item.ChrgitmLv == "1" {
  13885. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13886. }
  13887. if item.ChrgitmLv == "2" {
  13888. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13889. }
  13890. if item.ChrgitmLv == "3" {
  13891. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13892. }
  13893. }
  13894. if item.MedChrgitmType == "04" { //化验费
  13895. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13896. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13897. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13898. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  13899. if item.ChrgitmLv == "1" {
  13900. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13901. }
  13902. if item.ChrgitmLv == "2" {
  13903. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13904. }
  13905. if item.ChrgitmLv == "3" {
  13906. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13907. }
  13908. }
  13909. if item.MedChrgitmType == "05" { //治疗费
  13910. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13911. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13912. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13913. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  13914. if item.ChrgitmLv == "1" {
  13915. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13916. }
  13917. if item.ChrgitmLv == "2" {
  13918. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13919. }
  13920. if item.ChrgitmLv == "3" {
  13921. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13922. }
  13923. }
  13924. if item.MedChrgitmType == "06" { //手术费
  13925. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13926. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13927. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13928. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  13929. if item.ChrgitmLv == "1" {
  13930. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13931. }
  13932. if item.ChrgitmLv == "2" {
  13933. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13934. }
  13935. if item.ChrgitmLv == "3" {
  13936. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13937. }
  13938. }
  13939. if item.MedChrgitmType == "08" { //材料费
  13940. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13941. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13942. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13943. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  13944. if item.ChrgitmLv == "1" {
  13945. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13946. }
  13947. if item.ChrgitmLv == "2" {
  13948. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13949. }
  13950. if item.ChrgitmLv == "3" {
  13951. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13952. }
  13953. }
  13954. if item.MedChrgitmType == "09" { //西药费
  13955. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13956. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13957. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13958. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  13959. if item.ChrgitmLv == "1" {
  13960. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13961. }
  13962. if item.ChrgitmLv == "2" {
  13963. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13964. }
  13965. if item.ChrgitmLv == "3" {
  13966. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13967. }
  13968. }
  13969. if item.MedChrgitmType == "11" { //中成费
  13970. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13971. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13972. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13973. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  13974. if item.ChrgitmLv == "1" {
  13975. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13976. }
  13977. if item.ChrgitmLv == "2" {
  13978. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13979. }
  13980. if item.ChrgitmLv == "3" {
  13981. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13982. }
  13983. }
  13984. if item.MedChrgitmType == "14" { //其他费
  13985. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13986. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13987. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13988. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  13989. if item.ChrgitmLv == "1" {
  13990. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13991. }
  13992. if item.ChrgitmLv == "2" {
  13993. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13994. }
  13995. if item.ChrgitmLv == "3" {
  13996. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13997. }
  13998. }
  13999. }
  14000. var iteminfoStructs []service.IteminfoStruct
  14001. if bedCostTotal != 0 {
  14002. iteminfo.MedChrgitm = "01"
  14003. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  14004. iteminfo.Amt = bedCostTotal
  14005. iteminfo.ClaaSumfee = bed_claa_sunmfee
  14006. iteminfo.ClabAmt = bed_clab_amt
  14007. iteminfo.OthAmt = bed_other_amt
  14008. iteminfoStructs = append(iteminfoStructs, iteminfo)
  14009. }
  14010. if checkCostTotal != 0 {
  14011. iteminfo.MedChrgitm = "03"
  14012. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  14013. iteminfo.Amt = checkCostTotal
  14014. iteminfo.ClaaSumfee = check_claa_sunmfee
  14015. iteminfo.ClabAmt = check_clab_amt
  14016. iteminfo.OthAmt = check_other_amt
  14017. iteminfoStructs = append(iteminfoStructs, iteminfo)
  14018. }
  14019. if laboratoryCostTotal != 0 {
  14020. iteminfo.MedChrgitm = "04"
  14021. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  14022. iteminfo.Amt = laboratoryCostTotal
  14023. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  14024. iteminfo.ClabAmt = laboratory_clab_amt
  14025. iteminfo.OthAmt = laboratory_other_amt
  14026. iteminfoStructs = append(iteminfoStructs, iteminfo)
  14027. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  14028. }
  14029. if treatCostTotal != 0 {
  14030. iteminfo.MedChrgitm = "05"
  14031. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  14032. iteminfo.Amt = treatCostTotal
  14033. iteminfo.ClaaSumfee = treat_claa_sunmfee
  14034. iteminfo.ClabAmt = treat_clab_amt
  14035. iteminfo.OthAmt = treat_other_amt
  14036. iteminfoStructs = append(iteminfoStructs, iteminfo)
  14037. //(struct4101.IteminfoStruct, iteminfo)
  14038. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  14039. }
  14040. if operationCostTotal != 0 {
  14041. iteminfo.MedChrgitm = "06"
  14042. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  14043. iteminfo.Amt = operationCostTotal
  14044. iteminfo.ClaaSumfee = operation_claa_sunmfee
  14045. iteminfo.ClabAmt = operation_clab_amt
  14046. iteminfo.OthAmt = operation_other_amt
  14047. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  14048. iteminfoStructs = append(iteminfoStructs, iteminfo)
  14049. }
  14050. if materialCostTotal != 0 {
  14051. iteminfo.MedChrgitm = "08"
  14052. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  14053. iteminfo.Amt = materialCostTotal
  14054. iteminfo.ClaaSumfee = material_claa_sunmfee
  14055. iteminfo.ClabAmt = material_clab_amt
  14056. iteminfo.OthAmt = material_other_amt
  14057. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  14058. iteminfoStructs = append(iteminfoStructs, iteminfo)
  14059. }
  14060. if westernMedicineCostTotal != 0 {
  14061. iteminfo.MedChrgitm = "09"
  14062. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  14063. iteminfo.Amt = westernMedicineCostTotal
  14064. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  14065. iteminfo.ClabAmt = westernMedicine_clab_amt
  14066. iteminfo.OthAmt = westernMedicine_other_amt
  14067. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  14068. iteminfoStructs = append(iteminfoStructs, iteminfo)
  14069. }
  14070. if chineseTraditionalMedicineCostTotal != 0 {
  14071. iteminfo.MedChrgitm = "11"
  14072. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  14073. iteminfo.Amt = westernMedicineCostTotal
  14074. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  14075. iteminfo.ClabAmt = westernMedicine_clab_amt
  14076. iteminfo.OthAmt = westernMedicine_other_amt
  14077. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  14078. iteminfoStructs = append(iteminfoStructs, iteminfo)
  14079. }
  14080. if otherCostTotal != 0 {
  14081. iteminfo.MedChrgitm = "14"
  14082. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  14083. iteminfo.Amt = otherCostTotal
  14084. iteminfo.ClaaSumfee = other_claa_sunmfee
  14085. iteminfo.ClabAmt = other_clab_amt
  14086. iteminfo.OthAmt = other_other_amt
  14087. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  14088. iteminfoStructs = append(iteminfoStructs, iteminfo)
  14089. }
  14090. struct4101.IteminfoStruct = iteminfoStructs
  14091. struct4101.Ntly = "中国"
  14092. struct4101.AdmCaty = "A03.06"
  14093. var resOther ResultSeventeenOther
  14094. var res ResultSeventeen
  14095. if miConfig.MdtrtareaAdmvs == "150499" {
  14096. var pp models.PublicParams
  14097. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  14098. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  14099. pp.FixmedinsName = miConfig.OrgName
  14100. pp.FixmedinsCode = miConfig.Code
  14101. pp.RequestUrl = miConfig.Url
  14102. pp.Cainfo = miConfig.Cainfo
  14103. pp.SecretKey = miConfig.SecretKey
  14104. pp.AccessKey = miConfig.AccessKey
  14105. pp.OpterName = curRoles.UserName
  14106. client := &http.Client{}
  14107. var req *http.Request
  14108. data := make(map[string]interface{})
  14109. data["struct4101"] = struct4101
  14110. data["pp"] = pp
  14111. bytesData, _ := json.Marshal(data)
  14112. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/4101", bytes.NewReader(bytesData))
  14113. resp, _ := client.Do(req)
  14114. defer resp.Body.Close()
  14115. body, ioErr := ioutil.ReadAll(resp.Body)
  14116. if ioErr != nil {
  14117. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14118. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14119. return
  14120. }
  14121. var respJSON map[string]interface{}
  14122. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  14123. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14124. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14125. return
  14126. }
  14127. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  14128. userJSONBytes, _ := json.Marshal(respJSON)
  14129. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  14130. utils.ErrorLog("解析失败:%v", err)
  14131. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14132. return
  14133. }
  14134. res.InfRefmsgid = resOther.InfRefmsgid
  14135. res.Output = resOther.Output
  14136. res.ErrMsg = resOther.ErrMsg
  14137. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  14138. res.Infcode = infocode
  14139. } else if miConfig.MdtrtareaAdmvs == "360302" {
  14140. var pp models.PublicParams
  14141. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  14142. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  14143. pp.FixmedinsName = miConfig.OrgName
  14144. pp.FixmedinsCode = miConfig.Code
  14145. pp.RequestUrl = miConfig.Url
  14146. pp.Cainfo = miConfig.Cainfo
  14147. pp.SecretKey = miConfig.SecretKey
  14148. pp.AccessKey = miConfig.AccessKey
  14149. pp.OpterName = curRoles.UserName
  14150. result, _ := service.Jxyb4101(struct4101, pp)
  14151. var dat map[string]interface{}
  14152. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  14153. fmt.Println(dat)
  14154. } else {
  14155. fmt.Println(err)
  14156. }
  14157. userJSONBytes, _ := json.Marshal(dat)
  14158. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14159. utils.ErrorLog("解析失败:%v", err)
  14160. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14161. return
  14162. }
  14163. } else {
  14164. result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId, admin_user_id)
  14165. var dat map[string]interface{}
  14166. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  14167. fmt.Println(dat)
  14168. } else {
  14169. fmt.Println(err)
  14170. }
  14171. userJSONBytes, _ := json.Marshal(dat)
  14172. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14173. utils.ErrorLog("解析失败:%v", err)
  14174. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14175. return
  14176. }
  14177. }
  14178. if res.Infcode != 0 {
  14179. c.ServeSuccessJSON(map[string]interface{}{
  14180. "failed_code": -10,
  14181. "msg": res.ErrMsg,
  14182. })
  14183. return
  14184. } else {
  14185. if miConfig.MdtrtareaAdmvs != "150499" {
  14186. order.FaPiaoNumber = zero
  14187. order.FaPiaoCode = last_order.FaPiaoCode
  14188. service.UpdateOrder(order)
  14189. }
  14190. hisFundSettleListResult := &models.HisFundSettleListResult{
  14191. Number: res.Output.SetlListId,
  14192. Status: 1,
  14193. Ctime: time.Now().Unix(),
  14194. Mtime: time.Now().Unix(),
  14195. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14196. IsUpload: 1,
  14197. OrderId: order_id,
  14198. }
  14199. service.CreateUploadRecord(hisFundSettleListResult)
  14200. c.ServeSuccessJSON(map[string]interface{}{
  14201. "msg": "上传成功",
  14202. "result": hisFundSettleListResult,
  14203. })
  14204. return
  14205. }
  14206. }
  14207. //func (c *HisApiController) GetBatchSettleList() {
  14208. // orders, _ := service.GetAllHisOrder(10106)
  14209. // for _, item := range orders {
  14210. // order_id := item.ID
  14211. // order, _ := service.GetHisOrderByIDTwo(order_id)
  14212. // roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  14213. // his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  14214. // admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  14215. // curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, 2495)
  14216. // depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  14217. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  14218. //
  14219. // pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  14220. //
  14221. // doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  14222. //
  14223. // if order.ID == 0 {
  14224. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  14225. // return
  14226. // }
  14227. // if his.BalanceAccountsType == 2 {
  14228. // continue
  14229. // }
  14230. // struct4101 := service.Struct4101{
  14231. // PsnNo: order.PsnNo,
  14232. // MdtrtId: order.MdtrtId,
  14233. // SetlId: order.SetlId,
  14234. // PsnName: order.PsnName,
  14235. // Gend: order.Gend,
  14236. // Brdy: his.Brdy,
  14237. // Age: his.Age,
  14238. // Naty: order.Naty,
  14239. // PatnCertType: "01",
  14240. // Certno: order.Certno,
  14241. // Prfs: "90",
  14242. // ConerName: roles[0].UserName,
  14243. // PatnRlts: "99",
  14244. // ConerAddr: miConfig.OrgName,
  14245. // ConerTel: admin.Mobile,
  14246. // HiType: order.Insutype,
  14247. // Insuplc: his.InsuplcAdmdvs,
  14248. // MaindiagFlag: "1",
  14249. // BillCode: order.SetlId,
  14250. // BillNo: order.SetlId,
  14251. // BizSn: order.Number,
  14252. // PsnSelfPay: order.PsnPartAmt,
  14253. // PsnOwnPay: order.PsnPartAmt,
  14254. // AcctPay: order.AcctPay,
  14255. // PsnCashpay: order.PsnCashPay,
  14256. // HiPaymtd: "1",
  14257. // Hsorg: his.InsuplcAdmdvs,
  14258. // HsorgOpter: his.InsuplcAdmdvs,
  14259. // MedinsFillPsn: curRoles.UserName,
  14260. // MedinsFillDept: depart.Name,
  14261. // IptMedType: "2",
  14262. // }
  14263. // struct4101.SetlBegnDate = order.SetlTime
  14264. // struct4101.SetlEndDate = order.SetlTime
  14265. // //if order.SettleType == 1 {
  14266. // // t := time.Unix(int64(order.SettleAccountsDate), 0)
  14267. // // dateStr := t.Format("2006-01-02")
  14268. // // struct4101.SetlBegnDate = dateStr
  14269. // // struct4101.SetlEndDate = dateStr
  14270. // //} else {
  14271. // // t := time.Unix(int64(order.SettleStartTime), 0)
  14272. // // t2 := time.Unix(int64(order.SettleEndTime), 0)
  14273. // // dateStartStr := t.Format("2006-01-02")
  14274. // // dateEndStr := t2.Format("2006-01-02")
  14275. // // struct4101.SetlBegnDate = dateStartStr
  14276. // // struct4101.SetlEndDate = dateEndStr
  14277. // //}
  14278. //
  14279. // var rf []CustomFundPay
  14280. // json.Unmarshal([]byte(order.SetlDetail), &rf)
  14281. //
  14282. // var tempFunPays []service.CustomStruct
  14283. // var tempFunPay610100 service.CustomStruct
  14284. //
  14285. // for _, item := range rf {
  14286. // if item.FundPayType == "610100" {
  14287. // tempFunPay610100.FundPayamt, _ = decimal.NewFromFloat(tempFunPay610100.FundPayamt).Add(decimal.NewFromFloat(item.FundPayamt)).Float64()
  14288. // tempFunPay610100.FundPayType = item.FundPayType
  14289. // } else {
  14290. // var tempFunPay service.CustomStruct
  14291. // tempFunPay.FundPayamt = item.FundPayamt
  14292. // tempFunPay.FundPayType = item.FundPayType
  14293. // tempFunPays = append(tempFunPays, tempFunPay)
  14294. // }
  14295. // }
  14296. // tempFunPays = append(tempFunPays, tempFunPay610100)
  14297. // struct4101.CustomStruct = tempFunPays
  14298. //
  14299. // var tempDiaginfos []service.DiaginfoStructTwo
  14300. // var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  14301. // var tempOpspdiseinfos []service.OpspdiseinfoStruct
  14302. //
  14303. // diagnosis_ids := strings.Split(his.Diagnosis, ",")
  14304. // var config []*models.HisXtDiagnoseConfig
  14305. // for _, item := range diagnosis_ids {
  14306. // id, _ := strconv.ParseInt(item, 10, 64)
  14307. // diagnosisConfig, _ := service.FindDiagnoseById(id)
  14308. // config = append(config, &diagnosisConfig)
  14309. // }
  14310. //
  14311. // for index, item := range config {
  14312. // if index == 0 {
  14313. // var tempDiaginfo service.DiaginfoStructTwo
  14314. // tempDiaginfo.DiagCode = item.CountryCode
  14315. // tempDiaginfo.DiagName = item.CountryContentName
  14316. // tempDiaginfo.DiagType = "1"
  14317. // tempDiaginfo.MaindiagFlag = "1"
  14318. // tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  14319. // } else {
  14320. //
  14321. // var tempDiaginfo service.DiaginfoStructTwo
  14322. // tempDiaginfo.DiagCode = item.CountryCode
  14323. // tempDiaginfo.DiagName = item.CountryContentName
  14324. // tempDiaginfo.DiagType = "2"
  14325. // tempDiaginfo.MaindiagFlag = "0"
  14326. // tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  14327. // }
  14328. // }
  14329. // struct4101.Diseinfo = tempDiaginfos
  14330. //
  14331. // sickConfigTwo, _ := service.FindSickById(his.SickType)
  14332. // tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  14333. // tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  14334. // tempOpspdiseinfo2.OprnOprtCode = ""
  14335. // tempOpspdiseinfo2.OprnOprtName = ""
  14336. // tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  14337. // struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  14338. //
  14339. // var iteminfo service.IteminfoStruct
  14340. //
  14341. // var bedCostTotal float64 = 0 //床位总费
  14342. // var bedCostSelfTotal float64 = 0 //床位自费
  14343. // var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  14344. //
  14345. // var examineCostTotal float64 = 0 //诊查总费
  14346. // var examineCostSelfTotal float64 = 0 //诊查自费
  14347. // var examineCostPartSelfTotal float64 = 0 //诊查部分项目自费
  14348. //
  14349. // var nursingCostTotal float64 = 0 //护理总费
  14350. // var nursingCostSelfTotal float64 = 0 //护理自费
  14351. // var nursingCostPartSelfTotal float64 = 0 //护理部分项目自费
  14352. //
  14353. // var chineseMedicineCostTotal float64 = 0 //中成药
  14354. // var chineseMedicineCostSelfTotal float64 = 0 //中成药
  14355. // var chineseMedicineCostPartSelfTotal float64 = 0 //中成药
  14356. //
  14357. // var commonlyTreatmentCostTotal float64 = 0 //一般诊疗费
  14358. // var commonlyTreatmentCostSelfTotal float64 = 0 //一般诊疗费
  14359. // var commonlyTreatmentCostPartSelfTotal float64 = 0 //一般诊疗费
  14360. //
  14361. // var registerCostTotal float64 = 0 //一般诊疗费
  14362. // var registerCostSelfTotal float64 = 0 //一般诊疗费
  14363. // var registerPartSelfTotal float64 = 0 //一般诊疗费
  14364. //
  14365. // var operationCostTotal float64 = 0 //手术费
  14366. // var operationCostSelfTotal float64 = 0 //手术费
  14367. // var operationCostPartSelfTotal float64 = 0 //手术费
  14368. //
  14369. // var otherCostTotal float64 = 0 //其他费用
  14370. // var otherCostSelfTotal float64 = 0 //其他费用
  14371. // var otherCostPartSelfTotal float64 = 0 //其他费用
  14372. //
  14373. // var materialCostTotal float64 = 0 //材料费
  14374. // var materialCostSelfTotal float64 = 0 //材料费
  14375. // var materialCostPartSelfTotal float64 = 0 //材料费
  14376. //
  14377. // var westernMedicineCostTotal float64 = 0 //西药费
  14378. // var westernMedicineCostSelfTotal float64 = 0 //西药费
  14379. // var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  14380. //
  14381. // var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  14382. // var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  14383. // var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  14384. //
  14385. // var checkCostTotal float64 = 0 //检查费
  14386. // var checkCostSelfTotal float64 = 0 //检查费
  14387. // var checkCostPartSelfTotal float64 = 0 //检查费
  14388. //
  14389. // var laboratoryCostTotal float64 = 0 //化验费
  14390. // var laboratoryCostSelfTotal float64 = 0 //化验费
  14391. // var laboratoryCostPartSelfTotal float64 = 0 //化验费
  14392. //
  14393. // var treatCostTotal float64 = 0 //治疗费用
  14394. // var treatCostSelfTotal float64 = 0 //治疗费用
  14395. // var treatCostPartSelfTotal float64 = 0 //治疗费用
  14396. //
  14397. // decimal.DivisionPrecision = 2
  14398. //
  14399. // var bed_fulamt_ownpay_amt float64 = 0
  14400. //
  14401. // var examine_fulamt_ownpay_amt float64 = 0
  14402. //
  14403. // var nursing_fulamt_ownpay_amt float64 = 0
  14404. //
  14405. // var chinese_medicine_fulamt_ownpay_amt float64 = 0
  14406. //
  14407. // var commonly_treatment_fulamt_ownpay_amt float64 = 0
  14408. //
  14409. // var register_fulamt_ownpay_amt float64 = 0
  14410. //
  14411. // var operation_fulamt_ownpay_amt float64 = 0
  14412. // var other_fulamt_ownpay_amt float64 = 0
  14413. // var westernMedicine_fulamt_ownpay_amt float64 = 0
  14414. // var chineseTraditional_fulamt_ownpay_amt float64 = 0
  14415. // var check_fulamt_ownpay_amt float64 = 0
  14416. // var material_fulamt_ownpay_amt float64 = 0
  14417. // var laboratory_fulamt_ownpay_amt float64 = 0
  14418. // var treat_fulamt_ownpay_amt float64 = 0
  14419. //
  14420. // var bed_claa_sunmfee float64 = 0
  14421. // var bed_clab_amt float64 = 0
  14422. // var bed_other_amt float64 = 0
  14423. //
  14424. // var examine_claa_sunmfee float64 = 0
  14425. // var examine_clab_amt float64 = 0
  14426. // var examine_other_amt float64 = 0
  14427. //
  14428. // var nursing_claa_sunmfee float64 = 0
  14429. // var nursing_clab_amt float64 = 0
  14430. // var nursing_other_amt float64 = 0
  14431. //
  14432. // var chinese_medicine_claa_sunmfee float64 = 0
  14433. // var chinese_medicine_clab_amt float64 = 0
  14434. // var chinese_medicine_other_amt float64 = 0
  14435. //
  14436. // var commonly_treatment_claa_sunmfee float64 = 0
  14437. // var commonly_treatment_clab_amt float64 = 0
  14438. // var commonly_treatment_other_amt float64 = 0
  14439. //
  14440. // var operation_claa_sunmfee float64 = 0
  14441. // var operation_clab_amt float64 = 0
  14442. // var operation_other_amt float64 = 0
  14443. //
  14444. // var other_claa_sunmfee float64 = 0
  14445. // var other_clab_amt float64 = 0
  14446. // var other_other_amt float64 = 0
  14447. //
  14448. // var westernMedicine_claa_sunmfee float64 = 0
  14449. // var westernMedicine_clab_amt float64 = 0
  14450. // var westernMedicine_other_amt float64 = 0
  14451. //
  14452. // var chineseTraditional_claa_sunmfee float64 = 0
  14453. // var chineseTraditional_clab_amt float64 = 0
  14454. // var chineseTraditional_other_amt float64 = 0
  14455. //
  14456. // var check_claa_sunmfee float64 = 0
  14457. // var check_clab_amt float64 = 0
  14458. // var check_other_amt float64 = 0
  14459. //
  14460. // var material_claa_sunmfee float64 = 0
  14461. // var material_clab_amt float64 = 0
  14462. // var material_other_amt float64 = 0
  14463. //
  14464. // var laboratory_claa_sunmfee float64 = 0
  14465. // var laboratory_clab_amt float64 = 0
  14466. // var laboratory_other_amt float64 = 0
  14467. //
  14468. // var treat_claa_sunmfee float64 = 0
  14469. // var treat_clab_amt float64 = 0
  14470. // var treat_other_amt float64 = 0
  14471. //
  14472. // var register_claa_sunmfee float64 = 0
  14473. // var register_clab_amt float64 = 0
  14474. // var register_other_amt float64 = 0
  14475. //
  14476. // for _, item := range order.HisOrderInfo {
  14477. // if item.MedChrgitmType == "01" { //床位费
  14478. // bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14479. // bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14480. // bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14481. // bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14482. // if item.ChrgitmLv == "1" {
  14483. // bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14484. // }
  14485. // if item.ChrgitmLv == "2" {
  14486. // bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14487. //
  14488. // }
  14489. // if item.ChrgitmLv == "3" {
  14490. // bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14491. // }
  14492. //
  14493. // }
  14494. //
  14495. // if item.MedChrgitmType == "02" { //诊查
  14496. // examineCostTotal, _ = decimal.NewFromFloat(examineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14497. // examineCostSelfTotal, _ = decimal.NewFromFloat(examineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14498. // examineCostPartSelfTotal, _ = decimal.NewFromFloat(examineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14499. // examine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(examine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14500. // if item.ChrgitmLv == "1" {
  14501. // examine_claa_sunmfee, _ = decimal.NewFromFloat(examine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14502. // }
  14503. // if item.ChrgitmLv == "2" {
  14504. // examine_clab_amt, _ = decimal.NewFromFloat(examine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14505. //
  14506. // }
  14507. // if item.ChrgitmLv == "3" {
  14508. // examine_other_amt, _ = decimal.NewFromFloat(examine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14509. // }
  14510. //
  14511. // }
  14512. //
  14513. // if item.MedChrgitmType == "03" { //检查费
  14514. // checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14515. // checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14516. // checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14517. // check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14518. // if item.ChrgitmLv == "1" {
  14519. //
  14520. // check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14521. //
  14522. // }
  14523. // if item.ChrgitmLv == "2" {
  14524. // check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14525. //
  14526. // }
  14527. // if item.ChrgitmLv == "3" {
  14528. // check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14529. // }
  14530. // }
  14531. //
  14532. // if item.MedChrgitmType == "04" { //化验费
  14533. // laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14534. // laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14535. // laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14536. // laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14537. // if item.ChrgitmLv == "1" {
  14538. //
  14539. // laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14540. //
  14541. // }
  14542. // if item.ChrgitmLv == "2" {
  14543. // laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14544. //
  14545. // }
  14546. // if item.ChrgitmLv == "3" {
  14547. // laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14548. // }
  14549. // }
  14550. //
  14551. // if item.MedChrgitmType == "05" { //治疗费
  14552. // treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14553. // treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14554. // treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14555. // treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14556. // if item.ChrgitmLv == "1" {
  14557. //
  14558. // treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14559. //
  14560. // }
  14561. // if item.ChrgitmLv == "2" {
  14562. // treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14563. //
  14564. // }
  14565. // if item.ChrgitmLv == "3" {
  14566. // treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14567. // }
  14568. // }
  14569. //
  14570. // if item.MedChrgitmType == "06" { //手术费
  14571. // operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14572. // operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14573. // operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14574. // operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14575. //
  14576. // if item.ChrgitmLv == "1" {
  14577. //
  14578. // operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14579. //
  14580. // }
  14581. // if item.ChrgitmLv == "2" {
  14582. // operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14583. //
  14584. // }
  14585. // if item.ChrgitmLv == "3" {
  14586. // operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14587. // }
  14588. // }
  14589. //
  14590. // if item.MedChrgitmType == "07" { //手术费
  14591. // nursingCostTotal, _ = decimal.NewFromFloat(nursingCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14592. // nursingCostSelfTotal, _ = decimal.NewFromFloat(nursingCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14593. // nursingCostPartSelfTotal, _ = decimal.NewFromFloat(nursingCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14594. // nursing_fulamt_ownpay_amt, _ = decimal.NewFromFloat(nursing_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14595. //
  14596. // if item.ChrgitmLv == "1" {
  14597. //
  14598. // nursing_claa_sunmfee, _ = decimal.NewFromFloat(nursing_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14599. //
  14600. // }
  14601. // if item.ChrgitmLv == "2" {
  14602. // nursing_clab_amt, _ = decimal.NewFromFloat(nursing_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14603. //
  14604. // }
  14605. // if item.ChrgitmLv == "3" {
  14606. // nursing_other_amt, _ = decimal.NewFromFloat(nursing_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14607. // }
  14608. // }
  14609. //
  14610. // if item.MedChrgitmType == "08" { //材料费
  14611. // materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14612. // materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14613. // materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14614. // material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14615. // if item.ChrgitmLv == "1" {
  14616. //
  14617. // material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14618. //
  14619. // }
  14620. // if item.ChrgitmLv == "2" {
  14621. // material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14622. //
  14623. // }
  14624. // if item.ChrgitmLv == "3" {
  14625. // material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14626. // }
  14627. // }
  14628. // if item.MedChrgitmType == "09" { //西药费
  14629. // westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14630. // westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14631. // westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14632. // westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14633. // if item.ChrgitmLv == "1" {
  14634. // westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14635. // }
  14636. // if item.ChrgitmLv == "2" {
  14637. // westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14638. // }
  14639. // if item.ChrgitmLv == "3" {
  14640. // westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14641. // }
  14642. // }
  14643. // if item.MedChrgitmType == "10" { //中药饮片
  14644. // chineseMedicineCostTotal, _ = decimal.NewFromFloat(chineseMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14645. // chineseMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14646. // chineseMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14647. // chinese_medicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chinese_medicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14648. // if item.ChrgitmLv == "1" {
  14649. // chinese_medicine_claa_sunmfee, _ = decimal.NewFromFloat(chinese_medicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14650. // }
  14651. // if item.ChrgitmLv == "2" {
  14652. // chinese_medicine_clab_amt, _ = decimal.NewFromFloat(chinese_medicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14653. // }
  14654. // if item.ChrgitmLv == "3" {
  14655. // chinese_medicine_other_amt, _ = decimal.NewFromFloat(chinese_medicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14656. // }
  14657. // }
  14658. //
  14659. // if item.MedChrgitmType == "11" { //中成费
  14660. // chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14661. // chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14662. // chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14663. // chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14664. // if item.ChrgitmLv == "1" {
  14665. //
  14666. // chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14667. //
  14668. // }
  14669. // if item.ChrgitmLv == "2" {
  14670. // chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14671. //
  14672. // }
  14673. // if item.ChrgitmLv == "3" {
  14674. // chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14675. // }
  14676. // }
  14677. //
  14678. // if item.MedChrgitmType == "12" { //中成费
  14679. // commonlyTreatmentCostTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14680. // commonlyTreatmentCostSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14681. // commonlyTreatmentCostPartSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14682. // commonly_treatment_fulamt_ownpay_amt, _ = decimal.NewFromFloat(commonly_treatment_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14683. // if item.ChrgitmLv == "1" {
  14684. //
  14685. // commonly_treatment_claa_sunmfee, _ = decimal.NewFromFloat(commonly_treatment_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14686. //
  14687. // }
  14688. // if item.ChrgitmLv == "2" {
  14689. // commonly_treatment_clab_amt, _ = decimal.NewFromFloat(commonly_treatment_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14690. //
  14691. // }
  14692. // if item.ChrgitmLv == "3" {
  14693. // commonly_treatment_other_amt, _ = decimal.NewFromFloat(commonly_treatment_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14694. // }
  14695. // }
  14696. //
  14697. // if item.MedChrgitmType == "13" { //中成费
  14698. // registerCostTotal, _ = decimal.NewFromFloat(registerCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14699. // registerCostSelfTotal, _ = decimal.NewFromFloat(registerCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14700. // registerPartSelfTotal, _ = decimal.NewFromFloat(registerPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14701. // register_fulamt_ownpay_amt, _ = decimal.NewFromFloat(register_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14702. // if item.ChrgitmLv == "1" {
  14703. //
  14704. // register_claa_sunmfee, _ = decimal.NewFromFloat(register_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14705. //
  14706. // }
  14707. // if item.ChrgitmLv == "2" {
  14708. // register_clab_amt, _ = decimal.NewFromFloat(register_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14709. //
  14710. // }
  14711. // if item.ChrgitmLv == "3" {
  14712. // register_other_amt, _ = decimal.NewFromFloat(register_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14713. // }
  14714. // }
  14715. //
  14716. // if item.MedChrgitmType == "14" { //其他费
  14717. // otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14718. // otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14719. // otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14720. // other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14721. // if item.ChrgitmLv == "1" {
  14722. // other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14723. //
  14724. // }
  14725. // if item.ChrgitmLv == "2" {
  14726. // other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14727. //
  14728. // }
  14729. // if item.ChrgitmLv == "3" {
  14730. // other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14731. // }
  14732. // }
  14733. //
  14734. // }
  14735. //
  14736. // var iteminfoStructs []service.IteminfoStruct
  14737. //
  14738. // if bedCostTotal != 0 {
  14739. // iteminfo.MedChrgitm = "01"
  14740. // iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  14741. // iteminfo.Amt = bedCostTotal
  14742. // iteminfo.ClaaSumfee = bed_claa_sunmfee
  14743. // iteminfo.ClabAmt = bed_clab_amt
  14744. // iteminfo.OthAmt = bed_other_amt
  14745. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  14746. // }
  14747. //
  14748. // if examineCostTotal != 0 {
  14749. // iteminfo.MedChrgitm = "02"
  14750. // iteminfo.FulamtOwnpayAmt = examine_fulamt_ownpay_amt
  14751. // iteminfo.Amt = examineCostTotal
  14752. // iteminfo.ClaaSumfee = examine_claa_sunmfee
  14753. // iteminfo.ClabAmt = examine_clab_amt
  14754. // iteminfo.OthAmt = examine_other_amt
  14755. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  14756. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  14757. // }
  14758. //
  14759. // if checkCostTotal != 0 {
  14760. // iteminfo.MedChrgitm = "03"
  14761. // iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  14762. // iteminfo.Amt = checkCostTotal
  14763. // iteminfo.ClaaSumfee = check_claa_sunmfee
  14764. // iteminfo.ClabAmt = check_clab_amt
  14765. // iteminfo.OthAmt = check_other_amt
  14766. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  14767. //
  14768. // }
  14769. //
  14770. // if laboratoryCostTotal != 0 {
  14771. // iteminfo.MedChrgitm = "04"
  14772. // iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  14773. // iteminfo.Amt = laboratoryCostTotal
  14774. // iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  14775. // iteminfo.ClabAmt = laboratory_clab_amt
  14776. // iteminfo.OthAmt = laboratory_other_amt
  14777. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  14778. //
  14779. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  14780. //
  14781. // }
  14782. //
  14783. // if treatCostTotal != 0 {
  14784. // iteminfo.MedChrgitm = "05"
  14785. // iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  14786. // iteminfo.Amt = treatCostTotal
  14787. // iteminfo.ClaaSumfee = treat_claa_sunmfee
  14788. // iteminfo.ClabAmt = treat_clab_amt
  14789. // iteminfo.OthAmt = treat_other_amt
  14790. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  14791. // //(struct4101.IteminfoStruct, iteminfo)
  14792. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  14793. // }
  14794. //
  14795. // if operationCostTotal != 0 {
  14796. // iteminfo.MedChrgitm = "06"
  14797. // iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  14798. // iteminfo.Amt = operationCostTotal
  14799. // iteminfo.ClaaSumfee = operation_claa_sunmfee
  14800. // iteminfo.ClabAmt = operation_clab_amt
  14801. // iteminfo.OthAmt = operation_other_amt
  14802. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  14803. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  14804. // }
  14805. //
  14806. // if nursingCostTotal != 0 {
  14807. // iteminfo.MedChrgitm = "07"
  14808. // iteminfo.FulamtOwnpayAmt = nursing_fulamt_ownpay_amt
  14809. // iteminfo.Amt = nursingCostTotal
  14810. // iteminfo.ClaaSumfee = nursing_claa_sunmfee
  14811. // iteminfo.ClabAmt = nursing_clab_amt
  14812. // iteminfo.OthAmt = nursing_other_amt
  14813. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  14814. // }
  14815. //
  14816. // if materialCostTotal != 0 {
  14817. // iteminfo.MedChrgitm = "08"
  14818. // iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  14819. // iteminfo.Amt = materialCostTotal
  14820. // iteminfo.ClaaSumfee = material_claa_sunmfee
  14821. // iteminfo.ClabAmt = material_clab_amt
  14822. // iteminfo.OthAmt = material_other_amt
  14823. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  14824. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  14825. // }
  14826. //
  14827. // if westernMedicineCostTotal != 0 {
  14828. // iteminfo.MedChrgitm = "09"
  14829. // iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  14830. // iteminfo.Amt = westernMedicineCostTotal
  14831. // iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  14832. // iteminfo.ClabAmt = westernMedicine_clab_amt
  14833. // iteminfo.OthAmt = westernMedicine_other_amt
  14834. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  14835. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  14836. //
  14837. // }
  14838. //
  14839. // if chineseMedicineCostTotal != 0 {
  14840. // iteminfo.MedChrgitm = "10"
  14841. // iteminfo.FulamtOwnpayAmt = chinese_medicine_fulamt_ownpay_amt
  14842. // iteminfo.Amt = chineseMedicineCostTotal
  14843. // iteminfo.ClaaSumfee = chinese_medicine_claa_sunmfee
  14844. // iteminfo.ClabAmt = chinese_medicine_clab_amt
  14845. // iteminfo.OthAmt = chinese_medicine_other_amt
  14846. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  14847. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  14848. //
  14849. // }
  14850. //
  14851. // if chineseTraditionalMedicineCostTotal != 0 {
  14852. // iteminfo.MedChrgitm = "11"
  14853. // iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  14854. // iteminfo.Amt = westernMedicineCostTotal
  14855. // iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  14856. // iteminfo.ClabAmt = westernMedicine_clab_amt
  14857. // iteminfo.OthAmt = westernMedicine_other_amt
  14858. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  14859. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  14860. //
  14861. // }
  14862. //
  14863. // if commonlyTreatmentCostTotal != 0 {
  14864. // iteminfo.MedChrgitm = "12"
  14865. // iteminfo.FulamtOwnpayAmt = commonly_treatment_fulamt_ownpay_amt
  14866. // iteminfo.Amt = commonlyTreatmentCostTotal
  14867. // iteminfo.ClaaSumfee = commonly_treatment_claa_sunmfee
  14868. // iteminfo.ClabAmt = commonly_treatment_clab_amt
  14869. // iteminfo.OthAmt = commonly_treatment_other_amt
  14870. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  14871. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  14872. //
  14873. // }
  14874. //
  14875. // if registerCostTotal != 0 {
  14876. // iteminfo.MedChrgitm = "13"
  14877. // iteminfo.FulamtOwnpayAmt = register_fulamt_ownpay_amt
  14878. // iteminfo.Amt = registerCostTotal
  14879. // iteminfo.ClaaSumfee = register_claa_sunmfee
  14880. // iteminfo.ClabAmt = register_clab_amt
  14881. // iteminfo.OthAmt = register_other_amt
  14882. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  14883. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  14884. //
  14885. // }
  14886. //
  14887. // if otherCostTotal != 0 {
  14888. // iteminfo.MedChrgitm = "14"
  14889. // iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  14890. // iteminfo.Amt = otherCostTotal
  14891. // iteminfo.ClaaSumfee = other_claa_sunmfee
  14892. // iteminfo.ClabAmt = other_clab_amt
  14893. // iteminfo.OthAmt = other_other_amt
  14894. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  14895. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  14896. //
  14897. // }
  14898. // struct4101.IteminfoStruct = iteminfoStructs
  14899. // time_arr := strings.Split(order.SetlTime, " ")
  14900. // struct4101.AdmTime = time_arr[0]
  14901. // struct4101.AdmEndTime = time_arr[0]
  14902. //
  14903. // struct4101.DoctorName = doctor.UserName
  14904. // struct4101.DoctorCode = doctor.DoctorNumber
  14905. //
  14906. // struct4101.Ntly = "中国"
  14907. // struct4101.AdmCaty = "A03.06"
  14908. // var res ResultSeventeen
  14909. // if miConfig.MdtrtareaAdmvs == "421300" {
  14910. // data := make(map[string]interface{})
  14911. // data["struct4101"] = struct4101
  14912. // data["secret_key"] = miConfig.SecretKey
  14913. // data["org_name"] = miConfig.OrgName
  14914. // data["opera"] = curRoles.UserName
  14915. // data["code"] = miConfig.Code
  14916. // data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  14917. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  14918. //
  14919. // client := &http.Client{}
  14920. // bytesData, _ := json.Marshal(data)
  14921. // req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/4101", bytes.NewReader(bytesData))
  14922. // resp, _ := client.Do(req)
  14923. // defer resp.Body.Close()
  14924. // body, ioErr := ioutil.ReadAll(resp.Body)
  14925. // if ioErr != nil {
  14926. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14927. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14928. // return
  14929. // }
  14930. // var respJSON map[string]interface{}
  14931. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  14932. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14933. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14934. // return
  14935. // }
  14936. //
  14937. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  14938. // userJSONBytes, _ := json.Marshal(respJSON)
  14939. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14940. // utils.ErrorLog("解析失败:%v", err)
  14941. // //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14942. // adminUser := c.GetAdminUserInfo()
  14943. // errlog := &models.HisOrderError{
  14944. // UserOrgId: adminUser.CurrentOrgId,
  14945. // Ctime: time.Now().Unix(),
  14946. // Mtime: time.Now().Unix(),
  14947. // ErrMsg: res.ErrMsg + "解析失败",
  14948. // Status: 1,
  14949. // PatientId: order_id,
  14950. // Stage: 10088,
  14951. // }
  14952. // service.CreateErrMsgLog(errlog)
  14953. // continue
  14954. // }
  14955. //
  14956. // } else if miConfig.MdtrtareaAdmvs == "420200" {
  14957. // data := make(map[string]interface{})
  14958. // data["struct4101"] = struct4101
  14959. // data["secret_key"] = miConfig.SecretKey
  14960. // data["org_name"] = miConfig.OrgName
  14961. // data["opera"] = curRoles.UserName
  14962. // data["code"] = miConfig.Code
  14963. // data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  14964. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  14965. //
  14966. // client := &http.Client{}
  14967. // bytesData, _ := json.Marshal(data)
  14968. // req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/4101", bytes.NewReader(bytesData))
  14969. // resp, _ := client.Do(req)
  14970. // defer resp.Body.Close()
  14971. // body, ioErr := ioutil.ReadAll(resp.Body)
  14972. // if ioErr != nil {
  14973. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14974. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14975. // return
  14976. // }
  14977. // var respJSON map[string]interface{}
  14978. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  14979. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14980. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14981. // return
  14982. // }
  14983. //
  14984. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  14985. // userJSONBytes, _ := json.Marshal(respJSON)
  14986. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14987. // utils.ErrorLog("解析失败:%v", err)
  14988. // //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14989. // adminUser := c.GetAdminUserInfo()
  14990. // errlog := &models.HisOrderError{
  14991. // UserOrgId: adminUser.CurrentOrgId,
  14992. // Ctime: time.Now().Unix(),
  14993. // Mtime: time.Now().Unix(),
  14994. // ErrMsg: res.ErrMsg + "解析失败",
  14995. // Status: 1,
  14996. // PatientId: order_id,
  14997. // Stage: 10088,
  14998. // }
  14999. // service.CreateErrMsgLog(errlog)
  15000. // continue
  15001. // }
  15002. //
  15003. // } else {
  15004. // result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, c.GetAdminUserInfo().CurrentOrgId)
  15005. // fmt.Println(result)
  15006. //
  15007. // var dat map[string]interface{}
  15008. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  15009. // fmt.Println(dat)
  15010. // } else {
  15011. // fmt.Println(err)
  15012. // }
  15013. // userJSONBytes, _ := json.Marshal(dat)
  15014. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  15015. // utils.ErrorLog("解析失败:%v", err)
  15016. // //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15017. // adminUser := c.GetAdminUserInfo()
  15018. // errlog := &models.HisOrderError{
  15019. // UserOrgId: adminUser.CurrentOrgId,
  15020. // Ctime: time.Now().Unix(),
  15021. // Mtime: time.Now().Unix(),
  15022. // ErrMsg: res.ErrMsg + "解析失败",
  15023. // Status: 1,
  15024. // PatientId: order_id,
  15025. // Stage: 10106,
  15026. // }
  15027. // service.CreateErrMsgLog(errlog)
  15028. // continue
  15029. // }
  15030. // }
  15031. //
  15032. // if res.Infcode != 0 {
  15033. // adminUser := c.GetAdminUserInfo()
  15034. // errlog := &models.HisOrderError{
  15035. // UserOrgId: adminUser.CurrentOrgId,
  15036. // Ctime: time.Now().Unix(),
  15037. // Mtime: time.Now().Unix(),
  15038. // ErrMsg: res.ErrMsg,
  15039. // Status: 1,
  15040. // PatientId: order_id,
  15041. // Stage: 10106,
  15042. // }
  15043. // service.CreateErrMsgLog(errlog)
  15044. // continue
  15045. // } else {
  15046. // hisFundSettleListResult := &models.HisFundSettleListResult{
  15047. // Number: res.Output.SetlListId,
  15048. // Status: 1,
  15049. // Ctime: time.Now().Unix(),
  15050. // Mtime: time.Now().Unix(),
  15051. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15052. // IsUpload: 1,
  15053. // OrderId: order_id,
  15054. // }
  15055. // service.CreateUploadRecord(hisFundSettleListResult)
  15056. // continue
  15057. // }
  15058. // }
  15059. //}
  15060. func (c *HisApiController) GetOrgInfo() {
  15061. miConfig, _ := service.FindMedicalInsuranceInfo(4)
  15062. service.Gdyb1201("", miConfig.OrgName, "1122", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1, "")
  15063. }
  15064. func (c *HisApiController) GetHisPatientInfo() {
  15065. medical_insurance_card := c.GetString("medical_insurance_card")
  15066. id_card_type, _ := c.GetInt64("id_card_type")
  15067. id_card := c.GetString("id_card")
  15068. adminInfo := c.GetAdminUserInfo()
  15069. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  15070. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  15071. appRole, _ := service.GetAppRole(adminInfo.CurrentOrgId)
  15072. IdCardNo := ""
  15073. if id_card_type == 1 {
  15074. IdCardNo = medical_insurance_card
  15075. } else if id_card_type == 2 {
  15076. IdCardNo = id_card
  15077. }
  15078. if config.IsOpen == 1 {
  15079. 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
  15080. resp, requestErr := http.Get(api)
  15081. if requestErr != nil {
  15082. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15083. return
  15084. }
  15085. defer resp.Body.Close()
  15086. body, ioErr := ioutil.ReadAll(resp.Body)
  15087. if ioErr != nil {
  15088. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  15089. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15090. return
  15091. }
  15092. var respJSON map[string]interface{}
  15093. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  15094. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15095. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15096. return
  15097. }
  15098. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  15099. userJSONBytes, _ := json.Marshal(userJSON)
  15100. var res ResultTwo
  15101. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  15102. utils.ErrorLog("解析失败:%v", err)
  15103. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15104. return
  15105. }
  15106. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15107. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15108. infoStr := string(Iinfos)
  15109. idetinfoStr := string(Idetinfos)
  15110. if res.Infcode == 0 {
  15111. his := models.VMHisPatient{
  15112. Status: 1,
  15113. Ctime: time.Now().Unix(),
  15114. Mtime: time.Now().Unix(),
  15115. PsnNo: res.Output.Baseinfo.PsnNo,
  15116. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15117. Certno: res.Output.Baseinfo.Certno,
  15118. PsnName: res.Output.Baseinfo.PsnName,
  15119. Gend: res.Output.Baseinfo.Gend,
  15120. Naty: res.Output.Baseinfo.Naty,
  15121. Iinfo: infoStr,
  15122. Idetinfo: idetinfoStr,
  15123. UserOrgId: adminInfo.CurrentOrgId,
  15124. IsReturn: 1,
  15125. IdCardType: id_card_type,
  15126. }
  15127. c.ServeSuccessJSON(map[string]interface{}{
  15128. "info": his,
  15129. })
  15130. } else {
  15131. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15132. return
  15133. }
  15134. }
  15135. }
  15136. //func GetBasBaseInfo() (jsonStr string, err error) {
  15137. //
  15138. // handle := syscall.NewLazyDLL("SSCard.dll")
  15139. // add := handle.NewProc("ReadCardBas")
  15140. // str := make([]byte, 1024)
  15141. // str1 := make([]byte, 1024)
  15142. // ret, _, _ := add.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  15143. // fmt.Println(ConvertToString(string(str), "gbk", "utf-8"))
  15144. //
  15145. // fmt.Println(ConvertToString(string(str1), "gbk", "utf-8"))
  15146. //
  15147. // fmt.Println("> Add(4,5)的结果为:", ret)
  15148. // handle.Release()
  15149. //
  15150. // return "", nil
  15151. //
  15152. //}
  15153. //func GetQRBaseInfo() (jsonStr string, err error) {
  15154. // handle := syscall.LoadDLL("SSCard.dll")
  15155. // ReadCardBas := handle.FindProc("GetQRBase")
  15156. //
  15157. // str := make([]byte, 256)
  15158. // str1 := make([]byte, 256)
  15159. // r, _, _ := ReadCardBas.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  15160. //
  15161. // fmt.Println(string(str))
  15162. // fmt.Println(r)
  15163. // return string(str), nil
  15164. //}
  15165. //func CardInit() int {
  15166. // DllTestDef := syscall.MustLoadDLL("SSCard.dll")
  15167. // add := DllTestDef.MustFindProc("Init")
  15168. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  15169. // if err != nil {
  15170. // fmt.Println("SSCard的运算结果为:", ret)
  15171. // }
  15172. // result := int(ret)
  15173. // return result
  15174. //}
  15175. //func CardInit() int {
  15176. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  15177. // if err != nil {
  15178. // fmt.Println("SSCard的运算结果为:", ret)
  15179. // }
  15180. // fmt.Println(err)
  15181. // result := int(ret)
  15182. // return result
  15183. //}
  15184. func IntPtr(n int) uintptr {
  15185. return uintptr(n)
  15186. }
  15187. func StrPtr(s string) uintptr {
  15188. return uintptr(unsafe.Pointer(syscall.StringBytePtr(s)))
  15189. }
  15190. type Result2001 struct {
  15191. Cainfo interface{} `json:"cainfo"`
  15192. ErrMsg string `json:"err_msg"`
  15193. InfRefmsgid string `json:"inf_refmsgid"`
  15194. Infcode int64 `json:"infcode"`
  15195. Output struct {
  15196. Trtinfo struct {
  15197. PsnNo string `json:"psn_no"`
  15198. TrtChkType string `json:"trt_chk_type"`
  15199. FundPayType string `json:"fund_pay_type"`
  15200. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  15201. Begndate string `json:"begndate"`
  15202. Enddate string `json:"enddate"`
  15203. TrtChkRslt string `json:"trt_chk_rslt"`
  15204. } `json:"trtinfo"`
  15205. } `json:"output"`
  15206. RefmsgTime string `json:"refmsg_time"`
  15207. RespondTime string `json:"respond_time"`
  15208. Signtype interface{} `json:"signtype"`
  15209. WarnMsg interface{} `json:"warn_msg"`
  15210. }
  15211. type Result2001Org10265 struct {
  15212. Cainfo interface{} `json:"cainfo"`
  15213. ErrMsg string `json:"err_msg"`
  15214. InfRefmsgid string `json:"inf_refmsgid"`
  15215. Infcode string `json:"infcode"`
  15216. Output struct {
  15217. Trtinfo struct {
  15218. PsnNo string `json:"psn_no"`
  15219. TrtChkType string `json:"trt_chk_type"`
  15220. FundPayType string `json:"fund_pay_type"`
  15221. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  15222. Begndate string `json:"begndate"`
  15223. Enddate string `json:"enddate"`
  15224. TrtChkRslt string `json:"trt_chk_rslt"`
  15225. } `json:"trtinfo"`
  15226. } `json:"output"`
  15227. RefmsgTime string `json:"refmsg_time"`
  15228. RespondTime string `json:"respond_time"`
  15229. Signtype interface{} `json:"signtype"`
  15230. WarnMsg interface{} `json:"warn_msg"`
  15231. }
  15232. type ResultTwo struct {
  15233. ErrMsg string `json:"err_msg"`
  15234. InfRefmsgid string `json:"inf_refmsgid"`
  15235. Infcode int64 `json:"infcode"`
  15236. Output struct {
  15237. Baseinfo struct {
  15238. //Brdy string `json:"brdy"`
  15239. Certno string `json:"certno"`
  15240. Gend string `json:"gend"`
  15241. Naty string `json:"naty"`
  15242. PsnCertType string `json:"psn_cert_type"`
  15243. PsnName string `json:"psn_name"`
  15244. PsnNo string `json:"psn_no"`
  15245. } `json:"baseinfo"`
  15246. Idetinfo []interface{} `json:"idetinfo"`
  15247. Iinfo []struct {
  15248. Balc float64 `json:"balc"`
  15249. CvlservFlag string `json:"cvlserv_flag"`
  15250. EmpName string `json:"emp_name"`
  15251. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  15252. Insutype string `json:"insutype"`
  15253. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  15254. //PausInsuDate string `json:"paus_insu_date"`
  15255. //PsnInsuDate string `json:"psn_insu_date"`
  15256. PsnInsuStas string `json:"psn_insu_stas"`
  15257. PsnType string `json:"psn_type"`
  15258. } `json:"insuinfo"`
  15259. } `json:"output"`
  15260. RefmsgTime string `json:"refmsg_time"`
  15261. RespondTime string `json:"respond_time"`
  15262. Signtype interface{} `json:"signtype"`
  15263. WarnInfo interface{} `json:"warn_info"`
  15264. }
  15265. type ResultTwo10265 struct {
  15266. ErrMsg string `json:"err_msg"`
  15267. InfRefmsgid string `json:"inf_refmsgid"`
  15268. Infcode string `json:"infcode"`
  15269. Output struct {
  15270. Baseinfo struct {
  15271. //Brdy string `json:"brdy"`
  15272. Certno string `json:"certno"`
  15273. Gend string `json:"gend"`
  15274. Naty string `json:"naty"`
  15275. PsnCertType string `json:"psn_cert_type"`
  15276. PsnName string `json:"psn_name"`
  15277. PsnNo string `json:"psn_no"`
  15278. } `json:"baseinfo"`
  15279. Idetinfo []interface{} `json:"idetinfo"`
  15280. Iinfo []struct {
  15281. Balc float64 `json:"balc"`
  15282. CvlservFlag string `json:"cvlserv_flag"`
  15283. EmpName string `json:"emp_name"`
  15284. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  15285. Insutype string `json:"insutype"`
  15286. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  15287. PsnInsuStas string `json:"psn_insu_stas"`
  15288. PsnType string `json:"psn_type"`
  15289. } `json:"insuinfo"`
  15290. } `json:"output"`
  15291. RefmsgTime string `json:"refmsg_time"`
  15292. RespondTime string `json:"respond_time"`
  15293. Signtype interface{} `json:"signtype"`
  15294. WarnInfo interface{} `json:"warn_info"`
  15295. }
  15296. type ResultThree struct {
  15297. Cainfo interface{} `json:"cainfo"`
  15298. ErrMsg string `json:"err_msg"`
  15299. InfRefmsgid string `json:"inf_refmsgid"`
  15300. Infcode int64 `json:"infcode"`
  15301. Output struct {
  15302. Data struct {
  15303. IptOtpNo string `json:"ipt_otp_no"`
  15304. MdtrtID string `json:"mdtrt_id"`
  15305. PsnNo string `json:"psn_no"`
  15306. } `json:"data"`
  15307. } `json:"output"`
  15308. RefmsgTime string `json:"refmsg_time"`
  15309. RespondTime string `json:"respond_time"`
  15310. Signtype interface{} `json:"signtype"`
  15311. WarnMsg interface{} `json:"warn_msg"`
  15312. }
  15313. type ResultThree10265 struct {
  15314. Cainfo interface{} `json:"cainfo"`
  15315. ErrMsg string `json:"err_msg"`
  15316. InfRefmsgid string `json:"inf_refmsgid"`
  15317. Infcode string `json:"infcode"`
  15318. Output struct {
  15319. Data struct {
  15320. IptOtpNo string `json:"ipt_otp_no"`
  15321. MdtrtID string `json:"mdtrt_id"`
  15322. PsnNo string `json:"psn_no"`
  15323. } `json:"data"`
  15324. } `json:"output"`
  15325. RefmsgTime string `json:"refmsg_time"`
  15326. RespondTime string `json:"respond_time"`
  15327. Signtype interface{} `json:"signtype"`
  15328. WarnMsg interface{} `json:"warn_msg"`
  15329. }
  15330. type ResultFour struct {
  15331. Cainfo string `json:"cainfo"`
  15332. ErrMsg string `json:"err_msg"`
  15333. InfRefmsgid string `json:"inf_refmsgid"`
  15334. Infcode int64 `json:"infcode"`
  15335. Output struct {
  15336. Result []struct {
  15337. BasMednFlag string `json:"bas_medn_flag"`
  15338. ChldMedcFlag string `json:"chld_medc_flag"`
  15339. ChrgitmLv string `json:"chrgitm_lv"`
  15340. Cnt float64 `json:"cnt"`
  15341. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  15342. DrtReimFlag string `json:"drt_reim_flag"`
  15343. FeedetlSn string `json:"feedetl_sn"`
  15344. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  15345. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  15346. InscpScpAmt float64 `json:"inscp_scp_amt"`
  15347. ListSpItemFlag string `json:"list_sp_item_flag"`
  15348. LmtUsedFlag string `json:"lmt_used_flag"`
  15349. MedChrgitmType string `json:"med_chrgitm_type"`
  15350. Memo string `json:"memo"`
  15351. OverlmtAmt float64 `json:"overlmt_amt"`
  15352. PreselfpayAmt float64 `json:"preselfpay_amt"`
  15353. Pric float64 `json:"pric"`
  15354. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  15355. SelfpayProp float64 `json:"selfpay_prop"`
  15356. } `json:"result"`
  15357. } `json:"output"`
  15358. RefmsgTime string `json:"refmsg_time"`
  15359. RespondTime string `json:"respond_time"`
  15360. Signtype string `json:"signtype"`
  15361. WarnMsg string `json:"warn_msg"`
  15362. }
  15363. type ResultFour10265 struct {
  15364. Cainfo string `json:"cainfo"`
  15365. ErrMsg string `json:"err_msg"`
  15366. InfRefmsgid string `json:"inf_refmsgid"`
  15367. Infcode string `json:"infcode"`
  15368. Output struct {
  15369. Result []struct {
  15370. BasMednFlag string `json:"bas_medn_flag"`
  15371. ChldMedcFlag string `json:"chld_medc_flag"`
  15372. ChrgitmLv string `json:"chrgitm_lv"`
  15373. Cnt float64 `json:"cnt"`
  15374. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  15375. DrtReimFlag string `json:"drt_reim_flag"`
  15376. FeedetlSn string `json:"feedetl_sn"`
  15377. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  15378. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  15379. InscpScpAmt float64 `json:"inscp_scp_amt"`
  15380. ListSpItemFlag string `json:"list_sp_item_flag"`
  15381. LmtUsedFlag string `json:"lmt_used_flag"`
  15382. MedChrgitmType string `json:"med_chrgitm_type"`
  15383. Memo string `json:"memo"`
  15384. OverlmtAmt float64 `json:"overlmt_amt"`
  15385. PreselfpayAmt float64 `json:"preselfpay_amt"`
  15386. Pric float64 `json:"pric"`
  15387. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  15388. SelfpayProp float64 `json:"selfpay_prop"`
  15389. } `json:"result"`
  15390. } `json:"output"`
  15391. RefmsgTime string `json:"refmsg_time"`
  15392. RespondTime string `json:"respond_time"`
  15393. Signtype string `json:"signtype"`
  15394. WarnMsg string `json:"warn_msg"`
  15395. }
  15396. type ResultMemo struct {
  15397. InsuAdmdvs string `json:"insuAdmdvs"`
  15398. }
  15399. // [{"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}]
  15400. type ResultIDInfo struct {
  15401. Begntime string `json:"begntime"`
  15402. Endtime string `json:"endtime"`
  15403. Memo string `json:"memo"`
  15404. }
  15405. type ResultFive struct {
  15406. Balc float64 `json:"balc"`
  15407. CvlservFlag string `json:"cvlserv_flag"`
  15408. EmpName string `json:"emp_name"`
  15409. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  15410. Insutype string `json:"insutype"`
  15411. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  15412. PausInsuDate string `json:"paus_insu_date"`
  15413. PsnInsuDate string `json:"psn_insu_date"`
  15414. PsnInsuStas string `json:"psn_insu_stas"`
  15415. PsnType string `json:"psn_type"`
  15416. }
  15417. type ResultSix struct {
  15418. Cainfo interface{} `json:"cainfo"`
  15419. ErrMsg string `json:"err_msg"`
  15420. InfRefmsgid string `json:"inf_refmsgid"`
  15421. Infcode int64 `json:"infcode"`
  15422. Output struct {
  15423. } `json:"output"`
  15424. RefmsgTime string `json:"refmsg_time"`
  15425. RespondTime string `json:"respond_time"`
  15426. Signtype interface{} `json:"signtype"`
  15427. WarnMsg interface{} `json:"warn_msg"`
  15428. }
  15429. type Result2406 struct {
  15430. Cainfo interface{} `json:"cainfo"`
  15431. ErrMsg string `json:"err_msg"`
  15432. InfRefmsgid string `json:"inf_refmsgid"`
  15433. Infcode int64 `json:"infcode"`
  15434. Output struct {
  15435. Result struct {
  15436. IptPsnSpFlagDetlId string `json:"ipt_psn_sp_flag_detl_id"`
  15437. } `json:"result"`
  15438. } `json:"output"`
  15439. RefmsgTime string `json:"refmsg_time"`
  15440. RespondTime string `json:"respond_time"`
  15441. Signtype interface{} `json:"signtype"`
  15442. WarnMsg interface{} `json:"warn_msg"`
  15443. }
  15444. type GZResultSix struct {
  15445. Cainfo interface{} `json:"cainfo"`
  15446. ErrMsg string `json:"err_msg"`
  15447. InfRefmsgid string `json:"inf_refmsgid"`
  15448. Infcode int64 `json:"infcode"`
  15449. Output string `json:"output"`
  15450. RefmsgTime string `json:"refmsg_time"`
  15451. RespondTime string `json:"respond_time"`
  15452. Signtype interface{} `json:"signtype"`
  15453. WarnMsg interface{} `json:"warn_msg"`
  15454. }
  15455. type ResultSix10265 struct {
  15456. Cainfo interface{} `json:"cainfo"`
  15457. ErrMsg string `json:"err_msg"`
  15458. InfRefmsgid string `json:"inf_refmsgid"`
  15459. Infcode string `json:"infcode"`
  15460. Output struct {
  15461. } `json:"output"`
  15462. RefmsgTime string `json:"refmsg_time"`
  15463. RespondTime string `json:"respond_time"`
  15464. Signtype interface{} `json:"signtype"`
  15465. WarnMsg interface{} `json:"warn_msg"`
  15466. }
  15467. type ResultSeven struct {
  15468. Cainfo string `json:"cainfo"`
  15469. ErrMsg string `json:"err_msg"`
  15470. InfRefmsgid string `json:"inf_refmsgid"`
  15471. Infcode int64 `json:"infcode"`
  15472. Output struct {
  15473. Setlinfo struct {
  15474. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  15475. AcctPay float64 `json:"acct_pay"`
  15476. ActPayDedc float64 `json:"act_pay_dedc"`
  15477. Age float64 `json:"age"`
  15478. Balc float64 `json:"balc"`
  15479. Certno string `json:"certno"`
  15480. ClrOptins string `json:"clr_optins"`
  15481. ClrType string `json:"clr_type"`
  15482. ClrWay string `json:"clr_way"`
  15483. CvlservFlag string `json:"cvlserv_flag"`
  15484. CvlservPay float64 `json:"cvlserv_pay"`
  15485. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  15486. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  15487. Gend string `json:"gend"`
  15488. HifesPay float64 `json:"hifes_pay"`
  15489. HifmiPay float64 `json:"hifmi_pay"`
  15490. HifpPay float64 `json:"hifp_pay"`
  15491. HospPartAmt float64 `json:"hosp_part_amt"`
  15492. InscpScpAmt float64 `json:"inscp_scp_amt"`
  15493. Insutype string `json:"insutype"`
  15494. MafPay float64 `json:"maf_pay"`
  15495. MdtrtCertType string `json:"mdtrt_cert_type"`
  15496. HifobPay float64 `json:"hifob_pay"`
  15497. MdtrtID string `json:"mdtrt_id"`
  15498. MedType string `json:"med_type"`
  15499. MedfeeSumamt float64 `json:"medfee_sumamt"`
  15500. MedinsSetlID string `json:"medins_setl_id"`
  15501. Naty string `json:"naty"`
  15502. OthPay float64 `json:"oth_pay"`
  15503. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  15504. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  15505. PreselfpayAmt float64 `json:"preselfpay_amt"`
  15506. PsnCashPay float64 `json:"psn_cash_pay"`
  15507. PsnCertType string `json:"psn_cert_type"`
  15508. PsnName string `json:"psn_name"`
  15509. PsnNo string `json:"psn_no"`
  15510. PsnPartAmt float64 `json:"psn_part_amt"`
  15511. PsnType string `json:"psn_type"`
  15512. SetlID string `json:"setl_id"`
  15513. SetlTime string `json:"setl_time"`
  15514. } `json:"setlinfo"`
  15515. Setldetail interface{} `json:"setldetail"`
  15516. } `json:"output"`
  15517. RefmsgTime string `json:"refmsg_time"`
  15518. RespondTime string `json:"respond_time"`
  15519. Signtype interface{} `json:"signtype"`
  15520. WarnMsg interface{} `json:"warn_msg"`
  15521. }
  15522. type ResultSevenAH struct {
  15523. Cainfo string `json:"cainfo"`
  15524. ErrMsg string `json:"err_msg"`
  15525. InfRefmsgid string `json:"inf_refmsgid"`
  15526. Infcode int64 `json:"infcode"`
  15527. Output struct {
  15528. Setlinfo struct {
  15529. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  15530. AcctPay float64 `json:"acct_pay"`
  15531. ActPayDedc float64 `json:"act_pay_dedc"`
  15532. Age float64 `json:"age"`
  15533. Balc float64 `json:"balc"`
  15534. Certno string `json:"certno"`
  15535. ClrOptins string `json:"clr_optins"`
  15536. ClrType string `json:"clr_type"`
  15537. ClrWay string `json:"clr_way"`
  15538. CvlservFlag string `json:"cvlserv_flag"`
  15539. CvlservPay float64 `json:"cvlserv_pay"`
  15540. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  15541. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  15542. Gend string `json:"gend"`
  15543. HifesPay float64 `json:"hifes_pay"`
  15544. HifmiPay float64 `json:"hifmi_pay"`
  15545. HifpPay float64 `json:"hifp_pay"`
  15546. HospPartAmt float64 `json:"hosp_part_amt"`
  15547. InscpScpAmt float64 `json:"inscp_scp_amt"`
  15548. Insutype string `json:"insutype"`
  15549. MafPay float64 `json:"maf_pay"`
  15550. MdtrtCertType string `json:"mdtrt_cert_type"`
  15551. HifobPay float64 `json:"hifob_pay"`
  15552. MdtrtID string `json:"mdtrt_id"`
  15553. MedType string `json:"med_type"`
  15554. MedfeeSumamt float64 `json:"medfee_sumamt"`
  15555. MedinsSetlID string `json:"medins_setl_id"`
  15556. Naty string `json:"naty"`
  15557. OthPay float64 `json:"oth_pay"`
  15558. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  15559. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  15560. PreselfpayAmt float64 `json:"preselfpay_amt"`
  15561. PsnCashPay float64 `json:"psn_cash_pay"`
  15562. PsnCertType string `json:"psn_cert_type"`
  15563. PsnName string `json:"psn_name"`
  15564. PsnNo string `json:"psn_no"`
  15565. PsnPartAmt float64 `json:"psn_part_amt"`
  15566. PsnType string `json:"psn_type"`
  15567. SetlID string `json:"setl_id"`
  15568. SetlTime int64 `json:"setl_time"`
  15569. } `json:"setlinfo"`
  15570. Setldetail interface{} `json:"setldetail"`
  15571. } `json:"output"`
  15572. RefmsgTime string `json:"refmsg_time"`
  15573. RespondTime string `json:"respond_time"`
  15574. Signtype interface{} `json:"signtype"`
  15575. WarnMsg interface{} `json:"warn_msg"`
  15576. }
  15577. type ResultSeven10265 struct {
  15578. Cainfo string `json:"cainfo"`
  15579. ErrMsg string `json:"err_msg"`
  15580. InfRefmsgid string `json:"inf_refmsgid"`
  15581. Infcode string `json:"infcode"`
  15582. Output struct {
  15583. Setlinfo struct {
  15584. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  15585. AcctPay float64 `json:"acct_pay"`
  15586. ActPayDedc float64 `json:"act_pay_dedc"`
  15587. Age float64 `json:"age"`
  15588. Balc float64 `json:"balc"`
  15589. Certno string `json:"certno"`
  15590. ClrOptins string `json:"clr_optins"`
  15591. ClrType string `json:"clr_type"`
  15592. ClrWay string `json:"clr_way"`
  15593. CvlservFlag string `json:"cvlserv_flag"`
  15594. CvlservPay float64 `json:"cvlserv_pay"`
  15595. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  15596. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  15597. Gend string `json:"gend"`
  15598. HifesPay float64 `json:"hifes_pay"`
  15599. HifmiPay float64 `json:"hifmi_pay"`
  15600. HifpPay float64 `json:"hifp_pay"`
  15601. HospPartAmt float64 `json:"hosp_part_amt"`
  15602. InscpScpAmt float64 `json:"inscp_scp_amt"`
  15603. Insutype string `json:"insutype"`
  15604. MafPay float64 `json:"maf_pay"`
  15605. MdtrtCertType string `json:"mdtrt_cert_type"`
  15606. HifobPay float64 `json:"hifob_pay"`
  15607. MdtrtID string `json:"mdtrt_id"`
  15608. MedType string `json:"med_type"`
  15609. MedfeeSumamt float64 `json:"medfee_sumamt"`
  15610. MedinsSetlID string `json:"medins_setl_id"`
  15611. Naty string `json:"naty"`
  15612. OthPay float64 `json:"oth_pay"`
  15613. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  15614. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  15615. PreselfpayAmt float64 `json:"preselfpay_amt"`
  15616. PsnCashPay float64 `json:"psn_cash_pay"`
  15617. PsnCertType string `json:"psn_cert_type"`
  15618. PsnName string `json:"psn_name"`
  15619. PsnNo string `json:"psn_no"`
  15620. PsnPartAmt float64 `json:"psn_part_amt"`
  15621. PsnType string `json:"psn_type"`
  15622. SetlID string `json:"setl_id"`
  15623. SetlTime string `json:"setl_time"`
  15624. } `json:"setlinfo"`
  15625. Setldetail interface{} `json:"setldetail"`
  15626. } `json:"output"`
  15627. RefmsgTime string `json:"refmsg_time"`
  15628. RespondTime string `json:"respond_time"`
  15629. Signtype interface{} `json:"signtype"`
  15630. WarnMsg interface{} `json:"warn_msg"`
  15631. }
  15632. type ResultSeven10265Two struct {
  15633. Cainfo string `json:"cainfo"`
  15634. ErrMsg string `json:"err_msg"`
  15635. InfRefmsgid string `json:"inf_refmsgid"`
  15636. Infcode string `json:"infcode"`
  15637. Output struct {
  15638. Setlinfo struct {
  15639. AcctMulaidPay string `json:"acct_mulaid_pay"`
  15640. AcctPay float64 `json:"acct_pay"`
  15641. ActPayDedc float64 `json:"act_pay_dedc"`
  15642. Age float64 `json:"age"`
  15643. Balc float64 `json:"balc"`
  15644. Certno string `json:"certno"`
  15645. ClrOptins string `json:"clr_optins"`
  15646. ClrType string `json:"clr_type"`
  15647. ClrWay string `json:"clr_way"`
  15648. CvlservFlag string `json:"cvlserv_flag"`
  15649. CvlservPay float64 `json:"cvlserv_pay"`
  15650. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  15651. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  15652. Gend string `json:"gend"`
  15653. HifesPay float64 `json:"hifes_pay"`
  15654. HifmiPay float64 `json:"hifmi_pay"`
  15655. HifpPay float64 `json:"hifp_pay"`
  15656. HospPartAmt string `json:"hosp_part_amt"`
  15657. InscpScpAmt float64 `json:"inscp_scp_amt"`
  15658. Insutype string `json:"insutype"`
  15659. MafPay float64 `json:"maf_pay"`
  15660. MdtrtCertType string `json:"mdtrt_cert_type"`
  15661. HifobPay float64 `json:"hifob_pay"`
  15662. MdtrtID string `json:"mdtrt_id"`
  15663. MedType string `json:"med_type"`
  15664. MedfeeSumamt float64 `json:"medfee_sumamt"`
  15665. MedinsSetlID string `json:"medins_setl_id"`
  15666. Naty string `json:"naty"`
  15667. OthPay float64 `json:"oth_pay"`
  15668. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  15669. PoolPropSelfpay string `json:"pool_prop_selfpay"`
  15670. PreselfpayAmt float64 `json:"preselfpay_amt"`
  15671. PsnCashPay float64 `json:"psn_cash_pay"`
  15672. PsnCertType string `json:"psn_cert_type"`
  15673. PsnName string `json:"psn_name"`
  15674. PsnNo string `json:"psn_no"`
  15675. PsnPartAmt float64 `json:"psn_part_amt"`
  15676. PsnType string `json:"psn_type"`
  15677. SetlID string `json:"setl_id"`
  15678. SetlTime string `json:"setl_time"`
  15679. } `json:"setlinfo"`
  15680. Setldetail interface{} `json:"setldetail"`
  15681. } `json:"output"`
  15682. RefmsgTime string `json:"refmsg_time"`
  15683. RespondTime string `json:"respond_time"`
  15684. Signtype interface{} `json:"signtype"`
  15685. WarnMsg interface{} `json:"warn_msg"`
  15686. }
  15687. type GZResultSeven10265Two struct {
  15688. Cainfo string `json:"cainfo"`
  15689. ErrMsg string `json:"err_msg"`
  15690. InfRefmsgid string `json:"inf_refmsgid"`
  15691. Infcode int64 `json:"infcode"`
  15692. Output struct {
  15693. Setlinfo struct {
  15694. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  15695. AcctPay float64 `json:"acct_pay"`
  15696. ActPayDedc float64 `json:"act_pay_dedc"`
  15697. Age float64 `json:"age"`
  15698. Balc float64 `json:"balc"`
  15699. Certno string `json:"certno"`
  15700. ClrOptins string `json:"clr_optins"`
  15701. ClrType string `json:"clr_type"`
  15702. ClrWay string `json:"clr_way"`
  15703. CvlservFlag string `json:"cvlserv_flag"`
  15704. CvlservPay float64 `json:"cvlserv_pay"`
  15705. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  15706. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  15707. Gend string `json:"gend"`
  15708. HifesPay float64 `json:"hifes_pay"`
  15709. HifmiPay float64 `json:"hifmi_pay"`
  15710. HifpPay float64 `json:"hifp_pay"`
  15711. HospPartAmt float64 `json:"hosp_part_amt"`
  15712. InscpScpAmt float64 `json:"inscp_scp_amt"`
  15713. Insutype string `json:"insutype"`
  15714. MafPay float64 `json:"maf_pay"`
  15715. MdtrtCertType string `json:"mdtrt_cert_type"`
  15716. HifobPay float64 `json:"hifob_pay"`
  15717. MdtrtID string `json:"mdtrt_id"`
  15718. MedType string `json:"med_type"`
  15719. MedfeeSumamt float64 `json:"medfee_sumamt"`
  15720. MedinsSetlID string `json:"medins_setl_id"`
  15721. Naty string `json:"naty"`
  15722. OthPay float64 `json:"oth_pay"`
  15723. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  15724. PoolPropSelfpay string `json:"pool_prop_selfpay"`
  15725. PreselfpayAmt float64 `json:"preselfpay_amt"`
  15726. PsnCashPay float64 `json:"psn_cash_pay"`
  15727. PsnCertType string `json:"psn_cert_type"`
  15728. PsnName string `json:"psn_name"`
  15729. PsnNo string `json:"psn_no"`
  15730. PsnPartAmt float64 `json:"psn_part_amt"`
  15731. PsnType string `json:"psn_type"`
  15732. SetlID string `json:"setl_id"`
  15733. SetlTime string `json:"setl_time"`
  15734. } `json:"setlinfo"`
  15735. Setldetail interface{} `json:"setldetail"`
  15736. } `json:"output"`
  15737. RefmsgTime string `json:"refmsg_time"`
  15738. RespondTime string `json:"respond_time"`
  15739. Signtype interface{} `json:"signtype"`
  15740. WarnMsg interface{} `json:"warn_msg"`
  15741. }
  15742. type ResultEight struct {
  15743. Cainfo string `json:"cainfo"`
  15744. ErrMsg string `json:"err_msg"`
  15745. InfRefmsgid string `json:"inf_refmsgid"`
  15746. Infcode int64 `json:"infcode"`
  15747. Output struct {
  15748. Stmtinfo struct {
  15749. SetlOptins string `json:"setl_optins"`
  15750. StmtRslt string `json:"stmt_rslt"`
  15751. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  15752. } `json:"stmtinfo"`
  15753. } `json:"output"`
  15754. RefmsgTime string `json:"refmsg_time"`
  15755. RespondTime string `json:"respond_time"`
  15756. Signtype interface{} `json:"signtype"`
  15757. WarnMsg interface{} `json:"warn_msg"`
  15758. }
  15759. type ResultEightFor10188 struct {
  15760. Cainfo string `json:"cainfo"`
  15761. ErrMsg string `json:"err_msg"`
  15762. InfRefmsgid string `json:"inf_refmsgid"`
  15763. Infcode string `json:"infcode"`
  15764. Output struct {
  15765. Stmtinfo struct {
  15766. SetlOptins string `json:"setl_optins"`
  15767. StmtRslt string `json:"stmt_rslt"`
  15768. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  15769. } `json:"stmtinfo"`
  15770. } `json:"output"`
  15771. RefmsgTime string `json:"refmsg_time"`
  15772. RespondTime string `json:"respond_time"`
  15773. Signtype interface{} `json:"signtype"`
  15774. WarnMsg interface{} `json:"warn_msg"`
  15775. }
  15776. type ResultNine struct {
  15777. Cainfo string `json:"cainfo"`
  15778. ErrMsg string `json:"err_msg"`
  15779. InfRefmsgid string `json:"inf_refmsgid"`
  15780. Infcode int64 `json:"infcode"`
  15781. Output struct {
  15782. FileQuryNo string `json:"file_qury_no"`
  15783. } `json:"output"`
  15784. RefmsgTime string `json:"refmsg_time"`
  15785. RespondTime string `json:"respond_time"`
  15786. Signtype interface{} `json:"signtype"`
  15787. WarnMsg interface{} `json:"warn_msg"`
  15788. }
  15789. type ResultTen struct {
  15790. Cainfo string `json:"cainfo"`
  15791. ErrMsg string `json:"err_msg"`
  15792. InfRefmsgid string `json:"inf_refmsgid"`
  15793. Infcode int64 `json:"infcode"`
  15794. Output struct {
  15795. Fileinfo struct {
  15796. DldEndtime string `json:"dld_endtime"`
  15797. FileQuryNo string `json:"file_qury_no"`
  15798. Filename string `json:"filename"`
  15799. } `json:"fileinfo"`
  15800. } `json:"output"`
  15801. RefmsgTime string `json:"refmsg_time"`
  15802. RespondTime string `json:"respond_time"`
  15803. Signtype interface{} `json:"signtype"`
  15804. WarnMsg interface{} `json:"warn_msg"`
  15805. }
  15806. type Result5262 struct {
  15807. ErrMsg string `json:"err_msg"`
  15808. InfRefmsgid string `json:"inf_refmsgid"`
  15809. Infcode int64 `json:"infcode"`
  15810. Output struct {
  15811. PageInfo struct {
  15812. Size int `json:"size"`
  15813. RecordCounts int `json:"record_counts"`
  15814. } `json:"page_info"`
  15815. Idetinfo []interface{} `json:"idetinfo"`
  15816. Result []struct {
  15817. SetlID string `json:"setl_id"`
  15818. MedinsSetlID string `json:"medins_setl_id,omitempty"`
  15819. MdtrtID string `json:"mdtrt_id"`
  15820. InitSetlID string `json:"init_setl_id,omitempty"`
  15821. PsnNo string `json:"psn_no"`
  15822. PsnInsuRltsID string `json:"psn_insu_rlts_id,omitempty"`
  15823. PsnName string `json:"psn_name"`
  15824. PsnCertType string `json:"psn_cert_type"`
  15825. Certno string `json:"certno"`
  15826. Gend string `json:"gend,omitempty"`
  15827. Naty string `json:"naty,omitempty"`
  15828. Brdy string `json:"brdy,omitempty"`
  15829. Age float64 `json:"age,omitempty"`
  15830. Insutype string `json:"insutype,omitempty"`
  15831. PsnType string `json:"psn_type"`
  15832. CvlservFlag string `json:"cvlserv_flag"`
  15833. CvlservLv string `json:"cvlserv_lv,omitempty"`
  15834. SpPsnType string `json:"sp_psn_type,omitempty"`
  15835. SpPsnTypeLv string `json:"sp_psn_type_lv,omitempty"`
  15836. ClctGrde string `json:"clct_grde,omitempty"`
  15837. FlxempeFlag string `json:"flxempe_flag,omitempty"`
  15838. NwbFlag string `json:"nwb_flag,omitempty"`
  15839. InsuAdmdvs string `json:"insu_admdvs"`
  15840. EmpNo string `json:"emp_no,omitempty"`
  15841. EmpName string `json:"emp_name,omitempty"`
  15842. EmpType string `json:"emp_type,omitempty"`
  15843. EconType string `json:"econ_type,omitempty"`
  15844. AfilIndu string `json:"afil_indu,omitempty"`
  15845. AfilRlts string `json:"afil_rlts,omitempty"`
  15846. EmpMgtType string `json:"emp_mgt_type,omitempty"`
  15847. PayLoc string `json:"pay_loc,omitempty"`
  15848. FixmedinsCode string `json:"fixmedins_code"`
  15849. FixmedinsName string `json:"fixmedins_name"`
  15850. HospLv string `json:"hosp_lv,omitempty"`
  15851. FixBlngAdmdvs string `json:"fix_blng_admdvs,omitempty"`
  15852. LmtpricHospLv string `json:"lmtpric_hosp_lv,omitempty"`
  15853. DedcHospLv string `json:"dedc_hosp_lv,omitempty"`
  15854. Begndate string `json:"begndate"`
  15855. Enddate string `json:"enddate"`
  15856. SetlTime string `json:"setl_time"`
  15857. MdtrtCertType string `json:"mdtrt_cert_type,omitempty"`
  15858. MdtrtCertNo string `json:"mdtrt_cert_no,omitempty"`
  15859. MedType string `json:"med_type"`
  15860. SetlType string `json:"setl_type,omitempty"`
  15861. ClrType string `json:"clr_type,omitempty"`
  15862. ClrWay string `json:"clr_way,omitempty"`
  15863. PsnSetlway string `json:"psn_setlway,omitempty"`
  15864. ClrOptins string `json:"clr_optins,omitempty"`
  15865. MedfeeSumamt float64 `json:"medfee_sumamt,omitempty"`
  15866. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt,omitempty"`
  15867. OverlmtSelfpay float64 `json:"overlmt_selfpay,omitempty"`
  15868. PreselfpayAmt float64 `json:"preselfpay_amt,omitempty"`
  15869. InscpAmt float64 `json:"inscp_amt,omitempty"`
  15870. DedcStd float64 `json:"dedc_std,omitempty"`
  15871. CrtDedc float64 `json:"crt_dedc,omitempty"`
  15872. ActPayDedc float64 `json:"act_pay_dedc,omitempty"`
  15873. HifpPay float64 `json:"hifp_pay,omitempty"`
  15874. PoolPropSelfpay float64 `json:"pool_prop_selfpay,omitempty"`
  15875. HiAgreSumfee float64 `json:"hi_agre_sumfee,omitempty"`
  15876. CvlservPay float64 `json:"cvlserv_pay,omitempty"`
  15877. HifesPay float64 `json:"hifes_pay,omitempty"`
  15878. HifmiPay float64 `json:"hifmi_pay,omitempty"`
  15879. HifobPay float64 `json:"hifob_pay,omitempty"`
  15880. HifdmPay float64 `json:"hifdm_pay,omitempty"`
  15881. MafPay float64 `json:"maf_pay,omitempty"`
  15882. OthfundPay float64 `json:"othfund_pay,omitempty"`
  15883. FundPaySumamt float64 `json:"fund_pay_sumamt,omitempty"`
  15884. PsnPay float64 `json:"psn_pay,omitempty"`
  15885. AcctPay float64 `json:"acct_pay,omitempty"`
  15886. CashPayamt float64 `json:"cash_payamt,omitempty"`
  15887. OwnpayHospPart float64 `json:"ownpay_hosp_part,omitempty"`
  15888. Balc float64 `json:"balc,omitempty"`
  15889. AcctMulaidPay float64 `json:"acct_mulaid_pay,omitempty"`
  15890. RefdSetlFlag string `json:"refd_setl_flag,omitempty"`
  15891. CalIptCnt string `json:"cal_ipt_cnt,omitempty"`
  15892. SetlCashpayWay string `json:"setl_cashpay_way,omitempty"`
  15893. Year string `json:"year,omitempty"`
  15894. DiseNo string `json:"dise_no,omitempty"`
  15895. DiseName string `json:"dise_name,omitempty"`
  15896. Invono string `json:"invono,omitempty"`
  15897. ManlReimRea string `json:"manl_reim_rea,omitempty"`
  15898. ValiFlag string `json:"vali_flag,omitempty"`
  15899. Memo string `json:"memo,omitempty"`
  15900. Rid string `json:"rid"`
  15901. UpdtTime string `json:"updt_time,omitempty"`
  15902. CrterID string `json:"crter_id,omitempty"`
  15903. CrterName string `json:"crter_name,omitempty"`
  15904. CrteTime string `json:"crte_time,omitempty"`
  15905. CrteOptinsNo string `json:"crte_optins_no,omitempty"`
  15906. OpterID string `json:"opter_id,omitempty"`
  15907. OpterName string `json:"opter_name,omitempty"`
  15908. OptTime string `json:"opt_time,omitempty"`
  15909. OptinsNo string `json:"optins_no,omitempty"`
  15910. PoolareaNo string `json:"poolarea_no,omitempty"`
  15911. } `json:"result"`
  15912. } `json:"output"`
  15913. RefmsgTime string `json:"refmsg_time"`
  15914. RespondTime string `json:"respond_time"`
  15915. Signtype interface{} `json:"signtype"`
  15916. WarnInfo interface{} `json:"warn_info"`
  15917. }
  15918. type Result5267 struct {
  15919. ErrMsg string `json:"err_msg"`
  15920. InfRefmsgid string `json:"inf_refmsgid"`
  15921. Infcode int64 `json:"infcode"`
  15922. Output struct {
  15923. PageInfo struct {
  15924. Size int `json:"size"`
  15925. RecordCounts int `json:"record_counts"`
  15926. } `json:"pageinfo"`
  15927. Result []struct {
  15928. SetlID string `json:"setl_id"`
  15929. ClrOptins string `json:"clr_optins"`
  15930. MedinsSetlID string `json:"medins_setl_id,omitempty"`
  15931. MdtrtID string `json:"mdtrt_id"`
  15932. InitSetlID string `json:"init_setl_id,omitempty"`
  15933. PsnNo string `json:"psn_no"`
  15934. PsnInsuRltsID string `json:"psn_insu_rlts_id,omitempty"`
  15935. PsnName string `json:"psn_name"`
  15936. PsnCertType string `json:"psn_cert_type"`
  15937. Certno string `json:"certno"`
  15938. Gend string `json:"gend,omitempty"`
  15939. Naty string `json:"naty,omitempty"`
  15940. Brdy string `json:"brdy,omitempty"`
  15941. Age float64 `json:"age,omitempty"`
  15942. Insutype string `json:"insutype,omitempty"`
  15943. PsnType string `json:"psn_type"`
  15944. CvlservFlag string `json:"cvlserv_flag"`
  15945. CvlservLv string `json:"cvlserv_lv,omitempty"`
  15946. SpPsnType string `json:"sp_psn_type,omitempty"`
  15947. SpPsnTypeLv string `json:"sp_psn_type_lv,omitempty"`
  15948. ClctGrde string `json:"clct_grde,omitempty"`
  15949. FlxempeFlag string `json:"flxempe_flag,omitempty"`
  15950. NwbFlag string `json:"nwb_flag,omitempty"`
  15951. InsuAdmdvs string `json:"insu_admdvs"`
  15952. EmpNo string `json:"emp_no,omitempty"`
  15953. EmpName string `json:"emp_name,omitempty"`
  15954. EmpType string `json:"emp_type,omitempty"`
  15955. EconType string `json:"econ_type,omitempty"`
  15956. AfilIndu string `json:"afil_indu,omitempty"`
  15957. AfilRlts string `json:"afil_rlts,omitempty"`
  15958. EmpMgtType string `json:"emp_mgt_type,omitempty"`
  15959. PayLoc string `json:"pay_loc,omitempty"`
  15960. FixmedinsCode string `json:"fixmedins_code"`
  15961. FixmedinsName string `json:"fixmedins_name"`
  15962. HospLv string `json:"hosp_lv,omitempty"`
  15963. FixBlngAdmdvs string `json:"fix_blng_admdvs,omitempty"`
  15964. LmtpricHospLv string `json:"lmtpric_hosp_lv,omitempty"`
  15965. DedcHospLv string `json:"dedc_hosp_lv,omitempty"`
  15966. Begndate string `json:"begndate,omitempty"`
  15967. Enddate string `json:"enddate,omitempty"`
  15968. SetlTime string `json:"setl_time,omitempty"`
  15969. MdtrtCertType string `json:"mdtrt_cert_type,omitempty"`
  15970. MdtrtCertNo string `json:"mdtrt_cert_no,omitempty"`
  15971. MedType string `json:"med_type"`
  15972. SetlType string `json:"setl_type,omitempty"`
  15973. ClrType string `json:"clr_type,omitempty"`
  15974. ClrWay string `json:"clr_way,omitempty"`
  15975. PsnSetlway string `json:"psn_setlway,omitempty"`
  15976. MedfeeSumamt float64 `json:"medfee_sumamt,omitempty"`
  15977. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt,omitempty"`
  15978. OverlmtSelfpay float64 `json:"overlmt_selfpay,omitempty"`
  15979. PreselfpayAmt float64 `json:"preselfpay_amt,omitempty"`
  15980. InscpAmt float64 `json:"inscp_amt,omitempty"`
  15981. DedcStd float64 `json:"dedc_std,omitempty"`
  15982. CrtDedc float64 `json:"crt_dedc,omitempty"`
  15983. ActPayDedc float64 `json:"act_pay_dedc,omitempty"`
  15984. HifpPay float64 `json:"hifp_pay,omitempty"`
  15985. PoolPropSelfpay float64 `json:"pool_prop_selfpay,omitempty"`
  15986. HiAgreSumfee float64 `json:"hi_agre_sumfee,omitempty"`
  15987. CvlservPay float64 `json:"cvlserv_pay,omitempty"`
  15988. HifesPay float64 `json:"hifes_pay,omitempty"`
  15989. HifmiPay float64 `json:"hifmi_pay,omitempty"`
  15990. HifobPay float64 `json:"hifob_pay,omitempty"`
  15991. HifdmPay float64 `json:"hifdm_pay,omitempty"`
  15992. MafPay float64 `json:"maf_pay,omitempty"`
  15993. OthfundPay float64 `json:"othfund_pay,omitempty"`
  15994. FundPaySumamt float64 `json:"fund_pay_sumamt,omitempty"`
  15995. PsnPay float64 `json:"psn_pay,omitempty"`
  15996. AcctPay float64 `json:"acct_pay,omitempty"`
  15997. CashPayamt float64 `json:"cash_payamt,omitempty"`
  15998. OwnpayHospPart float64 `json:"ownpay_hosp_part,omitempty"`
  15999. Balc float64 `json:"balc,omitempty"`
  16000. AcctMulaidPay float64 `json:"acct_mulaid_pay,omitempty"`
  16001. RefdSetlFlag string `json:"refd_setl_flag,omitempty"`
  16002. CalIptCnt string `json:"cal_ipt_cnt,omitempty"`
  16003. SetlCashpayWay string `json:"setl_cashpay_way,omitempty"`
  16004. Year string `json:"year,omitempty"`
  16005. DiseNo string `json:"dise_no,omitempty"`
  16006. DiseName string `json:"dise_name,omitempty"`
  16007. Invono string `json:"invono,omitempty"`
  16008. ManlReimRea string `json:"manl_reim_rea,omitempty"`
  16009. Memo string `json:"memo,omitempty"`
  16010. UpdtTime string `json:"updt_time,omitempty"`
  16011. OpterID string `json:"opter_id,omitempty"`
  16012. OpterName string `json:"opter_name,omitempty"`
  16013. OptTime string `json:"opt_time,omitempty"`
  16014. OptinsNo string `json:"optins_no,omitempty"`
  16015. PoolareaNo string `json:"poolarea_no,omitempty"`
  16016. } `json:"result"`
  16017. } `json:"output"`
  16018. RefmsgTime string `json:"refmsg_time"`
  16019. RespondTime string `json:"respond_time"`
  16020. Signtype interface{} `json:"signtype"`
  16021. WarnInfo interface{} `json:"warn_info"`
  16022. }
  16023. // type Autogenerated struct {
  16024. // Output struct {
  16025. // Setlinfo struct {
  16026. // SetlTime string `json:"setl_time"`
  16027. // CvlservPay float64 `json:"cvlserv_pay"`
  16028. // Year string `json:"year"`
  16029. // MedType string `json:"med_type"`
  16030. // PsnPay float64 `json:"psn_pay"`
  16031. // OpterID string `json:"opter_id"`
  16032. // Begndate string `json:"begndate"`
  16033. // FlxempeFlag string `json:"flxempe_flag"`
  16034. // HifmiPay float64 `json:"hifmi_pay"`
  16035. // PsnNo string `json:"psn_no"`
  16036. // ActPayDedc float64 `json:"act_pay_dedc"`
  16037. // MedinsSetlID interface{} `json:"medins_setl_id"`
  16038. // AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  16039. // ClrWay string `json:"clr_way"`
  16040. // OthPay float64 `json:"oth_pay"`
  16041. // Gend string `json:"gend"`
  16042. // MdtrtID string `json:"mdtrt_id"`
  16043. // AcctPay float64 `json:"acct_pay"`
  16044. // InscpScpAmt float64 `json:"inscp_scp_amt"`
  16045. // Insutype string `json:"insutype"`
  16046. // Invono interface{} `json:"invono"`
  16047. // Enddate string `json:"enddate"`
  16048. // CashPayamt float64 `json:"cash_payamt"`
  16049. // PsnType string `json:"psn_type"`
  16050. // FixmedinsName string `json:"fixmedins_name"`
  16051. // HifpPay float64 `json:"hifp_pay"`
  16052. // NewFlag interface{} `json:"new_flag"`
  16053. // OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  16054. // PreselfpayAmt float64 `json:"preselfpay_amt"`
  16055. // PayLoc string `json:"pay_loc"`
  16056. // ClrType string `json:"clr_type"`
  16057. // RefdSetlFlag string `json:"refd_setl_flag"`
  16058. // CvlservFlag string `json:"cvlserv_flag"`
  16059. // EmpName string `json:"emp_name"`
  16060. // Brdy string `json:"brdy"`
  16061. // Naty string `json:"naty"`
  16062. // Certno string `json:"certno"`
  16063. // DiseCode string `json:"dise_code"`
  16064. // FixmedinsCode string `json:"fixmedins_code"`
  16065. // DedcHospLv string `json:"dedc_hosp_lv"`
  16066. // OpterName string `json:"opter_name"`
  16067. // Balc float64 `json:"balc"`
  16068. // FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  16069. // PsnCertType string `json:"psn_cert_type"`
  16070. // HifobPay float64 `json:"hifob_pay"`
  16071. // MedfeeSumamt float64 `json:"medfee_sumamt"`
  16072. // HifesPay float64 `json:"hifes_pay"`
  16073. // FundPaySumamt float64 `json:"fund_pay_sumamt"`
  16074. // OptTime string `json:"opt_time"`
  16075. // FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  16076. // SetlID string `json:"setl_id"`
  16077. // MafPay float64 `json:"maf_pay"`
  16078. // PsnName string `json:"psn_name"`
  16079. // InsuOptins interface{} `json:"insu_optins"`
  16080. // PrefFundPay interface{} `json:"pref_fund_pay"`
  16081. // ClrOptins string `json:"clr_optins"`
  16082. // PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  16083. // DiseName string `json:"dise_name"`
  16084. // LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  16085. // Age float64 `json:"age"`
  16086. // DtrtCertType string `json:"dtrt_cert_type"`
  16087. // HospLv string `json:"hosp_lv"`
  16088. // } `json:"setlinfo"`
  16089. // Setldetail []struct {
  16090. // FundPayType string `json:"fund_pay_type"`
  16091. // FundPayamt float64 `json:"fund_payamt"`
  16092. // SetlProcInfo interface{} `json:"setl_proc_info"`
  16093. // CrtPaybLmtAmt interface{} `json:"crt_payb_lmt_amt"`
  16094. // InscpScpAmt interface{} `json:"inscp_scp_amt"`
  16095. // FundPayTypeName interface{} `json:"fund_pay_type_name"`
  16096. // PrefFundPay interface{} `json:"pref_fund_pay"`
  16097. // } `json:"setldetail"`
  16098. // } `json:"output"`
  16099. // Infcode int `json:"infcode"`
  16100. // WarnMsg interface{} `json:"warn_msg"`
  16101. // Cainfo interface{} `json:"cainfo"`
  16102. // ErrMsg interface{} `json:"err_msg"`
  16103. // RefmsgTime string `json:"refmsg_time"`
  16104. // Signtype interface{} `json:"signtype"`
  16105. // RespondTime string `json:"respond_time"`
  16106. // InfRefmsgid string `json:"inf_refmsgid"`
  16107. // }
  16108. type Result002 struct {
  16109. Cainfo interface{} `json:"cainfo"`
  16110. ErrMsg string `json:"err_msg"`
  16111. InfRefmsgid string `json:"inf_refmsgid"`
  16112. Infcode int64 `json:"infcode"`
  16113. Output struct {
  16114. RxFile string `json:"rx_file"`
  16115. SignDigest string `json:"sign_digest"`
  16116. SignCertSn string `json:"sign_cert_sn"`
  16117. SignCertDn string `json:"sign_cert_dn"`
  16118. } `json:"output"`
  16119. RefmsgTime string `json:"refmsg_time"`
  16120. RespondTime string `json:"respond_time"`
  16121. Signtype interface{} `json:"signtype"`
  16122. WarnMsg interface{} `json:"warn_msg"`
  16123. }
  16124. type Result003 struct {
  16125. Cainfo interface{} `json:"cainfo"`
  16126. ErrMsg string `json:"err_msg"`
  16127. InfRefmsgid string `json:"inf_refmsgid"`
  16128. Infcode int64 `json:"infcode"`
  16129. Output struct {
  16130. HiRxno string `json:"hi_rxno"`
  16131. RxStasCodg string `json:"rx_stas_codg"`
  16132. RxStasName string `json:"rx_stas_name"`
  16133. } `json:"output"`
  16134. RefmsgTime string `json:"refmsg_time"`
  16135. RespondTime string `json:"respond_time"`
  16136. Signtype interface{} `json:"signtype"`
  16137. WarnMsg interface{} `json:"warn_msg"`
  16138. }
  16139. type ResultEleven struct {
  16140. Cainfo string `json:"cainfo"`
  16141. ErrMsg string `json:"err_msg"`
  16142. InfRefmsgid string `json:"inf_refmsgid"`
  16143. Infcode int64 `json:"infcode"`
  16144. Output struct {
  16145. Setlinfo struct {
  16146. SetlTime string `json:"setl_time"`
  16147. CvlservPay float64 `json:"cvlserv_pay"`
  16148. Year string `json:"year"`
  16149. MedType string `json:"med_type"`
  16150. PsnPay float64 `json:"psn_pay"`
  16151. OpterID string `json:"opter_id"`
  16152. Begndate string `json:"begndate"`
  16153. FlxempeFlag string `json:"flxempe_flag"`
  16154. HifmiPay float64 `json:"hifmi_pay"`
  16155. PsnNo string `json:"psn_no"`
  16156. ActPayDedc float64 `json:"act_pay_dedc"`
  16157. MedinsSetlID interface{} `json:"medins_setl_id"`
  16158. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  16159. ClrWay string `json:"clr_way"`
  16160. OthPay float64 `json:"oth_pay"`
  16161. Gend string `json:"gend"`
  16162. MdtrtID string `json:"mdtrt_id"`
  16163. AcctPay float64 `json:"acct_pay"`
  16164. InscpScpAmt float64 `json:"inscp_scp_amt"`
  16165. Insutype string `json:"insutype"`
  16166. Invono interface{} `json:"invono"`
  16167. Enddate string `json:"enddate"`
  16168. CashPayamt float64 `json:"cash_payamt"`
  16169. PsnType string `json:"psn_type"`
  16170. FixmedinsName string `json:"fixmedins_name"`
  16171. HifpPay float64 `json:"hifp_pay"`
  16172. NewFlag interface{} `json:"new_flag"`
  16173. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  16174. PreselfpayAmt float64 `json:"preselfpay_amt"`
  16175. PayLoc string `json:"pay_loc"`
  16176. ClrType string `json:"clr_type"`
  16177. RefdSetlFlag string `json:"refd_setl_flag"`
  16178. CvlservFlag string `json:"cvlserv_flag"`
  16179. EmpName string `json:"emp_name"`
  16180. Brdy string `json:"brdy"`
  16181. Naty string `json:"naty"`
  16182. Certno string `json:"certno"`
  16183. DiseCode string `json:"dise_code"`
  16184. FixmedinsCode string `json:"fixmedins_code"`
  16185. DedcHospLv string `json:"dedc_hosp_lv"`
  16186. OpterName string `json:"opter_name"`
  16187. Balc float64 `json:"balc"`
  16188. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  16189. PsnCertType string `json:"psn_cert_type"`
  16190. HifobPay float64 `json:"hifob_pay"`
  16191. MedfeeSumamt float64 `json:"medfee_sumamt"`
  16192. HifesPay float64 `json:"hifes_pay"`
  16193. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  16194. OptTime string `json:"opt_time"`
  16195. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  16196. SetlID string `json:"setl_id"`
  16197. MafPay float64 `json:"maf_pay"`
  16198. PsnName string `json:"psn_name"`
  16199. InsuOptins interface{} `json:"insu_optins"`
  16200. PrefFundPay interface{} `json:"pref_fund_pay"`
  16201. ClrOptins string `json:"clr_optins"`
  16202. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  16203. DiseName string `json:"dise_name"`
  16204. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  16205. Age float64 `json:"age"`
  16206. DtrtCertType string `json:"dtrt_cert_type"`
  16207. HospLv string `json:"hosp_lv"`
  16208. PsnCashPay float64 `json:"psn_cash_pay"`
  16209. } `json:"setlinfo"`
  16210. } `json:"output"`
  16211. RefmsgTime string `json:"refmsg_time"`
  16212. RespondTime string `json:"respond_time"`
  16213. Signtype interface{} `json:"signtype"`
  16214. WarnMsg interface{} `json:"warn_msg"`
  16215. }
  16216. type ResultElevenah struct {
  16217. Cainfo string `json:"cainfo"`
  16218. ErrMsg string `json:"err_msg"`
  16219. InfRefmsgid string `json:"inf_refmsgid"`
  16220. Infcode int64 `json:"infcode"`
  16221. Output struct {
  16222. Setlinfo struct {
  16223. SetlTime int64 `json:"setl_time"`
  16224. CvlservPay float64 `json:"cvlserv_pay"`
  16225. Year string `json:"year"`
  16226. MedType string `json:"med_type"`
  16227. PsnPay float64 `json:"psn_pay"`
  16228. OpterID string `json:"opter_id"`
  16229. Begndate int64 `json:"begndate"`
  16230. FlxempeFlag string `json:"flxempe_flag"`
  16231. HifmiPay float64 `json:"hifmi_pay"`
  16232. PsnNo string `json:"psn_no"`
  16233. ActPayDedc float64 `json:"act_pay_dedc"`
  16234. MedinsSetlID interface{} `json:"medins_setl_id"`
  16235. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  16236. ClrWay string `json:"clr_way"`
  16237. OthPay float64 `json:"oth_pay"`
  16238. Gend string `json:"gend"`
  16239. MdtrtID string `json:"mdtrt_id"`
  16240. AcctPay float64 `json:"acct_pay"`
  16241. InscpScpAmt float64 `json:"inscp_scp_amt"`
  16242. Insutype string `json:"insutype"`
  16243. Invono interface{} `json:"invono"`
  16244. Enddate int64 `json:"enddate"`
  16245. CashPayamt float64 `json:"cash_payamt"`
  16246. PsnType string `json:"psn_type"`
  16247. FixmedinsName string `json:"fixmedins_name"`
  16248. HifpPay float64 `json:"hifp_pay"`
  16249. NewFlag interface{} `json:"new_flag"`
  16250. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  16251. PreselfpayAmt float64 `json:"preselfpay_amt"`
  16252. PayLoc string `json:"pay_loc"`
  16253. ClrType string `json:"clr_type"`
  16254. RefdSetlFlag string `json:"refd_setl_flag"`
  16255. CvlservFlag string `json:"cvlserv_flag"`
  16256. EmpName string `json:"emp_name"`
  16257. Brdy int64 `json:"brdy"`
  16258. Naty string `json:"naty"`
  16259. Certno string `json:"certno"`
  16260. DiseCode string `json:"dise_code"`
  16261. FixmedinsCode string `json:"fixmedins_code"`
  16262. DedcHospLv string `json:"dedc_hosp_lv"`
  16263. OpterName string `json:"opter_name"`
  16264. Balc float64 `json:"balc"`
  16265. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  16266. PsnCertType string `json:"psn_cert_type"`
  16267. HifobPay float64 `json:"hifob_pay"`
  16268. MedfeeSumamt float64 `json:"medfee_sumamt"`
  16269. HifesPay float64 `json:"hifes_pay"`
  16270. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  16271. OptTime int64 `json:"opt_time"`
  16272. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  16273. SetlID string `json:"setl_id"`
  16274. MafPay float64 `json:"maf_pay"`
  16275. PsnName string `json:"psn_name"`
  16276. InsuOptins interface{} `json:"insu_optins"`
  16277. PrefFundPay interface{} `json:"pref_fund_pay"`
  16278. ClrOptins string `json:"clr_optins"`
  16279. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  16280. DiseName string `json:"dise_name"`
  16281. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  16282. Age float64 `json:"age"`
  16283. DtrtCertType string `json:"dtrt_cert_type"`
  16284. HospLv string `json:"hosp_lv"`
  16285. PsnCashPay float64 `json:"psn_cash_pay"`
  16286. } `json:"setlinfo"`
  16287. } `json:"output"`
  16288. RefmsgTime string `json:"refmsg_time"`
  16289. RespondTime string `json:"respond_time"`
  16290. Signtype interface{} `json:"signtype"`
  16291. WarnMsg interface{} `json:"warn_msg"`
  16292. }
  16293. type ResultEleven10265 struct {
  16294. Cainfo string `json:"cainfo"`
  16295. ErrMsg string `json:"err_msg"`
  16296. InfRefmsgid string `json:"inf_refmsgid"`
  16297. Infcode string `json:"infcode"`
  16298. Output struct {
  16299. Setlinfo struct {
  16300. SetlTime string `json:"setl_time"`
  16301. CvlservPay float64 `json:"cvlserv_pay"`
  16302. Year string `json:"year"`
  16303. MedType string `json:"med_type"`
  16304. PsnPay float64 `json:"psn_pay"`
  16305. OpterID string `json:"opter_id"`
  16306. Begndate string `json:"begndate"`
  16307. FlxempeFlag string `json:"flxempe_flag"`
  16308. HifmiPay float64 `json:"hifmi_pay"`
  16309. PsnNo string `json:"psn_no"`
  16310. ActPayDedc float64 `json:"act_pay_dedc"`
  16311. MedinsSetlID interface{} `json:"medins_setl_id"`
  16312. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  16313. ClrWay string `json:"clr_way"`
  16314. OthPay float64 `json:"oth_pay"`
  16315. Gend string `json:"gend"`
  16316. MdtrtID string `json:"mdtrt_id"`
  16317. AcctPay float64 `json:"acct_pay"`
  16318. InscpScpAmt float64 `json:"inscp_scp_amt"`
  16319. Insutype string `json:"insutype"`
  16320. Invono interface{} `json:"invono"`
  16321. Enddate string `json:"enddate"`
  16322. CashPayamt float64 `json:"cash_payamt"`
  16323. PsnType string `json:"psn_type"`
  16324. FixmedinsName string `json:"fixmedins_name"`
  16325. HifpPay float64 `json:"hifp_pay"`
  16326. NewFlag interface{} `json:"new_flag"`
  16327. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  16328. PreselfpayAmt float64 `json:"preselfpay_amt"`
  16329. PayLoc string `json:"pay_loc"`
  16330. ClrType string `json:"clr_type"`
  16331. RefdSetlFlag string `json:"refd_setl_flag"`
  16332. CvlservFlag string `json:"cvlserv_flag"`
  16333. EmpName string `json:"emp_name"`
  16334. Brdy string `json:"brdy"`
  16335. Naty string `json:"naty"`
  16336. Certno string `json:"certno"`
  16337. DiseCode string `json:"dise_code"`
  16338. FixmedinsCode string `json:"fixmedins_code"`
  16339. DedcHospLv string `json:"dedc_hosp_lv"`
  16340. OpterName string `json:"opter_name"`
  16341. Balc float64 `json:"balc"`
  16342. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  16343. PsnCertType string `json:"psn_cert_type"`
  16344. HifobPay float64 `json:"hifob_pay"`
  16345. MedfeeSumamt float64 `json:"medfee_sumamt"`
  16346. HifesPay float64 `json:"hifes_pay"`
  16347. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  16348. OptTime string `json:"opt_time"`
  16349. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  16350. SetlID string `json:"setl_id"`
  16351. MafPay float64 `json:"maf_pay"`
  16352. PsnName string `json:"psn_name"`
  16353. InsuOptins interface{} `json:"insu_optins"`
  16354. PrefFundPay interface{} `json:"pref_fund_pay"`
  16355. ClrOptins string `json:"clr_optins"`
  16356. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  16357. DiseName string `json:"dise_name"`
  16358. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  16359. Age float64 `json:"age"`
  16360. DtrtCertType string `json:"dtrt_cert_type"`
  16361. HospLv string `json:"hosp_lv"`
  16362. PsnCashPay float64 `json:"psn_cash_pay"`
  16363. } `json:"setlinfo"`
  16364. } `json:"output"`
  16365. RefmsgTime string `json:"refmsg_time"`
  16366. RespondTime string `json:"respond_time"`
  16367. Signtype interface{} `json:"signtype"`
  16368. WarnMsg interface{} `json:"warn_msg"`
  16369. }
  16370. type ResultTwelve struct {
  16371. Cainfo string `json:"cainfo"`
  16372. ErrMsg string `json:"err_msg"`
  16373. InfRefmsgid string `json:"inf_refmsgid"`
  16374. Infcode int64 `json:"infcode"`
  16375. Output struct {
  16376. MdtrtId string `json:"mdtrt_id"`
  16377. ChrgBchno string `json:"chrg_bchno"`
  16378. PsnNo string `json:"psn_no"`
  16379. } `json:"output"`
  16380. RefmsgTime string `json:"refmsg_time"`
  16381. RespondTime string `json:"respond_time"`
  16382. Signtype interface{} `json:"signtype"`
  16383. WarnMsg interface{} `json:"warn_msg"`
  16384. }
  16385. type ResultThirteen struct {
  16386. ErrMsg string `json:"err_msg"`
  16387. InfRefmsgid string `json:"inf_refmsgid"`
  16388. Infcode int64 `json:"infcode"`
  16389. Output struct {
  16390. Result struct {
  16391. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  16392. } `json:"result"`
  16393. } `json:"output"`
  16394. RefmsgTime string `json:"refmsg_time"`
  16395. RespondTime string `json:"respond_time"`
  16396. Signtype interface{} `json:"signtype"`
  16397. WarnInfo interface{} `json:"warn_info"`
  16398. }
  16399. type ResultThirteen10265 struct {
  16400. ErrMsg string `json:"err_msg"`
  16401. InfRefmsgid string `json:"inf_refmsgid"`
  16402. Infcode string `json:"infcode"`
  16403. Output struct {
  16404. Result struct {
  16405. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  16406. } `json:"result"`
  16407. } `json:"output"`
  16408. RefmsgTime string `json:"refmsg_time"`
  16409. RespondTime string `json:"respond_time"`
  16410. Signtype interface{} `json:"signtype"`
  16411. WarnInfo interface{} `json:"warn_info"`
  16412. }
  16413. type ResultFourteen struct {
  16414. ErrMsg string `json:"err_msg"`
  16415. InfRefmsgid string `json:"inf_refmsgid"`
  16416. Infcode int64 `json:"infcode"`
  16417. Output struct {
  16418. } `json:"output"`
  16419. RefmsgTime string `json:"refmsg_time"`
  16420. RespondTime string `json:"respond_time"`
  16421. Signtype interface{} `json:"signtype"`
  16422. WarnInfo interface{} `json:"warn_info"`
  16423. }
  16424. type ResultCFYLJG001 struct {
  16425. ErrMsg string `json:"err_msg"`
  16426. InfRefmsgid string `json:"inf_refmsgid"`
  16427. Infcode int64 `json:"infcode"`
  16428. Output struct {
  16429. RxTraceCode string `json:"rx_trace_code"`
  16430. HiRxno string `json:"hi_rxno"`
  16431. } `json:"output"`
  16432. RefmsgTime string `json:"refmsg_time"`
  16433. RespondTime string `json:"respond_time"`
  16434. Signtype interface{} `json:"signtype"`
  16435. WarnInfo interface{} `json:"warn_info"`
  16436. }
  16437. type ResultCFYLJG007 struct {
  16438. ErrMsg string `json:"err_msg"`
  16439. InfRefmsgid string `json:"inf_refmsgid"`
  16440. Infcode int64 `json:"infcode"`
  16441. Output struct {
  16442. HiRxno string `json:"hi_rxno"`
  16443. RxStasName string `json:"rx_stas_name"`
  16444. RxUsedStasCodg string `json:"rx_used_stas_codg"`
  16445. Seltdelts []interface{} `json:"seltdelts"`
  16446. RxUsedStasName string `json:"rx_used_stas_name"`
  16447. RxStasCodg string `json:"rx_stas_codg"`
  16448. } `json:"output"`
  16449. RefmsgTime string `json:"refmsg_time"`
  16450. RespondTime string `json:"respond_time"`
  16451. Signtype interface{} `json:"signtype"`
  16452. WarnInfo interface{} `json:"warn_info"`
  16453. }
  16454. type ResultCFYLJG002 struct {
  16455. ErrMsg string `json:"err_msg"`
  16456. InfRefmsgid string `json:"inf_refmsgid"`
  16457. Infcode int64 `json:"infcode"`
  16458. Output struct {
  16459. RxFile string `json:"rx_file"`
  16460. SignDigest string `json:"sign_digest"`
  16461. SignCertSn string `json:"sign_cert_sn"`
  16462. SignCertDn string `json:"sign_cert_dn"`
  16463. } `json:"output"`
  16464. RefmsgTime string `json:"refmsg_time"`
  16465. RespondTime string `json:"respond_time"`
  16466. Signtype interface{} `json:"signtype"`
  16467. WarnInfo interface{} `json:"warn_info"`
  16468. }
  16469. type ResultCFYLJG003 struct {
  16470. ErrMsg string `json:"err_msg"`
  16471. InfRefmsgid string `json:"inf_refmsgid"`
  16472. Infcode int64 `json:"infcode"`
  16473. Output struct {
  16474. HiRxno string `json:"hi_rxno"`
  16475. RxStasCodg string `json:"rx_stas_codg"`
  16476. RxStasName string `json:"rx_stas_name"`
  16477. } `json:"output"`
  16478. RefmsgTime string `json:"refmsg_time"`
  16479. RespondTime string `json:"respond_time"`
  16480. Signtype interface{} `json:"signtype"`
  16481. WarnInfo interface{} `json:"warn_info"`
  16482. }
  16483. type ResultCFYLJG004 struct {
  16484. ErrMsg string `json:"err_msg"`
  16485. InfRefmsgid string `json:"inf_refmsgid"`
  16486. Infcode int64 `json:"infcode"`
  16487. Output struct {
  16488. HiRxno string `json:"hi_rxno"`
  16489. RxStasCodg string `json:"rx_stas_codg"`
  16490. RxStasName string `json:"rx_stas_name"`
  16491. } `json:"output"`
  16492. RefmsgTime string `json:"refmsg_time"`
  16493. RespondTime string `json:"respond_time"`
  16494. Signtype interface{} `json:"signtype"`
  16495. WarnInfo interface{} `json:"warn_info"`
  16496. }
  16497. type ResultCFYLJG008 struct {
  16498. ErrMsg string `json:"err_msg"`
  16499. InfRefmsgid string `json:"inf_refmsgid"`
  16500. Infcode int64 `json:"infcode"`
  16501. Output struct {
  16502. PoolareaNo string `json:"poolareaNo"`
  16503. AdmdvsName string `json:"admdvsName"`
  16504. Count string `json:"count"`
  16505. } `json:"output"`
  16506. RefmsgTime string `json:"refmsg_time"`
  16507. RespondTime string `json:"respond_time"`
  16508. Signtype interface{} `json:"signtype"`
  16509. WarnInfo interface{} `json:"warn_info"`
  16510. }
  16511. type ResultCFYLJG005 struct {
  16512. ErrMsg string `json:"err_msg"`
  16513. InfRefmsgid string `json:"inf_refmsgid"`
  16514. Infcode int64 `json:"infcode"`
  16515. Output struct {
  16516. HiRxNo string `json:"hi_rxno"`
  16517. FixMedinsCode string `json:"fixmedins_code"`
  16518. FixMedinsName string `json:"fixmedins_name"`
  16519. RxStasCodg string `json:"rx_stas_codg"`
  16520. RxStasName string `json:"rx_stas_name"`
  16521. RxUserdStasCog string `json:"rx_userd_stas_cog"`
  16522. RxUserdStasName string `json:"rx_userd_stas_name"`
  16523. PrscTime string `json:"prsc_time"`
  16524. RxDrugCnt float64 `json:"rx_drug_cnt"`
  16525. RxUsedWayCodg string `json:"rx_used_way_codg"`
  16526. RxUsedWayName string `json:"rx_used_way_name"`
  16527. RxFrquCodg string `json:"rx_frqu_codg"`
  16528. RxFrquName string `json:"rx_frqu_name"`
  16529. RxDosunt string `json:"rx_dosunt"`
  16530. RxDoscnt float64 `json:"rx_doscnt"`
  16531. RxDrordDscr string `json:"rx_drord_dscr"`
  16532. ValiDays int64 `json:"vali_days"`
  16533. ValiEndTime string `json:"vali_end_time"`
  16534. ReptFlag string `json:"rept_flag"`
  16535. MaxReptCnt int64 `json:"max_rept_cnt"`
  16536. ReptdCnt int64 `json:"reptd_cnt"`
  16537. MinInrvDays int64 `json:"min_inrv_days"`
  16538. RxTypeCode string `json:"rx_type_code"`
  16539. RxTypeName string `json:"rx_type_name"`
  16540. LongRxFlag string `json:"long_rx_flag"`
  16541. RxDetlList []struct {
  16542. MedListCodg string `json:"med_list_codg"`
  16543. MedinsListCodg string `json:"medins_list_codg"`
  16544. HospPrepFlag string `json:"hosp_prep_flag"`
  16545. RxItemTypeCode string `json:"rx_item_type_code"`
  16546. RxItemTypeName string `json:"rx_item_type_name"`
  16547. TcmDrugTypeName string `json:"tcmdrug_type_name"`
  16548. TcmDrugTypeCode string `json:"tcmdrug_type_code"`
  16549. TcmHerbFoote string `json:"tcmherb_foote"`
  16550. MednTypeCode string `json:"medn_type_code"`
  16551. MednTypeName string `json:"medn_type_name"`
  16552. MainMedcFlag string `json:"main_medc_flag"`
  16553. UrgtFlag string `json:"urgt_flag"`
  16554. BasMednFlag string `json:"bas_medn_flag"`
  16555. ImpDrugFlag string `json:"imp_drug_flag"`
  16556. ProdBarc string `json:"prod_barc"`
  16557. DrugProdname string `json:"drug_prodname"`
  16558. GennameCodg string `json:"genname_codg"`
  16559. DrugGenname string `json:"drug_genname"`
  16560. DrugDosform string `json:"drug_dosform"`
  16561. DrugSpec string `json:"drug_spec"`
  16562. PrdrName string `json:"prdr_name"`
  16563. MedcWayCodg string `json:"medc_way_codg"`
  16564. MedcWayDscr string `json:"medc_way_dscr"`
  16565. MedcBegntime string `json:"medc_begntime"`
  16566. MedcEndtime string `json:"medc_endtime"`
  16567. MedcDays float64 `json:"medc_days"`
  16568. DrugPric float64 `json:"drug_pric"`
  16569. DrugSumamt float64 `json:"drug_sumamt"`
  16570. DrugCnt float64 `json:"drug_cnt"`
  16571. DrugDosunt string `json:"drug_dosunt"`
  16572. SinDoscnt float64 `json:"sin_doscnt"`
  16573. SinDosunt string `json:"sin_dosunt"`
  16574. UsedFrquCodg string `json:"used_frqu_codg"`
  16575. UsedFrquName string `json:"used_frqu_name"`
  16576. DrugTotlcnt string `json:"drug_totlcnt"`
  16577. DrugTotlcntEmp string `json:"drug_totlcnt_emp"`
  16578. DiseCodg string `json:"dise_codg"`
  16579. HospApprFlag string `json:"hosp_appr_flag"`
  16580. } `json:"rx_detl_list"`
  16581. RxOtpinfo struct {
  16582. MedType string `json:"med_type"`
  16583. IptOtpNo string `json:"ipt_otp_no"`
  16584. OtpIptFlag string `json:"otp_ipt_flag"`
  16585. PatnName string `json:"patn_name"`
  16586. PatnAge float64 `json:"patn_age"`
  16587. PatnHgt float64 `json:"patn_hgt"`
  16588. PatnWt float64 `json:"patn_wt"`
  16589. Gend string `json:"gend"`
  16590. GesoVal float64 `json:"geso_val"`
  16591. NwbFlag string `json:"nwb_flag"`
  16592. NwbAge string `json:"nwb_age"`
  16593. SuckPrdFlag string `json:"suck_prd_flag"`
  16594. AlgsHis string `json:"algs_his"`
  16595. Insutype string `json:"insutype"`
  16596. PrscDeptName string `json:"prsc_dept_name"`
  16597. PrscDrName string `json:"prsc_dr_name"`
  16598. PharName string `json:"phar_name"`
  16599. PharChkTime string `json:"phar_chk_time"`
  16600. MdtrtTime string `json:"mdtrt_time"`
  16601. DiseCodg string `json:"dise_codg"`
  16602. DiseName string `json:"dise_name"`
  16603. SpDiseFlag string `json:"sp_dise_flag"`
  16604. MaindiagCode string `json:"maindiag_code"`
  16605. MaindiagName string `json:"maindiag_name"`
  16606. DiseCondDscr string `json:"dise_cond_dscr"`
  16607. FstdiagFlag string `json:"fstdiag_flag"`
  16608. } `json:"rx_otpinfo"`
  16609. RxDiseList []struct {
  16610. DiagType string `json:"diag_type"`
  16611. MaindiagFlag string `json:"maindiag_flag"`
  16612. DiagSrtNo string `json:"diag_srt_no"`
  16613. DiagCode string `json:"diag_code"`
  16614. DiagName string `json:"diag_name"`
  16615. DiagDept string `json:"diag_dept"`
  16616. DiagDrNo string `json:"diag_dr_no"`
  16617. DiagDrName string `json:"diag_dr_name"`
  16618. DiagTime string `json:"diag_time"`
  16619. TcmDiseCode string `json:"tcm_dise_code"`
  16620. TcmDiseName string `json:"tcm_dise_name"`
  16621. TcmSympCode string `json:"tcmsymp_code"`
  16622. TcmSymp string `json:"tcmsymp"`
  16623. } `json:"rx_dise_list"`
  16624. } `json:"output"`
  16625. RefmsgTime string `json:"refmsg_time"`
  16626. RespondTime string `json:"respond_time"`
  16627. Signtype interface{} `json:"signtype"`
  16628. WarnInfo interface{} `json:"warn_info"`
  16629. }
  16630. type ResultCFYLJG006 struct {
  16631. ErrMsg string `json:"err_msg"`
  16632. InfRefmsgid string `json:"inf_refmsgid"`
  16633. Infcode int64 `json:"infcode"`
  16634. Output struct {
  16635. HiRxNo string `json:"hi_rxno"`
  16636. PharCode string `json:"phar_code"`
  16637. PharName string `json:"phar_name"`
  16638. RxChkOpnn string `json:"rx_chk_opnn"`
  16639. RxChkTime string `json:"rx_chk_time"`
  16640. RxChkStasCodg string `json:"rx_chk_stas_codg"`
  16641. RxChkStasName string `json:"rx_chk_stas_name"`
  16642. RxStasCodg string `json:"rx_stas_codg"`
  16643. RxStasName string `json:"rx_stas_name"`
  16644. } `json:"output"`
  16645. RefmsgTime string `json:"refmsg_time"`
  16646. RespondTime string `json:"respond_time"`
  16647. Signtype interface{} `json:"signtype"`
  16648. WarnInfo interface{} `json:"warn_info"`
  16649. }
  16650. type ResultFourteen10265 struct {
  16651. ErrMsg string `json:"err_msg"`
  16652. InfRefmsgid string `json:"inf_refmsgid"`
  16653. Infcode string `json:"infcode"`
  16654. Output struct {
  16655. } `json:"output"`
  16656. RefmsgTime string `json:"refmsg_time"`
  16657. RespondTime string `json:"respond_time"`
  16658. Signtype interface{} `json:"signtype"`
  16659. WarnInfo interface{} `json:"warn_info"`
  16660. }
  16661. type ResultSixteen struct {
  16662. Cainfo string `json:"cainfo"`
  16663. ErrMsg string `json:"err_msg"`
  16664. InfRefmsgid string `json:"inf_refmsgid"`
  16665. Infcode int64 `json:"infcode"`
  16666. Output struct {
  16667. Setlinfo struct {
  16668. MdtrtID string `json:"mdtrt_id"`
  16669. SetlID string `json:"setl_id"`
  16670. ClrOptins string `json:"clr_optins"`
  16671. SetlTime string `json:"setl_time"`
  16672. MedfeeSumamt float64 `json:"medfee_sumamt"`
  16673. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  16674. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  16675. PreselfpayAmt float64 `json:"preselfpay_amt"`
  16676. InscpScpAmt float64 `json:"inscp_scp_amt"`
  16677. ActPayDedc float64 `json:"act_pay_dedc"`
  16678. HifpPay float64 `json:"hifp_pay"`
  16679. PoolPropSe float64 `json:"pool_prop_selfpay"`
  16680. Lfpay float64 `json:"selfpay"`
  16681. CvlservPay float64 `json:"cvlserv_pay"`
  16682. HifesPay float64 `json:"hifes_pay"`
  16683. HifmiPay float64 `json:"hifmi_pay"`
  16684. HifobPay float64 `json:"hifob_pay"`
  16685. MafPay float64 `json:"maf_pay"`
  16686. OthPay float64 `json:"oth_pay"`
  16687. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  16688. PsnPartAmt float64 `json:"psn_part_amt"`
  16689. AcctPay float64 `json:"acct_pay"`
  16690. Balc float64 `json:"balc"`
  16691. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  16692. HospPartAmt float64 `json:"hosp_part_amt"`
  16693. MedinsSetlID string `json:"medins_setl_id"`
  16694. PdnCashPay string `json:"pdn_cash_pay"`
  16695. } `json:"setlinfo"`
  16696. } `json:"output"`
  16697. RefmsgTime string `json:"refmsg_time"`
  16698. RespondTime string `json:"respond_time"`
  16699. Signtype interface{} `json:"signtype"`
  16700. WarnMsg interface{} `json:"warn_msg"`
  16701. }
  16702. type ResultSixteen10265 struct {
  16703. Cainfo string `json:"cainfo"`
  16704. ErrMsg string `json:"err_msg"`
  16705. InfRefmsgid string `json:"inf_refmsgid"`
  16706. Infcode string `json:"infcode"`
  16707. Output struct {
  16708. Setlinfo struct {
  16709. MdtrtID string `json:"mdtrt_id"`
  16710. SetlID string `json:"setl_id"`
  16711. ClrOptins string `json:"clr_optins"`
  16712. SetlTime string `json:"setl_time"`
  16713. MedfeeSumamt float64 `json:"medfee_sumamt"`
  16714. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  16715. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  16716. PreselfpayAmt float64 `json:"preselfpay_amt"`
  16717. InscpScpAmt float64 `json:"inscp_scp_amt"`
  16718. ActPayDedc float64 `json:"act_pay_dedc"`
  16719. HifpPay float64 `json:"hifp_pay"`
  16720. PoolPropSe float64 `json:"pool_prop_selfpay"`
  16721. Lfpay float64 `json:"selfpay"`
  16722. CvlservPay float64 `json:"cvlserv_pay"`
  16723. HifesPay float64 `json:"hifes_pay"`
  16724. HifmiPay float64 `json:"hifmi_pay"`
  16725. HifobPay float64 `json:"hifob_pay"`
  16726. MafPay float64 `json:"maf_pay"`
  16727. OthPay float64 `json:"oth_pay"`
  16728. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  16729. PsnPartAmt float64 `json:"psn_part_amt"`
  16730. AcctPay float64 `json:"acct_pay"`
  16731. Balc float64 `json:"balc"`
  16732. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  16733. HospPartAmt float64 `json:"hosp_part_amt"`
  16734. MedinsSetlID string `json:"medins_setl_id"`
  16735. PdnCashPay string `json:"pdn_cash_pay"`
  16736. } `json:"setlinfo"`
  16737. } `json:"output"`
  16738. RefmsgTime string `json:"refmsg_time"`
  16739. RespondTime string `json:"respond_time"`
  16740. Signtype interface{} `json:"signtype"`
  16741. WarnMsg interface{} `json:"warn_msg"`
  16742. }
  16743. type ResultSixteen10265Two struct {
  16744. Cainfo string `json:"cainfo"`
  16745. ErrMsg string `json:"err_msg"`
  16746. InfRefmsgid string `json:"inf_refmsgid"`
  16747. Infcode string `json:"infcode"`
  16748. Output struct {
  16749. Setlinfo interface{} `json:"setlinfo"`
  16750. } `json:"output"`
  16751. RefmsgTime string `json:"refmsg_time"`
  16752. RespondTime string `json:"respond_time"`
  16753. Signtype interface{} `json:"signtype"`
  16754. WarnMsg interface{} `json:"warn_msg"`
  16755. }
  16756. type ResultgzSixteen10265Two struct {
  16757. Cainfo string `json:"cainfo"`
  16758. ErrMsg string `json:"err_msg"`
  16759. InfRefmsgid string `json:"inf_refmsgid"`
  16760. Infcode int64 `json:"infcode"`
  16761. Output struct {
  16762. Setlinfo interface{} `json:"setlinfo"`
  16763. } `json:"output"`
  16764. RefmsgTime string `json:"refmsg_time"`
  16765. RespondTime string `json:"respond_time"`
  16766. Signtype interface{} `json:"signtype"`
  16767. WarnMsg interface{} `json:"warn_msg"`
  16768. }
  16769. type ResultSeventeen struct {
  16770. ErrMsg string `json:"err_msg"`
  16771. InfRefmsgid string `json:"inf_refmsgid"`
  16772. Infcode int64 `json:"infcode"`
  16773. Output struct {
  16774. SetlListId string `json:"setl_list_id"`
  16775. } `json:"output"`
  16776. RefmsgTime string `json:"refmsg_time"`
  16777. RespondTime string `json:"respond_time"`
  16778. Signtype string `json:"signtype"`
  16779. WarnInfo string `json:"warn_info"`
  16780. }
  16781. type ResultSeventeenOther struct {
  16782. ErrMsg string `json:"err_msg"`
  16783. InfRefmsgid string `json:"inf_refmsgid"`
  16784. Infcode string `json:"infcode"`
  16785. Output struct {
  16786. SetlListId string `json:"setl_list_id"`
  16787. } `json:"output"`
  16788. RefmsgTime string `json:"refmsg_time"`
  16789. RespondTime string `json:"respond_time"`
  16790. Signtype string `json:"signtype"`
  16791. WarnInfo string `json:"warn_info"`
  16792. }
  16793. type Result90991 struct {
  16794. ErrMsg string `json:"err_msg"`
  16795. InfRefmsgid string `json:"inf_refmsgid"`
  16796. Infcode int64 `json:"infcode"`
  16797. Output struct {
  16798. Result struct {
  16799. PsnNo string `json:"psn_no"`
  16800. CardStat string `json:"card_stat"`
  16801. Certno string `json:"certno"`
  16802. PsnName string `json:"psn_name"`
  16803. CheckStat string `json:"check_stat"`
  16804. SscnoCheckStat string `json:"sscno_check_stat"`
  16805. } `json:"result"`
  16806. } `json:"output"`
  16807. RefmsgTime string `json:"refmsg_time"`
  16808. RespondTime string `json:"respond_time"`
  16809. Signtype interface{} `json:"signtype"`
  16810. WarnInfo interface{} `json:"warn_info"`
  16811. }
  16812. type Result90100 struct {
  16813. ErrMsg string `json:"err_msg"`
  16814. InfRefmsgid string `json:"inf_refmsgid"`
  16815. Infcode int64 `json:"infcode"`
  16816. Output struct {
  16817. PoolareaNo string `json:"poolarea_no"`
  16818. PoolareaNoName string `json:"poolarea_no_name"`
  16819. Insutype string `json:"insutype"`
  16820. InsutypeName string `json:"insutype_name"`
  16821. ClctType string `json:"clct_type"`
  16822. ClctTypeName string `json:"clct_type_name"`
  16823. ClctFlag string `json:"clct_flag"`
  16824. ClctFlagName string `json:"clct_flag_name"`
  16825. AccrymBegn string `json:"accrym_begn"`
  16826. AccrymEnd string `json:"accrym_end"`
  16827. ClctTime string `json:"clct_time"`
  16828. ClctstdCrtfRuleCodg string `json:"clctstd_crtf_rule_codg"`
  16829. } `json:"output"`
  16830. RefmsgTime string `json:"refmsg_time"`
  16831. RespondTime string `json:"respond_time"`
  16832. Signtype interface{} `json:"signtype"`
  16833. WarnInfo interface{} `json:"warn_info"`
  16834. }
  16835. type Custom struct {
  16836. DetItemFeeSumamt string
  16837. Cut string
  16838. FeedetlSn string
  16839. Price string
  16840. MedListCodg string
  16841. Type int64
  16842. AdviceId int64
  16843. ProjectId int64
  16844. ItemId int64
  16845. }
  16846. type Result5301 struct {
  16847. ErrMsg string `json:"err_msg"`
  16848. InfRefmsgid string `json:"inf_refmsgid"`
  16849. Infcode int64 `json:"infcode"`
  16850. Output struct {
  16851. Result []struct {
  16852. OpspDiseCode string `json:"opsp_dise_code"`
  16853. OpspDiseName string `json:"opsp_dise_name"`
  16854. Begndate string `json:"begndate"`
  16855. Enddate string `json:"enddate"`
  16856. } `json:"feedetail"`
  16857. } `json:"output"`
  16858. RefmsgTime string `json:"refmsg_time"`
  16859. RespondTime string `json:"respond_time"`
  16860. Signtype interface{} `json:"signtype"`
  16861. WarnInfo interface{} `json:"warn_info"`
  16862. }
  16863. type Result5301For10265 struct {
  16864. ErrMsg string `json:"err_msg"`
  16865. InfRefmsgid string `json:"inf_refmsgid"`
  16866. Infcode string `json:"infcode"`
  16867. Output struct {
  16868. Result []struct {
  16869. OpspDiseCode string `json:"opsp_dise_code"`
  16870. OpspDiseName string `json:"opsp_dise_name"`
  16871. Begndate string `json:"begndate"`
  16872. Enddate string `json:"enddate"`
  16873. } `json:"feedetail"`
  16874. } `json:"output"`
  16875. RefmsgTime string `json:"refmsg_time"`
  16876. RespondTime string `json:"respond_time"`
  16877. Signtype interface{} `json:"signtype"`
  16878. WarnInfo interface{} `json:"warn_info"`
  16879. }
  16880. //获取个人信息----挂号-----上传就诊信息
  16881. func (c *HisApiController) GetRegisterInfo() {
  16882. id, _ := c.GetInt64("id")
  16883. record_time := c.GetString("record_time")
  16884. settlementValue, _ := c.GetInt64("settlement_value")
  16885. medical_insurance_card := c.GetString("medical_insurance_card")
  16886. name := c.GetString("name")
  16887. id_card_type, _ := c.GetInt64("id_card_type")
  16888. certificates, _ := c.GetInt64("certificates")
  16889. medical_care, _ := c.GetInt64("medical_care")
  16890. birthday := c.GetString("birthday")
  16891. id_card := c.GetString("id_card")
  16892. register_type, _ := c.GetInt64("register")
  16893. doctor, _ := c.GetInt64("doctor")
  16894. department, _ := c.GetInt64("department")
  16895. gender, _ := c.GetInt64("sex")
  16896. registration_fee, _ := c.GetFloat("registration_fee")
  16897. medical_expenses, _ := c.GetFloat("medical_expenses")
  16898. social_type, _ := c.GetInt64("social_type")
  16899. admin_user_id, _ := c.GetInt64("admin_user_id")
  16900. insuplc_admdvs := c.GetString("insuplc_admdvs")
  16901. mdtrt_type := c.GetString("mdtrt_type")
  16902. if id_card_type == 5 {
  16903. id_card_type = 4
  16904. }
  16905. timeLayout := "2006-01-02"
  16906. loc, _ := time.LoadLocation("Local")
  16907. birthdays, _ := time.ParseInLocation(timeLayout+" 15:04:05", birthday+" 00:00:00", loc)
  16908. birthUnix := birthdays.Unix()
  16909. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  16910. if err != nil {
  16911. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  16912. return
  16913. }
  16914. recordDateTime := theTime.Unix()
  16915. adminInfo := c.GetAdminUserInfo()
  16916. var patient service.Patients
  16917. if id == 0 {
  16918. patient, _ = service.GetPatientByIDCard(id_card, adminInfo.CurrentOrgId)
  16919. } else {
  16920. patient, _ = service.GetPatientByIDTwo(adminInfo.CurrentOrgId, id)
  16921. }
  16922. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  16923. if patientPrescription.ID == 0 {
  16924. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  16925. }
  16926. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  16927. if patient.ID == 0 {
  16928. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  16929. return
  16930. }
  16931. if len(patient.IdCardNo) == 0 {
  16932. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  16933. return
  16934. }
  16935. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  16936. roles, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, admin_user_id)
  16937. doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, doctor)
  16938. //就诊结算未完成,不能进行二次挂号
  16939. //his, _ := service.GetHisPatientInfoTwo(adminInfo.CurrentOrgId, patient.ID, recordDateTime)
  16940. //if len(his) >= 1 {
  16941. // order, _ := service.GetNewHisOrderTwo(adminInfo.CurrentOrgId, his[len(his)-1].Number, his[len(his)-1].PatientId, recordDateTime)
  16942. // if len(his) >= 1 && order.ID == 0 {
  16943. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisPatientParamWrong)
  16944. // return
  16945. // }
  16946. //}
  16947. //var register_log string
  16948. if config.IsOpen == 1 {
  16949. var res ResultTwo
  16950. var res10265 ResultTwo10265
  16951. var PsnNo string
  16952. var PsnCertType string
  16953. var Certno string
  16954. var PsnName string
  16955. var Gend string
  16956. var Naty string
  16957. var Brdy string
  16958. var Age float64
  16959. var infoStr string
  16960. var idetinfoStr string
  16961. var infocode int64
  16962. var verify_number string
  16963. fmt.Println(verify_number)
  16964. if miConfig.MdtrtareaAdmvs == "421300" || miConfig.MdtrtareaAdmvs == "420200" || miConfig.MdtrtareaAdmvs == "421182" || miConfig.MdtrtareaAdmvs == "420902" {
  16965. psn_info, _ := service.GetPsnByPatientId(id)
  16966. PsnNo = psn_info.PsnNo
  16967. PsnCertType = psn_info.PsnCertType
  16968. Certno = psn_info.Certno
  16969. PsnName = psn_info.PsnName
  16970. Gend = psn_info.Gend
  16971. Naty = psn_info.Naty
  16972. Brdy = psn_info.Brdy
  16973. Age = psn_info.Age
  16974. infoStr = psn_info.Insuinfo
  16975. idetinfoStr = psn_info.Idetinfo
  16976. infocode = 0
  16977. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  16978. psn_info, _ := service.GetPsnByPatientId(id)
  16979. PsnNo = psn_info.PsnNo
  16980. PsnCertType = psn_info.PsnCertType
  16981. Certno = psn_info.Certno
  16982. PsnName = psn_info.PsnName
  16983. Gend = psn_info.Gend
  16984. Naty = psn_info.Naty
  16985. Brdy = psn_info.Brdy
  16986. Age = psn_info.Age
  16987. infoStr = psn_info.Insuinfo
  16988. idetinfoStr = psn_info.Idetinfo
  16989. infocode = 0
  16990. verify_number = psn_info.VerifyNumber
  16991. } else if miConfig.MdtrtareaAdmvs == "150499" {
  16992. if id_card_type == 2 {
  16993. //请求内网数据
  16994. api := "http://172.16.13.254:9532/" + "nmyb/1101?cert_no=" + patient.IdCardNo +
  16995. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  16996. "&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
  16997. resp, requestErr := http.Get(api)
  16998. if requestErr != nil {
  16999. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17000. return
  17001. }
  17002. body, ioErr := ioutil.ReadAll(resp.Body)
  17003. if ioErr != nil {
  17004. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  17005. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17006. return
  17007. }
  17008. var respJSON map[string]interface{}
  17009. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  17010. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  17011. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17012. return
  17013. }
  17014. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  17015. result_byte, _ := json.Marshal(respJSON)
  17016. result := string(result_byte)
  17017. var dat map[string]interface{}
  17018. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  17019. fmt.Println(dat)
  17020. } else {
  17021. fmt.Println(err)
  17022. }
  17023. userJSONBytes, _ := json.Marshal(dat)
  17024. var res ResultTwo
  17025. var resTwo10265 ResultTwo10265
  17026. if miConfig.Code == "H15049901371" {
  17027. if err := json.Unmarshal(userJSONBytes, &resTwo10265); err != nil {
  17028. utils.ErrorLog("解析失败:%v", err)
  17029. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17030. return
  17031. }
  17032. Infcode, _ := strconv.ParseInt(resTwo10265.Infcode, 10, 64)
  17033. res.Infcode = Infcode
  17034. res.ErrMsg = resTwo10265.ErrMsg
  17035. res.Output = resTwo10265.Output
  17036. res.InfRefmsgid = resTwo10265.InfRefmsgid
  17037. res.RespondTime = resTwo10265.RespondTime
  17038. res.WarnInfo = resTwo10265.WarnInfo
  17039. } else {
  17040. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  17041. utils.ErrorLog("解析失败:%v", err)
  17042. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17043. return
  17044. }
  17045. }
  17046. //var insutypes []string
  17047. //var insutype string
  17048. //var is390 int = 0
  17049. //var is310 int = 0
  17050. //for _, item := range res.Output.Iinfo {
  17051. // if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  17052. // insutypes = append(insutypes, item.Insutype)
  17053. // }
  17054. //}
  17055. //if len(insutypes) == 1 {
  17056. // insutype = insutypes[0]
  17057. //} else {
  17058. // for _, i := range insutypes {
  17059. // if i == "390" {
  17060. // is390 = 1
  17061. // }
  17062. //
  17063. // if i == "310" {
  17064. // is310 = 1
  17065. // }
  17066. // }
  17067. //}
  17068. //if is390 == 1 {
  17069. // insutype = "390"
  17070. //}
  17071. //if is310 == 1 {
  17072. // insutype = "310"
  17073. //}
  17074. //if len(insutypes) == 0 {
  17075. // insutype = "310"
  17076. //}
  17077. PsnNo = res.Output.Baseinfo.PsnNo
  17078. PsnCertType = res.Output.Baseinfo.PsnCertType
  17079. Certno = res.Output.Baseinfo.Certno
  17080. PsnName = res.Output.Baseinfo.PsnName
  17081. Gend = res.Output.Baseinfo.Gend
  17082. Naty = res.Output.Baseinfo.Naty
  17083. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  17084. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  17085. infoStr = string(Iinfos)
  17086. idetinfoStr = string(Idetinfos)
  17087. infocode = res.Infcode
  17088. //infocode = 0
  17089. //verify_number = psn_info.VerifyNumber
  17090. } else {
  17091. psn_info, _ := service.GetPsnByPatientId(id)
  17092. PsnNo = psn_info.PsnNo
  17093. PsnCertType = psn_info.PsnCertType
  17094. Certno = psn_info.Certno
  17095. PsnName = psn_info.PsnName
  17096. Gend = psn_info.Gend
  17097. Naty = psn_info.Naty
  17098. Brdy = psn_info.Brdy
  17099. Age = psn_info.Age
  17100. infoStr = psn_info.Insuinfo
  17101. idetinfoStr = psn_info.Idetinfo
  17102. infocode = 0
  17103. verify_number = psn_info.VerifyNumber
  17104. }
  17105. } else if miConfig.MdtrtareaAdmvs == "350500" {
  17106. if id_card_type == 1 {
  17107. psn_info, _ := service.GetPsnByPatientId(id)
  17108. PsnNo = psn_info.PsnNo
  17109. PsnCertType = psn_info.PsnCertType
  17110. Certno = psn_info.Certno
  17111. PsnName = psn_info.PsnName
  17112. Gend = psn_info.Gend
  17113. Naty = psn_info.Naty
  17114. Brdy = psn_info.Brdy
  17115. Age = psn_info.Age
  17116. infoStr = psn_info.Insuinfo
  17117. idetinfoStr = psn_info.Idetinfo
  17118. infocode = 0
  17119. verify_number = psn_info.VerifyNumber
  17120. } else if id_card_type == 2 {
  17121. 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)
  17122. fmt.Println(errMsgLog)
  17123. saveLog(result, requestLog, "1101", "人员基本信息获取")
  17124. if err := json.Unmarshal([]byte(result), &res); err != nil {
  17125. utils.ErrorLog("解析失败:%v", err)
  17126. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17127. return
  17128. }
  17129. PsnNo = res.Output.Baseinfo.PsnNo
  17130. PsnCertType = res.Output.Baseinfo.PsnCertType
  17131. Certno = res.Output.Baseinfo.Certno
  17132. PsnName = res.Output.Baseinfo.PsnName
  17133. Gend = res.Output.Baseinfo.Gend
  17134. Naty = res.Output.Baseinfo.Naty
  17135. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  17136. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  17137. infoStr = string(Iinfos)
  17138. idetinfoStr = string(Idetinfos)
  17139. infocode = res.Infcode
  17140. }
  17141. } else if miConfig.MdtrtareaAdmvs == "360302" {
  17142. if id_card_type == 1 {
  17143. psn_info, _ := service.GetPsnByPatientId(id)
  17144. PsnNo = psn_info.PsnNo
  17145. PsnCertType = psn_info.PsnCertType
  17146. Certno = psn_info.Certno
  17147. PsnName = psn_info.PsnName
  17148. Gend = psn_info.Gend
  17149. Naty = psn_info.Naty
  17150. Brdy = psn_info.Brdy
  17151. Age = psn_info.Age
  17152. infoStr = psn_info.Insuinfo
  17153. idetinfoStr = psn_info.Idetinfo
  17154. infocode = 0
  17155. verify_number = psn_info.VerifyNumber
  17156. } else if id_card_type == 2 {
  17157. 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, "")
  17158. saveLog(result, requestLog, "1101", "人员基本信息获取")
  17159. if err := json.Unmarshal([]byte(result), &res); err != nil {
  17160. utils.ErrorLog("解析失败:%v", err)
  17161. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17162. return
  17163. }
  17164. PsnNo = res.Output.Baseinfo.PsnNo
  17165. PsnCertType = res.Output.Baseinfo.PsnCertType
  17166. Certno = res.Output.Baseinfo.Certno
  17167. PsnName = res.Output.Baseinfo.PsnName
  17168. Gend = res.Output.Baseinfo.Gend
  17169. Naty = res.Output.Baseinfo.Naty
  17170. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  17171. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  17172. infoStr = string(Iinfos)
  17173. idetinfoStr = string(Idetinfos)
  17174. infocode = res.Infcode
  17175. } else {
  17176. psn_info, _ := service.GetPsnByPatientId(id)
  17177. PsnNo = psn_info.PsnNo
  17178. PsnCertType = psn_info.PsnCertType
  17179. Certno = psn_info.Certno
  17180. PsnName = psn_info.PsnName
  17181. Gend = psn_info.Gend
  17182. Naty = psn_info.Naty
  17183. Brdy = psn_info.Brdy
  17184. Age = psn_info.Age
  17185. infoStr = psn_info.Insuinfo
  17186. idetinfoStr = psn_info.Idetinfo
  17187. infocode = 0
  17188. verify_number = psn_info.VerifyNumber
  17189. }
  17190. } else if miConfig.MdtrtareaAdmvs == "341203" {
  17191. psn_info, _ := service.GetPsnByPatientId(id)
  17192. PsnNo = psn_info.PsnNo
  17193. PsnCertType = psn_info.PsnCertType
  17194. Certno = psn_info.Certno
  17195. PsnName = psn_info.PsnName
  17196. Gend = psn_info.Gend
  17197. Naty = psn_info.Naty
  17198. Brdy = psn_info.Brdy
  17199. Age = psn_info.Age
  17200. infoStr = psn_info.Insuinfo
  17201. idetinfoStr = psn_info.Idetinfo
  17202. infocode = 0
  17203. verify_number = psn_info.VerifyNumber
  17204. } else if miConfig.MdtrtareaAdmvs == "430800" {
  17205. if id_card_type == 1 {
  17206. psn_info, _ := service.GetPsnByPatientId(id)
  17207. PsnNo = psn_info.PsnNo
  17208. PsnCertType = psn_info.PsnCertType
  17209. Certno = psn_info.Certno
  17210. PsnName = psn_info.PsnName
  17211. Gend = psn_info.Gend
  17212. Naty = psn_info.Naty
  17213. Brdy = psn_info.Brdy
  17214. Age = psn_info.Age
  17215. infoStr = psn_info.Insuinfo
  17216. idetinfoStr = psn_info.Idetinfo
  17217. infocode = 0
  17218. verify_number = psn_info.VerifyNumber
  17219. } else if id_card_type == 2 {
  17220. 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)
  17221. saveLog(result, requestLog, "1101", "人员基本信息获取")
  17222. if err := json.Unmarshal([]byte(result), &res); err != nil {
  17223. utils.ErrorLog("解析失败:%v", err)
  17224. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17225. return
  17226. }
  17227. PsnNo = res.Output.Baseinfo.PsnNo
  17228. PsnCertType = res.Output.Baseinfo.PsnCertType
  17229. Certno = res.Output.Baseinfo.Certno
  17230. PsnName = res.Output.Baseinfo.PsnName
  17231. Gend = res.Output.Baseinfo.Gend
  17232. Naty = res.Output.Baseinfo.Naty
  17233. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  17234. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  17235. infoStr = string(Iinfos)
  17236. idetinfoStr = string(Idetinfos)
  17237. infocode = res.Infcode
  17238. } else if id_card_type == 4 {
  17239. psn_info, _ := service.GetPsnByPatientId(id)
  17240. PsnNo = psn_info.PsnNo
  17241. PsnCertType = psn_info.PsnCertType
  17242. Certno = psn_info.Certno
  17243. PsnName = psn_info.PsnName
  17244. Gend = psn_info.Gend
  17245. Naty = psn_info.Naty
  17246. Brdy = psn_info.Brdy
  17247. Age = psn_info.Age
  17248. infoStr = psn_info.Insuinfo
  17249. idetinfoStr = psn_info.Idetinfo
  17250. infocode = 0
  17251. verify_number = psn_info.VerifyNumber
  17252. }
  17253. } else if miConfig.MdtrtareaAdmvs == "131023" {
  17254. var result string
  17255. var requestLog string
  17256. 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), "")
  17257. if id_card_type == 4 {
  17258. psn_info, _ := service.GetPsnByPatientId(id)
  17259. PsnNo = psn_info.PsnNo
  17260. PsnCertType = psn_info.PsnCertType
  17261. Certno = psn_info.Certno
  17262. PsnName = psn_info.PsnName
  17263. Gend = psn_info.Gend
  17264. Naty = psn_info.Naty
  17265. Brdy = psn_info.Brdy
  17266. Age = psn_info.Age
  17267. infoStr = psn_info.Insuinfo
  17268. idetinfoStr = psn_info.Idetinfo
  17269. infocode = 0
  17270. verify_number = psn_info.VerifyNumber
  17271. } else {
  17272. saveLog(result, requestLog, "1101", "人员基本信息获取")
  17273. if miConfig.Code == "H15049901371" {
  17274. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  17275. utils.ErrorLog("解析失败:%v", err)
  17276. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17277. return
  17278. }
  17279. res.ErrMsg = res10265.ErrMsg
  17280. res.Output = res10265.Output
  17281. res.InfRefmsgid = res10265.InfRefmsgid
  17282. } else {
  17283. if err := json.Unmarshal([]byte(result), &res); err != nil {
  17284. utils.ErrorLog("解析失败:%v", err)
  17285. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17286. return
  17287. }
  17288. }
  17289. PsnNo = res.Output.Baseinfo.PsnNo
  17290. PsnCertType = res.Output.Baseinfo.PsnCertType
  17291. Certno = res.Output.Baseinfo.Certno
  17292. PsnName = res.Output.Baseinfo.PsnName
  17293. Gend = res.Output.Baseinfo.Gend
  17294. Naty = res.Output.Baseinfo.Naty
  17295. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  17296. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  17297. infoStr = string(Iinfos)
  17298. idetinfoStr = string(Idetinfos)
  17299. if miConfig.Code == "H15049901371" {
  17300. infocode, _ = strconv.ParseInt(res10265.Infcode, 10, 64)
  17301. } else {
  17302. infocode = res.Infcode
  17303. }
  17304. }
  17305. } else if miConfig.MdtrtareaAdmvs == "441799" {
  17306. psn_info, _ := service.GetPsnByPatientId(id)
  17307. PsnNo = psn_info.PsnNo
  17308. PsnCertType = psn_info.PsnCertType
  17309. Certno = psn_info.Certno
  17310. PsnName = psn_info.PsnName
  17311. Gend = psn_info.Gend
  17312. Naty = psn_info.Naty
  17313. Brdy = psn_info.Brdy
  17314. Age = psn_info.Age
  17315. infoStr = psn_info.Insuinfo
  17316. idetinfoStr = psn_info.Idetinfo
  17317. infocode = 0
  17318. verify_number = psn_info.VerifyNumber
  17319. } else if miConfig.MdtrtareaAdmvs == "450721" {
  17320. psn_info, _ := service.GetPsnByPatientId(id)
  17321. PsnNo = psn_info.PsnNo
  17322. PsnCertType = psn_info.PsnCertType
  17323. Certno = psn_info.Certno
  17324. PsnName = psn_info.PsnName
  17325. Gend = psn_info.Gend
  17326. Naty = psn_info.Naty
  17327. Brdy = psn_info.Brdy
  17328. Age = psn_info.Age
  17329. infoStr = psn_info.Insuinfo
  17330. idetinfoStr = psn_info.Idetinfo
  17331. infocode = 0
  17332. verify_number = psn_info.VerifyNumber
  17333. } else {
  17334. var result string
  17335. var requestLog string
  17336. //if miConfig.UserOrgId == 10138 {
  17337. if id_card_type != 4 || id_card_type != 1 {
  17338. var insa string
  17339. if len(patient.InsuplcAdmdvs) > 0 {
  17340. insa = patient.InsuplcAdmdvs
  17341. } else {
  17342. insa = miConfig.InsuplcAdmdvs
  17343. }
  17344. //psn_info, _ := service.GetPsnByPatientId(id)
  17345. //result, requestLog = service.Gdyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_info.VerifyNumber)
  17346. 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)
  17347. }
  17348. //}
  17349. //else {
  17350. // var insa string
  17351. // if len(patient.InsuplcAdmdvs) > 0 {
  17352. // insa = patient.InsuplcAdmdvs
  17353. // } else {
  17354. // insa = miConfig.InsuplcAdmdvs
  17355. // }
  17356. // 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)
  17357. //}
  17358. if id_card_type == 4 || id_card_type == 1 {
  17359. psn_info, _ := service.GetPsnByPatientId(id)
  17360. PsnNo = psn_info.PsnNo
  17361. PsnCertType = psn_info.PsnCertType
  17362. Certno = psn_info.Certno
  17363. PsnName = psn_info.PsnName
  17364. Gend = psn_info.Gend
  17365. Naty = psn_info.Naty
  17366. Brdy = psn_info.Brdy
  17367. Age = psn_info.Age
  17368. infoStr = psn_info.Insuinfo
  17369. idetinfoStr = psn_info.Idetinfo
  17370. infocode = 0
  17371. verify_number = psn_info.VerifyNumber
  17372. } else {
  17373. saveLog(result, requestLog, "1101", "人员基本信息获取")
  17374. if miConfig.Code == "H15049901371" {
  17375. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  17376. utils.ErrorLog("解析失败:%v", err)
  17377. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17378. return
  17379. }
  17380. res.ErrMsg = res10265.ErrMsg
  17381. res.Output = res10265.Output
  17382. res.InfRefmsgid = res10265.InfRefmsgid
  17383. } else {
  17384. if err := json.Unmarshal([]byte(result), &res); err != nil {
  17385. utils.ErrorLog("解析失败:%v", err)
  17386. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17387. return
  17388. }
  17389. }
  17390. PsnNo = res.Output.Baseinfo.PsnNo
  17391. PsnCertType = res.Output.Baseinfo.PsnCertType
  17392. Certno = res.Output.Baseinfo.Certno
  17393. PsnName = res.Output.Baseinfo.PsnName
  17394. Gend = res.Output.Baseinfo.Gend
  17395. Naty = res.Output.Baseinfo.Naty
  17396. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  17397. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  17398. infoStr = string(Iinfos)
  17399. idetinfoStr = string(Idetinfos)
  17400. if miConfig.Code == "H15049901371" {
  17401. infocode, _ = strconv.ParseInt(res10265.Infcode, 10, 64)
  17402. } else {
  17403. infocode = res.Infcode
  17404. }
  17405. }
  17406. }
  17407. if infocode == 0 {
  17408. his := models.VMHisPatient{
  17409. Name: name,
  17410. Gender: gender,
  17411. Birthday: birthUnix,
  17412. MedicalTreatmentType: medical_care,
  17413. IdType: certificates,
  17414. IdCardNo: id_card,
  17415. BalanceAccountsType: settlementValue,
  17416. SocialType: social_type,
  17417. MedicalInsuranceNumber: medical_insurance_card,
  17418. RegisterType: register_type,
  17419. RegisterCost: registration_fee,
  17420. TreatmentCost: medical_expenses,
  17421. Status: 1,
  17422. Ctime: time.Now().Unix(),
  17423. Mtime: time.Now().Unix(),
  17424. PsnNo: PsnNo,
  17425. PsnCertType: PsnCertType,
  17426. Certno: Certno,
  17427. PsnName: PsnName,
  17428. Gend: Gend,
  17429. Naty: Naty,
  17430. Brdy: Brdy,
  17431. Age: Age,
  17432. Iinfo: infoStr,
  17433. Idetinfo: idetinfoStr,
  17434. PatientId: patient.ID,
  17435. RecordDate: theTime.Unix(),
  17436. UserOrgId: adminInfo.CurrentOrgId,
  17437. AdminUserId: admin_user_id,
  17438. IsReturn: 1,
  17439. IdCardType: id_card_type,
  17440. Doctor: doctor,
  17441. Departments: department,
  17442. MdtrtGrpType: mdtrt_type,
  17443. }
  17444. timestamp := time.Now().Unix()
  17445. tempTime := time.Unix(timestamp, 0)
  17446. timeFormat := tempTime.Format("20060102150405")
  17447. chrgBchno := rand.Intn(100000) + 10000
  17448. ipt_otp_no := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  17449. his.Number = ipt_otp_no
  17450. //count, _ := service.FindHisRegisterRecord(theTime.Unix(), patient.ID, adminInfo.CurrentOrgId)
  17451. department, _ := service.GetDepartMentDetail(department)
  17452. //doctor_id := strconv.FormatInt(patientPrescription., 10)
  17453. IdCardNo := ""
  17454. if id_card_type == 1 {
  17455. // IdCardNo = medical_insurance_card
  17456. IdCardNo = patient.IdCardNo
  17457. } else {
  17458. IdCardNo = patient.IdCardNo
  17459. }
  17460. var rf []*ResultFive
  17461. json.Unmarshal([]byte(his.Iinfo), &rf)
  17462. var insutypes []*ResultFive
  17463. var insutype string
  17464. var insuplc_admdvs_temp string
  17465. var is390 int = 0
  17466. var is310 int = 0
  17467. for _, item := range rf {
  17468. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  17469. insutypes = append(insutypes, item)
  17470. }
  17471. }
  17472. if len(insutypes) == 1 {
  17473. insutype = insutypes[0].Insutype
  17474. insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  17475. if insutype == "390" {
  17476. is390 = 1
  17477. }
  17478. if insutype == "310" {
  17479. is310 = 1
  17480. }
  17481. } else {
  17482. for _, i := range insutypes {
  17483. if i.Insutype == "390" {
  17484. is390 = 1
  17485. }
  17486. if i.Insutype == "310" {
  17487. is310 = 1
  17488. }
  17489. }
  17490. }
  17491. if is390 == 1 {
  17492. insutype = "390"
  17493. }
  17494. if is310 == 1 {
  17495. insutype = "310"
  17496. }
  17497. fmt.Println(social_type)
  17498. if social_type > 0 {
  17499. insutype = strconv.FormatInt(social_type, 10)
  17500. }
  17501. var infocode int64
  17502. var resThree ResultThree
  17503. var resThree10265 ResultThree10265
  17504. if len(insuplc_admdvs) == 0 {
  17505. psn_info, _ := service.GetPsnByPatientId(id)
  17506. //if len(psn_info.InsuplcAdmdvs) > 0 {
  17507. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  17508. //}
  17509. } else {
  17510. insuplc_admdvs_temp = insuplc_admdvs
  17511. }
  17512. if miConfig.MdtrtareaAdmvs == "421300" {
  17513. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  17514. psn_info, _ := service.GetPsnByPatientId(id)
  17515. api := "http://192.168.124.4:9532/" + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  17516. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  17517. "&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
  17518. resp, requestErr := http.Get(api)
  17519. if requestErr != nil {
  17520. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17521. return
  17522. }
  17523. body, ioErr := ioutil.ReadAll(resp.Body)
  17524. if ioErr != nil {
  17525. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  17526. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17527. return
  17528. }
  17529. var respJSON map[string]interface{}
  17530. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  17531. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  17532. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17533. return
  17534. }
  17535. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  17536. result, _ := json.Marshal(respJSON)
  17537. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  17538. utils.ErrorLog("解析失败:%v", err)
  17539. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17540. return
  17541. }
  17542. infocode = resThree.Infcode
  17543. } else if miConfig.MdtrtareaAdmvs == "420200" {
  17544. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  17545. //if strings.Contains(insuplc_admdvs_temp, "4202") {
  17546. // insuplc_admdvs_temp =
  17547. //}
  17548. //if strings.Contains(insuplc_admdvs_temp, "4413") {
  17549. // insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  17550. //}
  17551. api := "http://192.168.0.197:9532/" + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  17552. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  17553. "&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
  17554. resp, requestErr := http.Get(api)
  17555. if requestErr != nil {
  17556. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17557. return
  17558. }
  17559. body, ioErr := ioutil.ReadAll(resp.Body)
  17560. if ioErr != nil {
  17561. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  17562. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17563. return
  17564. }
  17565. var respJSON map[string]interface{}
  17566. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  17567. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  17568. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17569. return
  17570. }
  17571. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  17572. result, _ := json.Marshal(respJSON)
  17573. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  17574. utils.ErrorLog("解析失败:%v", err)
  17575. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17576. return
  17577. }
  17578. infocode = resThree.Infcode
  17579. } else if miConfig.MdtrtareaAdmvs == "420902" {
  17580. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  17581. //if strings.Contains(insuplc_admdvs_temp, "4202") {
  17582. // insuplc_admdvs_temp =
  17583. //}
  17584. //if strings.Contains(insuplc_admdvs_temp, "4413") {
  17585. // insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  17586. //}
  17587. utils.ErrorLog("解析失败:%v", insutype)
  17588. utils.ErrorLog("解析失败:%v", PsnNo)
  17589. utils.ErrorLog("解析失败:%v", Certno)
  17590. utils.ErrorLog("解析失败:%v", ipt_otp_no)
  17591. utils.ErrorLog("解析失败:%v", hb_doctor_info.UserName)
  17592. utils.ErrorLog("解析失败:%v", insuplc_admdvs_temp)
  17593. utils.ErrorLog("解析失败:%v", hb_doctor_info.DoctorNumber)
  17594. utils.ErrorLog("解析失败:%v", PsnNo)
  17595. utils.ErrorLog("解析失败:%v", department.Number )
  17596. utils.ErrorLog("解析失败:%v", department.Name )
  17597. utils.ErrorLog("解析失败:%v", roles.UserName)
  17598. api := miConfig.Url + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  17599. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  17600. "&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
  17601. resp, requestErr := http.Get(api)
  17602. if requestErr != nil {
  17603. utils.ErrorLog("解析失败:%v", requestErr)
  17604. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17605. return
  17606. }
  17607. body, ioErr := ioutil.ReadAll(resp.Body)
  17608. if ioErr != nil {
  17609. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  17610. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17611. return
  17612. }
  17613. var respJSON map[string]interface{}
  17614. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  17615. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  17616. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17617. return
  17618. }
  17619. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  17620. result, _ := json.Marshal(respJSON)
  17621. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  17622. utils.ErrorLog("解析失败:%v", err)
  17623. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17624. return
  17625. }
  17626. infocode = resThree.Infcode
  17627. } else if miConfig.MdtrtareaAdmvs == "421182" {
  17628. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  17629. //if strings.Contains(insuplc_admdvs_temp, "4202") {
  17630. // insuplc_admdvs_temp =
  17631. //}
  17632. //if strings.Contains(insuplc_admdvs_temp, "4413") {
  17633. // insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  17634. //}
  17635. api := miConfig.Url + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  17636. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  17637. "&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
  17638. resp, requestErr := http.Get(api)
  17639. if requestErr != nil {
  17640. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17641. return
  17642. }
  17643. body, ioErr := ioutil.ReadAll(resp.Body)
  17644. if ioErr != nil {
  17645. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  17646. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17647. return
  17648. }
  17649. var respJSON map[string]interface{}
  17650. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  17651. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  17652. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17653. return
  17654. }
  17655. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  17656. result, _ := json.Marshal(respJSON)
  17657. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  17658. utils.ErrorLog("解析失败:%v", err)
  17659. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17660. return
  17661. }
  17662. infocode = resThree.Infcode
  17663. } else if miConfig.MdtrtareaAdmvs == "150499" {
  17664. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  17665. psn_info, _ := service.GetPsnByPatientId(id)
  17666. var verify_number string
  17667. if id_card_type == 4 {
  17668. verify_number = psn_info.VerifyNumber
  17669. } else if id_card_type == 1 {
  17670. bas := strings.Split(psn_info.CardInfo, "|")
  17671. cardNumber := bas[2]
  17672. verify_number = cardNumber
  17673. }
  17674. api := "http://172.16.13.254:9532/" + "nmyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  17675. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  17676. "&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
  17677. resp, requestErr := http.Get(api)
  17678. if requestErr != nil {
  17679. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17680. return
  17681. }
  17682. body, ioErr := ioutil.ReadAll(resp.Body)
  17683. if ioErr != nil {
  17684. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  17685. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17686. return
  17687. }
  17688. var respJSON map[string]interface{}
  17689. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  17690. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  17691. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17692. return
  17693. }
  17694. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  17695. result, _ := json.Marshal(respJSON)
  17696. //if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  17697. // utils.ErrorLog("解析失败:%v", err)
  17698. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17699. // return
  17700. //}
  17701. //infocode = resThree.Infcode
  17702. //result, _ := json.Marshal(respJSON)
  17703. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  17704. utils.ErrorLog("解析失败:%v", err)
  17705. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17706. return
  17707. }
  17708. resThree.ErrMsg = resThree10265.ErrMsg
  17709. resThree.Output = resThree10265.Output
  17710. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  17711. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  17712. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  17713. psn_info, _ := service.GetPsnByPatientId(id)
  17714. his.PsnNo = psn_info.PsnNo
  17715. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  17716. var cert_no string
  17717. if id_card_type == 3 {
  17718. psn_info.VerifyNumber = IdCardNo + "|" + psn_info.VerifyNumber
  17719. cert_no = IdCardNo
  17720. } else if id_card_type == 4 {
  17721. cert_no = IdCardNo
  17722. psn_info.VerifyNumber = psn_info.VerifyNumber
  17723. } else {
  17724. bas := strings.Split(psn_info.CardInfo, "|")
  17725. cert_no = bas[2]
  17726. }
  17727. var hisPrescription []*models.HisPrescription
  17728. for _, item := range rf {
  17729. if item.Insutype == insutype {
  17730. //insuplc_admdvs = item.InsuplcAdmdvs
  17731. his.InsuplcAdmdvs = insuplc_admdvs
  17732. }
  17733. }
  17734. his.Insutype = insutype
  17735. res3101 := Check3101ForOne(c, patient.ID, his, admin_user_id, "1", record_time, hisPrescription)
  17736. fmt.Println(res3101)
  17737. fmt.Println(res3101.Infcode)
  17738. if res3101.Infcode == "0" {
  17739. fmt.Println("33333333")
  17740. if len(res3101.Output.Result) > 0 {
  17741. fmt.Println("222222")
  17742. for _, item := range res3101.Output.Result {
  17743. if len(res3101.ErrMsg) == 0 {
  17744. res3101.ErrMsg = item.VolaCont
  17745. } else {
  17746. res3101.ErrMsg = res3101.ErrMsg + "\n" + item.VolaCont
  17747. }
  17748. }
  17749. c.ServeSuccessJSON(map[string]interface{}{
  17750. "failed_code": -10,
  17751. "msg": res3101.ErrMsg,
  17752. })
  17753. return
  17754. } else {
  17755. fmt.Println("11111")
  17756. var api string
  17757. if miConfig.MdtrtareaAdmvs == "320921" {
  17758. ipt_otp_no = timeFormat
  17759. api = "http://192.168.2.3:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  17760. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  17761. "&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
  17762. } else {
  17763. ipt_otp_no = timeFormat
  17764. api = "http://192.168.5.251:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  17765. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  17766. "&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
  17767. }
  17768. resp, requestErr := http.Get(api)
  17769. if requestErr != nil {
  17770. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17771. return
  17772. }
  17773. body, ioErr := ioutil.ReadAll(resp.Body)
  17774. if ioErr != nil {
  17775. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  17776. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17777. return
  17778. }
  17779. var respJSON map[string]interface{}
  17780. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  17781. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  17782. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17783. return
  17784. }
  17785. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  17786. result, _ := json.Marshal(respJSON)
  17787. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  17788. utils.ErrorLog("解析失败:%v", err)
  17789. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17790. return
  17791. }
  17792. resThree.ErrMsg = resThree10265.ErrMsg
  17793. resThree.Output = resThree10265.Output
  17794. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  17795. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  17796. }
  17797. } else if res3101.Infcode != "0" {
  17798. c.ServeSuccessJSON(map[string]interface{}{
  17799. "failed_code": -10,
  17800. "msg": res3101.ErrMsg,
  17801. })
  17802. return
  17803. }
  17804. } else if miConfig.MdtrtareaAdmvs == "350500" {
  17805. psn_info, _ := service.GetPsnByPatientId(id)
  17806. var cert_no string
  17807. if id_card_type == 1 {
  17808. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  17809. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  17810. } else if id_card_type == 4 {
  17811. cert_no = psn_info.VerifyNumber
  17812. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  17813. } else {
  17814. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  17815. cert_no = psn_info.VerifyNumber
  17816. }
  17817. 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)
  17818. saveLog(result, requestLog, "2201", "挂号")
  17819. if miConfig.Code == "H15049901371" {
  17820. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  17821. utils.ErrorLog("解析失败:%v", err)
  17822. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17823. return
  17824. }
  17825. resThree.ErrMsg = resThree10265.ErrMsg
  17826. resThree.Output = resThree10265.Output
  17827. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  17828. } else {
  17829. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  17830. utils.ErrorLog("解析失败:%v", err)
  17831. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17832. return
  17833. }
  17834. }
  17835. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  17836. } else if miConfig.MdtrtareaAdmvs == "360302" { //江西萍乡
  17837. psn_info, _ := service.GetPsnByPatientId(id)
  17838. var result string
  17839. var requestLog string
  17840. if id_card_type == 1 {
  17841. bas := strings.Split(psn_info.CardInfo, "|")
  17842. basNumber := bas[2]
  17843. card_sn := bas[3]
  17844. 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)
  17845. saveLog(result, requestLog, "2201A", "挂号")
  17846. } else if id_card_type == 2 {
  17847. 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, "", "", "", "", "", "")
  17848. saveLog(result, requestLog, "2201A", "挂号")
  17849. } else {
  17850. 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)
  17851. saveLog(result, requestLog, "2201A", "挂号")
  17852. }
  17853. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  17854. utils.ErrorLog("解析失败:%v", err)
  17855. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17856. return
  17857. }
  17858. infocode = resThree.Infcode
  17859. } else if miConfig.MdtrtareaAdmvs == "341203" {
  17860. psn_info, _ := service.GetPsnByPatientId(id)
  17861. his.PsnNo = psn_info.PsnNo
  17862. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  17863. var cert_no string
  17864. if id_card_type == 1 {
  17865. bas := strings.Split(psn_info.CardInfo, "|")
  17866. cert_no = bas[2]
  17867. } else if id_card_type == 4 {
  17868. cert_no = IdCardNo
  17869. psn_info.VerifyNumber = psn_info.VerifyNumber
  17870. } else {
  17871. cert_no = IdCardNo
  17872. psn_info.VerifyNumber = cert_no
  17873. }
  17874. for _, item := range rf {
  17875. if item.Insutype == insutype {
  17876. his.InsuplcAdmdvs = insuplc_admdvs
  17877. }
  17878. }
  17879. his.Insutype = insutype
  17880. var api string
  17881. ipt_otp_no = timeFormat
  17882. api = miConfig.SecretKey + "ahyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  17883. "&org_name=" + miConfig.OrgName + "&opera=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  17884. "&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
  17885. resp, requestErr := http.Get(api)
  17886. if requestErr != nil {
  17887. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17888. return
  17889. }
  17890. body, ioErr := ioutil.ReadAll(resp.Body)
  17891. if ioErr != nil {
  17892. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  17893. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17894. return
  17895. }
  17896. var respJSON map[string]interface{}
  17897. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  17898. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  17899. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17900. return
  17901. }
  17902. status := respJSON["data"].(map[string]interface{})["status"].(string)
  17903. if status == "0" {
  17904. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  17905. c.ServeSuccessJSON(map[string]interface{}{
  17906. "failed_code": -10,
  17907. "msg": err_msg,
  17908. })
  17909. return
  17910. }
  17911. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  17912. result, _ := json.Marshal(respJSON)
  17913. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  17914. utils.ErrorLog("解析失败:%v", err)
  17915. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17916. return
  17917. }
  17918. infocode = resThree.Infcode
  17919. } else if miConfig.MdtrtareaAdmvs == "430800" {
  17920. psn_info, _ := service.GetPsnByPatientId(id)
  17921. var result string
  17922. var requestLog string
  17923. if id_card_type == 1 {
  17924. bas := strings.Split(psn_info.CardInfo, "|")
  17925. basNumber := bas[2]
  17926. card_sn := bas[3]
  17927. 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)
  17928. saveLog(result, requestLog, "2201A", "挂号")
  17929. } else if id_card_type == 2 {
  17930. 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, "", "")
  17931. saveLog(result, requestLog, "2201A", "挂号")
  17932. } else {
  17933. 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, "", "")
  17934. saveLog(result, requestLog, "2201A", "挂号")
  17935. }
  17936. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  17937. utils.ErrorLog("解析失败:%v", err)
  17938. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17939. return
  17940. }
  17941. infocode = resThree.Infcode
  17942. } else if miConfig.MdtrtareaAdmvs == "131023" {
  17943. psn_info, _ := service.GetPsnByPatientId(id)
  17944. 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)
  17945. saveLog(result, requestLog, "2201A", "挂号")
  17946. if miConfig.Code == "H15049901371" {
  17947. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  17948. utils.ErrorLog("解析失败:%v", err)
  17949. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17950. return
  17951. }
  17952. resThree.ErrMsg = resThree10265.ErrMsg
  17953. resThree.Output = resThree10265.Output
  17954. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  17955. } else {
  17956. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  17957. utils.ErrorLog("解析失败:%v", err)
  17958. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17959. return
  17960. }
  17961. }
  17962. if miConfig.Code == "H15049901371" {
  17963. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  17964. } else {
  17965. infocode = resThree.Infcode
  17966. }
  17967. } else {
  17968. psn_info, _ := service.GetPsnByPatientId(id)
  17969. if id_card_type == 4 || id_card_type == 1 {
  17970. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  17971. }
  17972. var rf []*ResultFive
  17973. json.Unmarshal([]byte(psn_info.Insuinfo), &rf)
  17974. var insutypes []*ResultFive
  17975. var insutype string
  17976. var is390 int = 0
  17977. var is310 int = 0
  17978. for _, item := range rf {
  17979. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  17980. insutypes = append(insutypes, item)
  17981. }
  17982. }
  17983. if len(insutypes) == 1 {
  17984. insutype = insutypes[0].Insutype
  17985. insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  17986. } else {
  17987. for _, i := range insutypes {
  17988. if i.Insutype == "390" {
  17989. is390 = 1
  17990. }
  17991. if i.Insutype == "310" {
  17992. is310 = 1
  17993. }
  17994. }
  17995. }
  17996. if is390 == 1 {
  17997. insutype = "390"
  17998. }
  17999. if is310 == 1 {
  18000. insutype = "310"
  18001. }
  18002. fmt.Println(len(insutypes))
  18003. if len(insutypes) == 0 {
  18004. for index, item := range rf {
  18005. if index == 0 {
  18006. insutype = item.Insutype
  18007. insuplc_admdvs = item.InsuplcAdmdvs
  18008. }
  18009. }
  18010. fmt.Println(insutype)
  18011. fmt.Println(insuplc_admdvs)
  18012. }
  18013. if social_type > 0 {
  18014. insutype = strconv.FormatInt(social_type, 10)
  18015. }
  18016. fmt.Println("--------")
  18017. fmt.Println(psn_info)
  18018. fmt.Println(psn_info.PsnNo)
  18019. if miConfig.MdtrtareaAdmvs == "441202" {
  18020. var hisPrescription []*models.HisPrescription
  18021. res3101 := Checkgd3101ForOne(c, patient.ID, his, admin_user_id, "1", record_time, hisPrescription)
  18022. if res3101.Infcode == 0 {
  18023. fmt.Println("33333333")
  18024. if len(res3101.Output.Result) > 0 {
  18025. fmt.Println("222222")
  18026. for _, item := range res3101.Output.Result {
  18027. if len(res3101.ErrMsg) == 0 {
  18028. res3101.ErrMsg = item.VolaCont
  18029. } else {
  18030. res3101.ErrMsg = res3101.ErrMsg + "\n" + item.VolaCont
  18031. }
  18032. }
  18033. c.ServeSuccessJSON(map[string]interface{}{
  18034. "failed_code": -10,
  18035. "msg": res3101.ErrMsg,
  18036. })
  18037. return
  18038. } else {
  18039. hour := time.Now().Format("15")
  18040. min := time.Now().Format("04")
  18041. sec := time.Now().Format("05")
  18042. record_time_two := record_time + " " + hour + ":" + min + ":" + sec
  18043. fmt.Println(record_time_two)
  18044. 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)
  18045. saveLog(result, requestLog, "2201A", "挂号")
  18046. if miConfig.Code == "H15049901371" {
  18047. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  18048. utils.ErrorLog("解析失败:%v", err)
  18049. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18050. return
  18051. }
  18052. resThree.ErrMsg = resThree10265.ErrMsg
  18053. resThree.Output = resThree10265.Output
  18054. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  18055. } else {
  18056. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  18057. utils.ErrorLog("解析失败:%v", err)
  18058. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18059. return
  18060. }
  18061. }
  18062. if miConfig.Code == "H15049901371" {
  18063. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  18064. } else {
  18065. infocode = resThree.Infcode
  18066. }
  18067. }
  18068. } else if res3101.Infcode != 0 {
  18069. c.ServeSuccessJSON(map[string]interface{}{
  18070. "failed_code": -10,
  18071. "msg": res3101.ErrMsg,
  18072. })
  18073. return
  18074. }
  18075. } else if miConfig.MdtrtareaAdmvs == "441799" {
  18076. doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  18077. psn_info, _ := service.GetPsnByPatientId(id)
  18078. var verify_number string
  18079. if id_card_type == 4 {
  18080. verify_number = psn_info.VerifyNumber
  18081. } else if id_card_type == 1 {
  18082. bas := strings.Split(psn_info.CardInfo, "|")
  18083. cardNumber := bas[2]
  18084. verify_number = cardNumber
  18085. } else {
  18086. verify_number = psn_info.Certno
  18087. }
  18088. api := miConfig.Url + "gdyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  18089. "&org_name=" + miConfig.OrgName + "&operator=" + roles.UserName + "&doctor=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  18090. "&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
  18091. resp, requestErr := http.Get(api)
  18092. if requestErr != nil {
  18093. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18094. return
  18095. }
  18096. body, ioErr := ioutil.ReadAll(resp.Body)
  18097. if ioErr != nil {
  18098. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  18099. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18100. return
  18101. }
  18102. var respJSON map[string]interface{}
  18103. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  18104. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18105. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18106. return
  18107. }
  18108. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  18109. result, _ := json.Marshal(respJSON)
  18110. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  18111. utils.ErrorLog("解析失败:%v", err)
  18112. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18113. return
  18114. }
  18115. infocode = resThree.Infcode
  18116. } else {
  18117. hour := time.Now().Format("15")
  18118. min := time.Now().Format("04")
  18119. sec := time.Now().Format("05")
  18120. record_time_two := record_time + " " + hour + ":" + min + ":" + sec
  18121. if id_card_type == 1 {
  18122. for _, item := range rf {
  18123. if item.Insutype == strconv.FormatInt(social_type, 10) {
  18124. if strconv.FormatInt(social_type, 10) == "310" && item.PsnInsuStas == "1" {
  18125. insuplc_admdvs_temp = item.InsuplcAdmdvs
  18126. } else if strconv.FormatInt(social_type, 10) == "390" {
  18127. insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  18128. } else {
  18129. insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  18130. }
  18131. }
  18132. }
  18133. }
  18134. if miConfig.MdtrtareaAdmvs == "440205" && strconv.FormatInt(social_type, 10) == "390" {
  18135. insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  18136. }
  18137. if id_card_type == 1 {
  18138. utils.ErrorLog("解析失败:%v", psn_info.CardInfo)
  18139. bas := strings.Split(psn_info.CardInfo, "|")
  18140. basNumber := bas[1]
  18141. IdCardNo = basNumber
  18142. }
  18143. if miConfig.MdtrtareaAdmvs == "450721" && id_card_type == 1 {
  18144. IdCardNo = psn_info.VerifyNumber
  18145. }
  18146. 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)
  18147. saveLog(result, requestLog, "2201A", "挂号")
  18148. if miConfig.Code == "H15049901371" {
  18149. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  18150. utils.ErrorLog("解析失败:%v", err)
  18151. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18152. return
  18153. }
  18154. resThree.ErrMsg = resThree10265.ErrMsg
  18155. resThree.Output = resThree10265.Output
  18156. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  18157. } else {
  18158. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  18159. utils.ErrorLog("解析失败:%v", err)
  18160. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18161. return
  18162. }
  18163. }
  18164. if miConfig.Code == "H15049901371" {
  18165. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  18166. } else {
  18167. infocode = resThree.Infcode
  18168. }
  18169. }
  18170. }
  18171. if infocode != 0 {
  18172. adminUser := c.GetAdminUserInfo()
  18173. errlog := &models.HisOrderError{
  18174. UserOrgId: adminUser.CurrentOrgId,
  18175. Ctime: time.Now().Unix(),
  18176. Mtime: time.Now().Unix(),
  18177. ErrMsg: resThree.ErrMsg,
  18178. Status: 1,
  18179. PatientId: id,
  18180. RecordTime: recordDateTime,
  18181. Stage: 2,
  18182. }
  18183. service.CreateErrMsgLog(errlog)
  18184. c.ServeSuccessJSON(map[string]interface{}{
  18185. "failed_code": -10,
  18186. "msg": resThree.ErrMsg,
  18187. })
  18188. return
  18189. }
  18190. his.Number = resThree.Output.Data.MdtrtID
  18191. his.PsnNo = resThree.Output.Data.PsnNo
  18192. his.IptOtpNo = resThree.Output.Data.IptOtpNo
  18193. his.IdCardNo = patient.IdCardNo
  18194. his.PhoneNumber = patient.Phone
  18195. his.UserOrgId = adminInfo.CurrentOrgId
  18196. his.Insutype = insutype
  18197. his.Ctime = time.Now().Unix()
  18198. his.Mtime = time.Now().Unix()
  18199. his.InsuplcAdmdvs = insuplc_admdvs_temp
  18200. if miConfig.MdtrtareaAdmvs == "421300" && strings.Contains(insuplc_admdvs_temp, "4213") {
  18201. his.InsuplcAdmdvs = miConfig.MdtrtareaAdmvs
  18202. }
  18203. if miConfig.MdtrtareaAdmvs == "420200" && strings.Contains(insuplc_admdvs_temp, "4202") {
  18204. his.InsuplcAdmdvs = miConfig.MdtrtareaAdmvs
  18205. }
  18206. if miConfig.MdtrtareaAdmvs == "421182" && strings.Contains(insuplc_admdvs_temp, "4211") {
  18207. his.InsuplcAdmdvs = miConfig.MdtrtareaAdmvs
  18208. }
  18209. his.Status = 1
  18210. his.MdtrtGrpType = mdtrt_type
  18211. service.UpdateHisPatientStatus(&his)
  18212. service.UpdateHisPrescriptionHisID(his.ID, patient.ID, recordDateTime, adminInfo.CurrentOrgId)
  18213. c.ServeSuccessJSON(map[string]interface{}{
  18214. "his_info": his,
  18215. })
  18216. } else {
  18217. adminUser := c.GetAdminUserInfo()
  18218. errlog := &models.HisOrderError{
  18219. UserOrgId: adminUser.CurrentOrgId,
  18220. Ctime: time.Now().Unix(),
  18221. Mtime: time.Now().Unix(),
  18222. ErrMsg: res.ErrMsg,
  18223. Status: 1,
  18224. PatientId: id,
  18225. RecordTime: recordDateTime,
  18226. Stage: 1,
  18227. }
  18228. service.CreateErrMsgLog(errlog)
  18229. c.ServeSuccessJSON(map[string]interface{}{
  18230. "failed_code": -10,
  18231. "msg": res.ErrMsg,
  18232. })
  18233. return
  18234. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  18235. }
  18236. }
  18237. }
  18238. func (c *HisApiController) GetUploadInfo() {
  18239. id, _ := c.GetInt64("id")
  18240. record_time := c.GetString("record_time")
  18241. his_patient_id, _ := c.GetInt64("his_patient_id")
  18242. order_id, _ := c.GetInt64("order_id")
  18243. pay_way, _ := c.GetInt64("pay_way")
  18244. pay_ways := c.GetString("pay_ways")
  18245. oth_desc := c.GetString("oth_desc")
  18246. pay_price, _ := c.GetFloat("pay_price")
  18247. pay_card_no := c.GetString("pay_card_no")
  18248. discount_price, _ := c.GetFloat("discount_price")
  18249. preferential_price, _ := c.GetFloat("preferential_price")
  18250. reality_price, _ := c.GetFloat("reality_price")
  18251. found_price, _ := c.GetFloat("found_price")
  18252. medical_insurance_price, _ := c.GetFloat("medical_insurance_price")
  18253. private_price, _ := c.GetFloat("private_price")
  18254. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  18255. admin_user_id, _ := c.GetInt64("admin_user_id")
  18256. fapiao_code := c.GetString("fapiao_code")
  18257. fapiao_number := c.GetString("fapiao_number")
  18258. diagnosis_id := c.GetString("diagnosis")
  18259. sick_type, _ := c.GetInt64("sick_type")
  18260. reg_type, _ := c.GetInt64("p_type")
  18261. begin_time := c.GetString("begin_time")
  18262. acct_used_flag_num, _ := c.GetInt64("acct_used_flag")
  18263. cash_pay := c.GetString("cash_pay")
  18264. band_card_pay := c.GetString("band_card_pay")
  18265. wechat_pay := c.GetString("wechat_pay")
  18266. ali_pay := c.GetString("ali_pay")
  18267. jifen_pay := c.GetString("jifen_pay")
  18268. acct_used_flag := strconv.FormatInt(acct_used_flag_num, 10)
  18269. fmt.Println(acct_used_flag)
  18270. id_str := c.GetString("ids")
  18271. ids_arr := strings.Split(id_str, ",")
  18272. timeLayout := "2006-01-02"
  18273. loc, _ := time.LoadLocation("Local")
  18274. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  18275. if err != nil {
  18276. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  18277. return
  18278. }
  18279. recordDateTime := theTime.Unix()
  18280. adminUser := c.GetAdminUserInfo()
  18281. var tempOrder models.HisOrder
  18282. tempOrder, _ = service.GetHisOrderByID(order_id)
  18283. var prescriptions []*models.HisPrescription
  18284. var start_time int64
  18285. var end_time int64
  18286. //押金模块
  18287. dec_way := c.GetString("dec_way") //是否使用押金支付bool类型
  18288. tmp_decimal := c.GetString("tmp_decimal")
  18289. var decimal float64 //本次使用的押金
  18290. var errmsg error
  18291. if dec_way == "true" && tmp_decimal == "0" || dec_way == "true" && tmp_decimal == "" {
  18292. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "押金不能为0")
  18293. return
  18294. }
  18295. if len(tmp_decimal) > 0 {
  18296. if tmp_decimal[0] == 45 {
  18297. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "押金不能为负数")
  18298. return
  18299. }
  18300. }
  18301. tt, errs := strconv.ParseFloat(tmp_decimal, 64)
  18302. fmt.Println(errs)
  18303. decimal = tt
  18304. //if adminUser.CurrentOrgId == 10106{
  18305. // if len(fapiao_code) == 0{
  18306. // fapiao_code = "144072080589"
  18307. // }
  18308. // if len(fapiao_number) == 0{
  18309. // order, _ := service.GetLastHisOrder(adminUser.CurrentOrgId)
  18310. // if order.ID == 0{
  18311. // fapiao_number = "00001520"
  18312. // }else{
  18313. // //fapiao_code = "00001520"
  18314. // fpNumber, _ := strconv.Atoi(order.FaPiaoNumber)
  18315. // var zero string
  18316. // if fpNumber >= 1000{
  18317. // zero = "0000" + strconv.Itoa(fpNumber)
  18318. // }else if fpNumber >= 10000{
  18319. // zero = "000" + strconv.Itoa(fpNumber)
  18320. // } else if fpNumber >= 100000{
  18321. // zero = "00" + strconv.Itoa(fpNumber)
  18322. // } else if fpNumber >= 1000000{
  18323. // zero = "0" + strconv.Itoa(fpNumber)
  18324. // }else {
  18325. // zero = strconv.Itoa(fpNumber)
  18326. // }
  18327. // fapiao_number = zero
  18328. // }
  18329. // }
  18330. //}
  18331. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  18332. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  18333. var patientPrescription models.HisPrescriptionInfo
  18334. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  18335. if patientPrescription.ID == 0 {
  18336. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  18337. }
  18338. //if patientPrescription.Do
  18339. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  18340. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  18341. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  18342. diagnosis_ids := strings.Split(diagnosis_id, ",")
  18343. var config []*models.HisXtDiagnoseConfig
  18344. for _, item := range diagnosis_ids {
  18345. id, _ := strconv.ParseInt(item, 10, 64)
  18346. diagnosisConfig, _ := service.FindDiagnoseById(id)
  18347. config = append(config, &diagnosisConfig)
  18348. }
  18349. sickConfig, _ := service.FindSickById(sick_type)
  18350. //if tempOrder.ID == 0 {
  18351. // tempOrder, _ = service.GetTodayHisOrder(adminUser.CurrentOrgId, id, recordDateTime, his.Number)
  18352. //}
  18353. if tempOrder.ID == 0 {
  18354. var result string
  18355. var requestLog string
  18356. var res2 ResultSix
  18357. var res3 GZResultSix
  18358. var ressix10265 ResultSix10265
  18359. if miConfig.MdtrtareaAdmvs == "421300" {
  18360. data := make(map[string]interface{})
  18361. client := &http.Client{}
  18362. data["psn_no"] = his.PsnNo
  18363. data["mdtrt_id"] = his.Number
  18364. data["opter"] = roles.UserName
  18365. data["org_name"] = miConfig.OrgName
  18366. data["med_type"] = strconv.FormatInt(reg_type, 10)
  18367. data["doctor_id"] = doctor_info.DoctorNumber
  18368. data["doctor_name"] = doctor_info.UserName
  18369. data["department"] = department.Name
  18370. data["fixmedins_code"] = miConfig.Code
  18371. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  18372. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  18373. data["secret_key"] = miConfig.SecretKey
  18374. data["sick_code"] = sickConfig.CountryCode
  18375. data["sick_name"] = sickConfig.ClassName
  18376. data["dept"] = strconv.FormatInt(department.ID, 10)
  18377. data["config"] = config
  18378. data["begin_time"] = begin_time
  18379. bytesData, _ := json.Marshal(data)
  18380. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  18381. resp, _ := client.Do(req)
  18382. defer resp.Body.Close()
  18383. body, ioErr := ioutil.ReadAll(resp.Body)
  18384. if ioErr != nil {
  18385. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  18386. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18387. return
  18388. }
  18389. var respJSON map[string]interface{}
  18390. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  18391. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18392. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18393. return
  18394. }
  18395. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  18396. userJSONBytes, _ := json.Marshal(respJSON)
  18397. fmt.Println("log")
  18398. fmt.Println(string(userJSONBytes))
  18399. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  18400. utils.ErrorLog("解析失败:%v", err)
  18401. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18402. return
  18403. }
  18404. } else if miConfig.MdtrtareaAdmvs == "420200" {
  18405. data := make(map[string]interface{})
  18406. client := &http.Client{}
  18407. data["psn_no"] = his.PsnNo
  18408. data["mdtrt_id"] = his.Number
  18409. data["opter"] = roles.UserName
  18410. data["org_name"] = miConfig.OrgName
  18411. if reg_type == 11 && his.Insutype == "390" {
  18412. data["med_type"] = "110104"
  18413. } else {
  18414. data["med_type"] = strconv.FormatInt(reg_type, 10)
  18415. }
  18416. data["doctor_id"] = doctor_info.DoctorNumber
  18417. data["doctor_name"] = doctor_info.UserName
  18418. data["department"] = department.Name
  18419. data["fixmedins_code"] = miConfig.Code
  18420. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  18421. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  18422. data["secret_key"] = miConfig.SecretKey
  18423. data["sick_code"] = sickConfig.CountryCode
  18424. data["sick_name"] = sickConfig.ClassName
  18425. data["dept"] = strconv.FormatInt(department.ID, 10)
  18426. data["config"] = config
  18427. data["begin_time"] = begin_time
  18428. bytesData, _ := json.Marshal(data)
  18429. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  18430. resp, _ := client.Do(req)
  18431. defer resp.Body.Close()
  18432. body, ioErr := ioutil.ReadAll(resp.Body)
  18433. if ioErr != nil {
  18434. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  18435. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18436. return
  18437. }
  18438. var respJSON map[string]interface{}
  18439. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  18440. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18441. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18442. return
  18443. }
  18444. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  18445. userJSONBytes, _ := json.Marshal(respJSON)
  18446. fmt.Println("log")
  18447. fmt.Println(string(userJSONBytes))
  18448. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  18449. utils.ErrorLog("解析失败:%v", err)
  18450. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18451. return
  18452. }
  18453. } else if miConfig.MdtrtareaAdmvs == "420902" {
  18454. data := make(map[string]interface{})
  18455. client := &http.Client{}
  18456. data["psn_no"] = his.PsnNo
  18457. data["mdtrt_id"] = his.Number
  18458. data["opter"] = roles.UserName
  18459. data["org_name"] = miConfig.OrgName
  18460. if reg_type == 11 && his.Insutype == "390" {
  18461. data["med_type"] = "110104"
  18462. } else {
  18463. data["med_type"] = strconv.FormatInt(reg_type, 10)
  18464. }
  18465. data["doctor_id"] = doctor_info.DoctorNumber
  18466. data["doctor_name"] = doctor_info.UserName
  18467. data["department"] = department.Name
  18468. data["fixmedins_code"] = miConfig.Code
  18469. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  18470. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  18471. data["secret_key"] = miConfig.SecretKey
  18472. data["sick_code"] = sickConfig.CountryCode
  18473. data["sick_name"] = sickConfig.ClassName
  18474. data["dept"] = strconv.FormatInt(department.ID, 10)
  18475. data["config"] = config
  18476. data["begin_time"] = begin_time
  18477. bytesData, _ := json.Marshal(data)
  18478. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2203", bytes.NewReader(bytesData))
  18479. resp, _ := client.Do(req)
  18480. defer resp.Body.Close()
  18481. body, ioErr := ioutil.ReadAll(resp.Body)
  18482. if ioErr != nil {
  18483. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  18484. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18485. return
  18486. }
  18487. var respJSON map[string]interface{}
  18488. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  18489. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18490. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18491. return
  18492. }
  18493. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  18494. userJSONBytes, _ := json.Marshal(respJSON)
  18495. fmt.Println("log")
  18496. fmt.Println(string(userJSONBytes))
  18497. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  18498. utils.ErrorLog("解析失败:%v", err)
  18499. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18500. return
  18501. }
  18502. }else if miConfig.MdtrtareaAdmvs == "421182" {
  18503. data := make(map[string]interface{})
  18504. client := &http.Client{}
  18505. data["psn_no"] = his.PsnNo
  18506. data["mdtrt_id"] = his.Number
  18507. data["opter"] = roles.UserName
  18508. data["org_name"] = miConfig.OrgName
  18509. if reg_type == 11 && his.Insutype == "390" {
  18510. data["med_type"] = "110104"
  18511. } else {
  18512. data["med_type"] = strconv.FormatInt(reg_type, 10)
  18513. }
  18514. data["doctor_id"] = doctor_info.DoctorNumber
  18515. data["doctor_name"] = doctor_info.UserName
  18516. data["department"] = department.Name
  18517. data["fixmedins_code"] = miConfig.Code
  18518. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  18519. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  18520. data["secret_key"] = miConfig.SecretKey
  18521. data["sick_code"] = sickConfig.CountryCode
  18522. data["sick_name"] = sickConfig.ClassName
  18523. data["dept"] = strconv.FormatInt(department.ID, 10)
  18524. data["config"] = config
  18525. data["begin_time"] = begin_time
  18526. bytesData, _ := json.Marshal(data)
  18527. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2203", bytes.NewReader(bytesData))
  18528. resp, _ := client.Do(req)
  18529. defer resp.Body.Close()
  18530. body, ioErr := ioutil.ReadAll(resp.Body)
  18531. if ioErr != nil {
  18532. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  18533. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18534. return
  18535. }
  18536. var respJSON map[string]interface{}
  18537. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  18538. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18539. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18540. return
  18541. }
  18542. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  18543. userJSONBytes, _ := json.Marshal(respJSON)
  18544. fmt.Println("log")
  18545. fmt.Println(string(userJSONBytes))
  18546. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  18547. utils.ErrorLog("解析失败:%v", err)
  18548. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18549. return
  18550. }
  18551. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  18552. data := make(map[string]interface{})
  18553. client := &http.Client{}
  18554. data["psn_no"] = his.PsnNo
  18555. data["mdtrt_id"] = his.Number
  18556. data["doctor"] = roles.UserName
  18557. data["department"] = department.Name
  18558. data["org_name"] = miConfig.OrgName
  18559. data["med_type"] = strconv.FormatInt(reg_type, 10)
  18560. data["doctor_id"] = doctor_info.DoctorNumber
  18561. data["new_doctor_name"] = doctor_info.UserName
  18562. data["fixmedins_code"] = miConfig.Code
  18563. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  18564. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  18565. data["secret_key"] = miConfig.SecretKey
  18566. data["sick_code"] = sickConfig.CountryCode
  18567. data["sick_name"] = sickConfig.ClassName
  18568. data["url"] = miConfig.Url
  18569. data["ak"] = miConfig.AccessKey
  18570. data["begin_time"] = begin_time
  18571. data["cainfo"] = miConfig.Cainfo
  18572. data["dept"] = strconv.FormatInt(department.ID, 10)
  18573. data["config"] = config
  18574. bytesData, _ := json.Marshal(data)
  18575. var req *http.Request
  18576. if miConfig.MdtrtareaAdmvs == "320921" {
  18577. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  18578. //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 +
  18579. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo
  18580. } else {
  18581. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  18582. }
  18583. resp, _ := client.Do(req)
  18584. defer resp.Body.Close()
  18585. body, ioErr := ioutil.ReadAll(resp.Body)
  18586. if ioErr != nil {
  18587. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  18588. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18589. return
  18590. }
  18591. var respJSON map[string]interface{}
  18592. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  18593. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18594. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18595. return
  18596. }
  18597. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  18598. userJSONBytes, _ := json.Marshal(respJSON)
  18599. fmt.Println("log")
  18600. fmt.Println(string(userJSONBytes))
  18601. if err := json.Unmarshal(userJSONBytes, &ressix10265); err != nil {
  18602. utils.ErrorLog("解析失败:%v", err)
  18603. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18604. return
  18605. }
  18606. res2.InfRefmsgid = ressix10265.InfRefmsgid
  18607. res2.Output = ressix10265.Output
  18608. res2.ErrMsg = ressix10265.ErrMsg
  18609. res2.Cainfo = ressix10265.Cainfo
  18610. res2.WarnMsg = ressix10265.WarnMsg
  18611. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  18612. res2.Infcode = infocode
  18613. } else if miConfig.MdtrtareaAdmvs == "150499" {
  18614. data := make(map[string]interface{})
  18615. client := &http.Client{}
  18616. data["psn_no"] = his.PsnNo
  18617. data["mdtrt_id"] = his.Number
  18618. data["doctor"] = roles.UserName
  18619. data["department"] = department.Name
  18620. data["org_name"] = miConfig.OrgName
  18621. data["med_type"] = strconv.FormatInt(reg_type, 10)
  18622. data["doctor_id"] = doctor_info.DoctorNumber
  18623. data["new_doctor_name"] = doctor_info.UserName
  18624. data["fixmedins_code"] = miConfig.Code
  18625. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  18626. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  18627. data["secret_key"] = miConfig.SecretKey
  18628. data["sick_code"] = sickConfig.CountryCode
  18629. data["sick_name"] = sickConfig.ClassName
  18630. data["url"] = miConfig.Url
  18631. data["ak"] = miConfig.AccessKey
  18632. data["begin_time"] = begin_time
  18633. data["cainfo"] = miConfig.Cainfo
  18634. data["dept"] = strconv.FormatInt(department.ID, 10)
  18635. data["config"] = config
  18636. bytesData, _ := json.Marshal(data)
  18637. var req *http.Request
  18638. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2203", bytes.NewReader(bytesData))
  18639. resp, _ := client.Do(req)
  18640. defer resp.Body.Close()
  18641. body, ioErr := ioutil.ReadAll(resp.Body)
  18642. if ioErr != nil {
  18643. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  18644. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18645. return
  18646. }
  18647. var respJSON map[string]interface{}
  18648. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  18649. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18650. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18651. return
  18652. }
  18653. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  18654. userJSONBytes, _ := json.Marshal(respJSON)
  18655. fmt.Println("log")
  18656. fmt.Println(string(userJSONBytes))
  18657. if err := json.Unmarshal(userJSONBytes, &ressix10265); err != nil {
  18658. utils.ErrorLog("解析失败:%v", err)
  18659. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18660. return
  18661. }
  18662. res2.InfRefmsgid = ressix10265.InfRefmsgid
  18663. res2.Output = ressix10265.Output
  18664. res2.ErrMsg = ressix10265.ErrMsg
  18665. res2.Cainfo = ressix10265.Cainfo
  18666. res2.WarnMsg = ressix10265.WarnMsg
  18667. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  18668. res2.Infcode = infocode
  18669. } else if miConfig.MdtrtareaAdmvs == "350500" {
  18670. 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)
  18671. saveLog(result, requestLog, "2203", "上传就诊信息")
  18672. var respJSON2 map[string]interface{}
  18673. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  18674. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18675. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18676. return
  18677. }
  18678. userJSONBytes2, _ := json.Marshal(respJSON2)
  18679. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  18680. utils.ErrorLog("解析失败:%v", err)
  18681. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18682. return
  18683. }
  18684. 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)
  18685. fmt.Println(result2)
  18686. fmt.Println(src_request)
  18687. } else if miConfig.MdtrtareaAdmvs == "441799" {
  18688. data := make(map[string]interface{})
  18689. client := &http.Client{}
  18690. data["psn_no"] = his.PsnNo
  18691. data["mdtrt_id"] = his.Number
  18692. data["doctor"] = roles.UserName
  18693. data["department"] = department.Name
  18694. data["org_name"] = miConfig.OrgName
  18695. data["med_type"] = strconv.FormatInt(reg_type, 10)
  18696. data["doctor_id"] = doctor_info.DoctorNumber
  18697. data["new_doctor_name"] = doctor_info.UserName
  18698. data["fixmedins_code"] = miConfig.Code
  18699. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  18700. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  18701. data["secret_key"] = miConfig.SecretKey
  18702. data["sick_code"] = sickConfig.CountryCode
  18703. data["sick_name"] = sickConfig.ClassName
  18704. data["url"] = miConfig.Url
  18705. data["ak"] = miConfig.AccessKey
  18706. data["begin_time"] = begin_time
  18707. data["cainfo"] = miConfig.Cainfo
  18708. data["dept"] = strconv.FormatInt(department.ID, 10)
  18709. data["config"] = config
  18710. bytesData, _ := json.Marshal(data)
  18711. var req *http.Request
  18712. req, _ = http.NewRequest("POST", "http://172.20.10.81:9532/"+"gdyb/2203", bytes.NewReader(bytesData))
  18713. resp, _ := client.Do(req)
  18714. defer resp.Body.Close()
  18715. body, ioErr := ioutil.ReadAll(resp.Body)
  18716. if ioErr != nil {
  18717. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  18718. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18719. return
  18720. }
  18721. var respJSON map[string]interface{}
  18722. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  18723. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18724. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18725. return
  18726. }
  18727. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  18728. userJSONBytes, _ := json.Marshal(respJSON)
  18729. fmt.Println("log")
  18730. fmt.Println(string(userJSONBytes))
  18731. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  18732. utils.ErrorLog("解析失败:%v", err)
  18733. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18734. return
  18735. }
  18736. } else {
  18737. if miConfig.MdtrtareaAdmvs == "440781" { //
  18738. 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)
  18739. } else {
  18740. if miConfig.Code == "H15049901371" {
  18741. //赤峰地区国家医保医疗类别
  18742. //职工透析:医疗类别选特殊情况门诊990502
  18743. //居民定额血透门慢: 医疗类别选门诊慢病140104
  18744. var med_type string
  18745. if his.Insutype == "390" {
  18746. if reg_type == 14 {
  18747. med_type = "9933"
  18748. } else if reg_type == 11 {
  18749. med_type = "11"
  18750. }
  18751. } else if his.Insutype == "310" {
  18752. if reg_type == 14 {
  18753. med_type = "990502"
  18754. } else if reg_type == 11 {
  18755. med_type = "11"
  18756. }
  18757. }
  18758. 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)
  18759. } else {
  18760. 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)
  18761. }
  18762. }
  18763. saveLog(result, requestLog, "2203", "上传就诊信息")
  18764. var respJSON2 map[string]interface{}
  18765. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  18766. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18767. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18768. return
  18769. }
  18770. userJSONBytes2, _ := json.Marshal(respJSON2)
  18771. if miConfig.Code == "H15049901371" {
  18772. if err := json.Unmarshal(userJSONBytes2, &ressix10265); err != nil {
  18773. utils.ErrorLog("解析失败:%v", err)
  18774. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18775. return
  18776. }
  18777. res2.InfRefmsgid = ressix10265.InfRefmsgid
  18778. res2.Output = ressix10265.Output
  18779. res2.ErrMsg = ressix10265.ErrMsg
  18780. res2.Cainfo = ressix10265.Cainfo
  18781. res2.WarnMsg = ressix10265.WarnMsg
  18782. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  18783. res2.Infcode = infocode
  18784. } else {
  18785. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  18786. if err := json.Unmarshal(userJSONBytes2, &res3); err != nil {
  18787. utils.ErrorLog("解析失败:%v", err)
  18788. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18789. return
  18790. }
  18791. res2.Infcode = res3.Infcode
  18792. } else {
  18793. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  18794. utils.ErrorLog("解析失败:%v", err)
  18795. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18796. return
  18797. }
  18798. }
  18799. }
  18800. }
  18801. if res2.Infcode != 0 {
  18802. adminUser := c.GetAdminUserInfo()
  18803. errlog := &models.HisOrderError{
  18804. UserOrgId: adminUser.CurrentOrgId,
  18805. Ctime: time.Now().Unix(),
  18806. Mtime: time.Now().Unix(),
  18807. ErrMsg: res2.ErrMsg,
  18808. Status: 1,
  18809. PatientId: id,
  18810. RecordTime: recordDateTime,
  18811. Stage: 3,
  18812. }
  18813. service.CreateErrMsgLog(errlog)
  18814. c.ServeSuccessJSON(map[string]interface{}{
  18815. "failed_code": -10,
  18816. "msg": res2.ErrMsg,
  18817. })
  18818. return
  18819. } else {
  18820. his.Diagnosis = diagnosis_id
  18821. his.SickType = sickConfig.ID
  18822. //var p_type int64
  18823. //if reg_type == 1111 || reg_type == 1112 {
  18824. // p_type = 11
  18825. //
  18826. //}
  18827. his.PType = fmt.Sprintf("%d", reg_type)
  18828. service.UpdateHisPatientThree(&his)
  18829. data := make(map[string]interface{})
  18830. if settle_accounts_type == 1 { //日结
  18831. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  18832. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  18833. } else {
  18834. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  18835. }
  18836. //prescriptions, _ = service.GetNewHisPrescriptionTwo(adminUser.CurrentOrgId, his_patient_id, recordDateTime, reg_type)
  18837. data["pre"] = prescriptions
  18838. } else { //月结
  18839. start_time_str := c.GetString("start_time")
  18840. end_time_str := c.GetString("end_time")
  18841. timeLayout := "2006-01-02"
  18842. loc, _ := time.LoadLocation("Local")
  18843. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  18844. if err != nil {
  18845. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  18846. return
  18847. }
  18848. recordStartTime := theStartTime.Unix()
  18849. start_time = recordStartTime
  18850. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  18851. if err != nil {
  18852. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  18853. return
  18854. }
  18855. recordEndTime := theEndTime.Unix()
  18856. end_time = recordEndTime
  18857. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  18858. data["pre"] = prescriptions
  18859. }
  18860. timestamp := time.Now().Unix()
  18861. tempTime := time.Unix(timestamp, 0)
  18862. timeFormat := tempTime.Format("20060102150405")
  18863. chrgBchno := rand.Intn(100000) + 10000
  18864. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  18865. strconv.FormatInt(his.PatientId, 10)
  18866. client := &http.Client{}
  18867. data["psn_no"] = his.PsnNo
  18868. data["mdtrt_id"] = his.Number
  18869. data["chrg_bchno"] = chrg_bchno
  18870. data["org_name"] = miConfig.OrgName
  18871. data["doctor"] = doctor_info.UserName
  18872. data["doctor_id"] = doctor_info.DoctorNumber
  18873. data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  18874. data["fixmedins_code"] = miConfig.Code
  18875. data["dept_code"] = department.Number
  18876. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  18877. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  18878. data["secret_key"] = miConfig.SecretKey
  18879. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  18880. data["url"] = miConfig.Url
  18881. data["ak"] = miConfig.AccessKey
  18882. data["new_doctor_name"] = patientPrescription.Doctor
  18883. data["diag_code"] = sickConfig.CountryCode
  18884. data["cainfo"] = miConfig.Cainfo
  18885. data["opter"] = roles.UserName
  18886. var ids []int64
  18887. for _, item := range prescriptions {
  18888. ids = append(ids, item.ID)
  18889. }
  18890. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  18891. if config.IsOpen == 1 { //对接了医保,走医保流程
  18892. var res ResultFour
  18893. var resFour10265 ResultFour10265
  18894. if miConfig.MdtrtareaAdmvs == "421300" {
  18895. bytesData, _ := json.Marshal(data)
  18896. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  18897. resp, _ := client.Do(req)
  18898. defer resp.Body.Close()
  18899. body, ioErr := ioutil.ReadAll(resp.Body)
  18900. if ioErr != nil {
  18901. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  18902. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18903. return
  18904. }
  18905. var respJSON map[string]interface{}
  18906. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  18907. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18908. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18909. return
  18910. }
  18911. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  18912. userJSONBytes, _ := json.Marshal(respJSON)
  18913. fmt.Println("log")
  18914. fmt.Println(string(userJSONBytes))
  18915. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  18916. utils.ErrorLog("解析失败:%v", err)
  18917. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18918. return
  18919. }
  18920. } else if miConfig.MdtrtareaAdmvs == "420200" {
  18921. bytesData, _ := json.Marshal(data)
  18922. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  18923. resp, _ := client.Do(req)
  18924. defer resp.Body.Close()
  18925. body, ioErr := ioutil.ReadAll(resp.Body)
  18926. if ioErr != nil {
  18927. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  18928. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18929. return
  18930. }
  18931. var respJSON map[string]interface{}
  18932. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  18933. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18934. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18935. return
  18936. }
  18937. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  18938. userJSONBytes, _ := json.Marshal(respJSON)
  18939. fmt.Println("log")
  18940. fmt.Println(string(userJSONBytes))
  18941. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  18942. utils.ErrorLog("解析失败:%v", err)
  18943. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18944. return
  18945. }
  18946. } else if miConfig.MdtrtareaAdmvs == "420902" {
  18947. bytesData, _ := json.Marshal(data)
  18948. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2204", bytes.NewReader(bytesData))
  18949. resp, _ := client.Do(req)
  18950. defer resp.Body.Close()
  18951. body, ioErr := ioutil.ReadAll(resp.Body)
  18952. if ioErr != nil {
  18953. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  18954. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18955. return
  18956. }
  18957. var respJSON map[string]interface{}
  18958. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  18959. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18960. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18961. return
  18962. }
  18963. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  18964. userJSONBytes, _ := json.Marshal(respJSON)
  18965. fmt.Println("log")
  18966. fmt.Println(string(userJSONBytes))
  18967. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  18968. utils.ErrorLog("解析失败:%v", err)
  18969. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18970. return
  18971. }
  18972. }else if miConfig.MdtrtareaAdmvs == "421182" {
  18973. bytesData, _ := json.Marshal(data)
  18974. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2204", bytes.NewReader(bytesData))
  18975. resp, _ := client.Do(req)
  18976. defer resp.Body.Close()
  18977. body, ioErr := ioutil.ReadAll(resp.Body)
  18978. if ioErr != nil {
  18979. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  18980. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18981. return
  18982. }
  18983. var respJSON map[string]interface{}
  18984. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  18985. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18986. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18987. return
  18988. }
  18989. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  18990. userJSONBytes, _ := json.Marshal(respJSON)
  18991. fmt.Println("log")
  18992. fmt.Println(string(userJSONBytes))
  18993. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  18994. utils.ErrorLog("解析失败:%v", err)
  18995. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18996. return
  18997. }
  18998. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  18999. result3101 := Check3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  19000. if result3101.Infcode == "0" {
  19001. if len(result3101.Output.Result) > 0 {
  19002. var errMsgs []string
  19003. for _, item := range result3101.Output.Result {
  19004. errMsgs = append(errMsgs, item.VolaCont)
  19005. }
  19006. c.ServeSuccessJSON(map[string]interface{}{
  19007. "failed_code": -10,
  19008. "msg": errMsgs,
  19009. })
  19010. return
  19011. }
  19012. }
  19013. bytesData, _ := json.Marshal(data)
  19014. var req *http.Request
  19015. if miConfig.MdtrtareaAdmvs == "320921" {
  19016. data["diag_code"] = sickConfig.CountryCode
  19017. fmt.Println(data)
  19018. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  19019. } else {
  19020. data["diag_code"] = sickConfig.CountryCode
  19021. fmt.Println(data)
  19022. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  19023. }
  19024. resp, _ := client.Do(req)
  19025. defer resp.Body.Close()
  19026. body, ioErr := ioutil.ReadAll(resp.Body)
  19027. if ioErr != nil {
  19028. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19029. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19030. return
  19031. }
  19032. var respJSON map[string]interface{}
  19033. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  19034. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19035. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19036. return
  19037. }
  19038. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  19039. userJSONBytes, _ := json.Marshal(respJSON)
  19040. fmt.Println("log")
  19041. fmt.Println(string(userJSONBytes))
  19042. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  19043. utils.ErrorLog("解析失败:%v", err)
  19044. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19045. return
  19046. }
  19047. res.InfRefmsgid = resFour10265.InfRefmsgid
  19048. res.Output = resFour10265.Output
  19049. res.ErrMsg = resFour10265.ErrMsg
  19050. res.Cainfo = resFour10265.Cainfo
  19051. res.WarnMsg = resFour10265.WarnMsg
  19052. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  19053. res.Infcode = infocode
  19054. } else if miConfig.MdtrtareaAdmvs == "150499" {
  19055. var pagesize int = 2
  19056. var start int = 1
  19057. var stop int
  19058. var pagecount int
  19059. var curpage int
  19060. var isSuccess bool = true
  19061. data["doctor_id"] = doctor_info.DoctorNumber
  19062. //总页数,向上取整,注意除之前要先转换类型为float64
  19063. pagecount = int(math.Ceil(float64(len(prescriptions)) / float64(pagesize)))
  19064. for curpage = 1; curpage <= pagecount; curpage++ {
  19065. if curpage == 1 {
  19066. start = 1
  19067. } else {
  19068. start = (curpage-1)*pagesize + 1
  19069. }
  19070. stop = curpage * pagesize
  19071. if stop > len(prescriptions) {
  19072. stop = len(prescriptions)
  19073. }
  19074. //var requestLog string
  19075. data["pre"] = prescriptions[start-1 : stop]
  19076. fmt.Println(data["pre"])
  19077. bytesData, _ := json.Marshal(data)
  19078. var req *http.Request
  19079. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2204", bytes.NewReader(bytesData))
  19080. resp, _ := client.Do(req)
  19081. defer resp.Body.Close()
  19082. body, ioErr := ioutil.ReadAll(resp.Body)
  19083. if ioErr != nil {
  19084. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19085. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19086. return
  19087. }
  19088. var respJSON map[string]interface{}
  19089. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  19090. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19091. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19092. return
  19093. }
  19094. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  19095. userJSONBytes, _ := json.Marshal(respJSON)
  19096. fmt.Println("log")
  19097. fmt.Println(string(userJSONBytes))
  19098. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  19099. utils.ErrorLog("解析失败:%v", err)
  19100. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19101. return
  19102. }
  19103. res.InfRefmsgid = resFour10265.InfRefmsgid
  19104. res.Output = resFour10265.Output
  19105. res.ErrMsg = resFour10265.ErrMsg
  19106. res.Cainfo = resFour10265.Cainfo
  19107. res.WarnMsg = resFour10265.WarnMsg
  19108. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  19109. res.Infcode = infocode
  19110. if infocode == 0 {
  19111. res.Output.Result = append(res.Output.Result, res.Output.Result...)
  19112. } else {
  19113. isSuccess = false
  19114. errlog := &models.HisOrderError{
  19115. UserOrgId: adminUser.CurrentOrgId,
  19116. Ctime: time.Now().Unix(),
  19117. Mtime: time.Now().Unix(),
  19118. Number: chrg_bchno,
  19119. ErrMsg: "",
  19120. Status: 1,
  19121. PatientId: id,
  19122. RecordTime: recordDateTime,
  19123. Stage: 4,
  19124. }
  19125. service.CreateErrMsgLog(errlog)
  19126. c.ServeSuccessJSON(map[string]interface{}{
  19127. "failed_code": -10,
  19128. "msg": res.ErrMsg,
  19129. })
  19130. return
  19131. }
  19132. }
  19133. if isSuccess {
  19134. res.Infcode = 0
  19135. }
  19136. } else if miConfig.MdtrtareaAdmvs == "350500" {
  19137. 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)
  19138. var dat map[string]interface{}
  19139. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  19140. fmt.Println(dat)
  19141. } else {
  19142. fmt.Println(err)
  19143. }
  19144. saveLog(result, request_log, "2204", "上传费用明细")
  19145. userJSONBytes, _ := json.Marshal(dat)
  19146. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  19147. utils.ErrorLog("解析失败:%v", err)
  19148. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19149. return
  19150. }
  19151. res.InfRefmsgid = resFour10265.InfRefmsgid
  19152. res.Output = resFour10265.Output
  19153. res.ErrMsg = resFour10265.ErrMsg
  19154. res.Cainfo = resFour10265.Cainfo
  19155. res.WarnMsg = resFour10265.WarnMsg
  19156. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  19157. res.Infcode = infocode
  19158. } else if miConfig.MdtrtareaAdmvs == "441799" {
  19159. bytesData, _ := json.Marshal(data)
  19160. req, _ := http.NewRequest("POST", miConfig.Url+"gdyb/2204", bytes.NewReader(bytesData))
  19161. resp, _ := client.Do(req)
  19162. defer resp.Body.Close()
  19163. body, ioErr := ioutil.ReadAll(resp.Body)
  19164. if ioErr != nil {
  19165. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19166. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19167. return
  19168. }
  19169. var respJSON map[string]interface{}
  19170. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  19171. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19172. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19173. return
  19174. }
  19175. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  19176. userJSONBytes, _ := json.Marshal(respJSON)
  19177. fmt.Println("log")
  19178. fmt.Println(string(userJSONBytes))
  19179. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19180. utils.ErrorLog("解析失败:%v", err)
  19181. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19182. return
  19183. }
  19184. } else {
  19185. if miConfig.Code == "H15049901371" {
  19186. 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)
  19187. var dat map[string]interface{}
  19188. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  19189. fmt.Println(dat)
  19190. } else {
  19191. fmt.Println(err)
  19192. }
  19193. saveLog(result, request_log, "2204", "上传费用明细")
  19194. userJSONBytes, _ := json.Marshal(dat)
  19195. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  19196. utils.ErrorLog("解析失败:%v", err)
  19197. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19198. return
  19199. }
  19200. res.InfRefmsgid = resFour10265.InfRefmsgid
  19201. res.Output = resFour10265.Output
  19202. res.ErrMsg = resFour10265.ErrMsg
  19203. res.Cainfo = resFour10265.Cainfo
  19204. res.WarnMsg = resFour10265.WarnMsg
  19205. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  19206. res.Infcode = infocode
  19207. } else {
  19208. 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)
  19209. var dat map[string]interface{}
  19210. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  19211. fmt.Println(dat)
  19212. } else {
  19213. fmt.Println(err)
  19214. }
  19215. saveLog(result, request_log, "2204", "上传费用明细")
  19216. userJSONBytes, _ := json.Marshal(dat)
  19217. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19218. utils.ErrorLog("解析失败:%v", err)
  19219. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19220. return
  19221. }
  19222. }
  19223. }
  19224. if res.Infcode == 0 {
  19225. order := &models.HisOrder{
  19226. UserOrgId: adminUser.CurrentOrgId,
  19227. HisPatientId: his.ID,
  19228. PatientId: his.PatientId,
  19229. SettleAccountsDate: recordDateTime,
  19230. MdtrtId: his.Number,
  19231. PsnNo: his.PsnNo,
  19232. MedType: strconv.FormatInt(reg_type, 10),
  19233. Ctime: time.Now().Unix(),
  19234. Mtime: time.Now().Unix(),
  19235. Status: 1,
  19236. Number: chrg_bchno,
  19237. Infcode: res.Infcode,
  19238. WarnMsg: res.WarnMsg,
  19239. Cainfo: res.Cainfo,
  19240. ErrMsg: res.ErrMsg,
  19241. RespondTime: res.RefmsgTime,
  19242. InfRefmsgid: res.InfRefmsgid,
  19243. OrderStatus: 1,
  19244. PayWay: pay_way,
  19245. PayWays: pay_ways,
  19246. OthDesc: oth_desc,
  19247. PayPrice: pay_price,
  19248. PayCardNo: pay_card_no,
  19249. DiscountPrice: discount_price,
  19250. PreferentialPrice: preferential_price,
  19251. RealityPrice: reality_price,
  19252. FoundPrice: found_price,
  19253. MedicalInsurancePrice: medical_insurance_price,
  19254. PrivatePrice: private_price,
  19255. IsMedicineInsurance: 1,
  19256. SettleType: settle_accounts_type,
  19257. SettleStartTime: start_time,
  19258. SettleEndTime: end_time,
  19259. Creator: roles.AdminUserId,
  19260. Modify: roles.AdminUserId,
  19261. FaPiaoNumber: fapiao_number,
  19262. FaPiaoCode: fapiao_code,
  19263. PType: 2,
  19264. Diagnosis: diagnosis_id,
  19265. CashPay: cash_pay,
  19266. WechatPay: wechat_pay,
  19267. AliPay: ali_pay,
  19268. JifenPay: jifen_pay,
  19269. BandCardPay: band_card_pay,
  19270. }
  19271. err = service.CreateOrder(order)
  19272. if err != nil {
  19273. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  19274. return
  19275. }
  19276. for _, item := range res.Output.Result {
  19277. temp := strings.Split(item.FeedetlSn, "-")
  19278. var advice_id int64 = 0
  19279. var project_id int64 = 0
  19280. var types int64 = 0
  19281. id, _ := strconv.ParseInt(temp[2], 10, 64)
  19282. types, _ = strconv.ParseInt(temp[1], 10, 64)
  19283. if temp[1] == "1" {
  19284. advice_id = id
  19285. project_id = 0
  19286. } else if temp[1] == "2" {
  19287. advice_id = 0
  19288. project_id = id
  19289. }
  19290. if item.MedChrgitmType == "9" {
  19291. item.MedChrgitmType = "09"
  19292. }
  19293. info := &models.HisOrderInfo{
  19294. OrderNumber: order.Number,
  19295. FeedetlSn: item.FeedetlSn,
  19296. UploadDate: time.Now().Unix(),
  19297. AdviceId: advice_id,
  19298. DetItemFeeSumamt: item.DetItemFeeSumamt,
  19299. Cnt: item.Cnt,
  19300. Pric: float64(item.Pric),
  19301. PatientId: his.PatientId,
  19302. PricUplmtAmt: item.PricUplmtAmt,
  19303. SelfpayProp: item.SelfpayProp,
  19304. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  19305. OverlmtAmt: item.OverlmtAmt,
  19306. PreselfpayAmt: item.PreselfpayAmt,
  19307. BasMednFlag: item.BasMednFlag,
  19308. MedChrgitmType: item.MedChrgitmType,
  19309. HiNegoDrugFlag: item.HiNegoDrugFlag,
  19310. Status: 1,
  19311. Memo: item.Memo,
  19312. Mtime: time.Now().Unix(),
  19313. InscpScpAmt: item.InscpScpAmt,
  19314. DrtReimFlag: item.DrtReimFlag,
  19315. Ctime: time.Now().Unix(),
  19316. ListSpItemFlag: item.ListSpItemFlag,
  19317. ChldMedcFlag: item.ChldMedcFlag,
  19318. LmtUsedFlag: item.LmtUsedFlag,
  19319. ChrgitmLv: item.ChrgitmLv,
  19320. UserOrgId: adminUser.CurrentOrgId,
  19321. HisPatientId: his.ID,
  19322. OrderId: order.ID,
  19323. ProjectId: project_id,
  19324. Type: types,
  19325. }
  19326. service.CreateOrderInfo(info)
  19327. }
  19328. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  19329. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  19330. var total float64
  19331. for _, item := range prescriptions {
  19332. if item.Type == 1 { //药品
  19333. for _, subItem := range item.HisDoctorAdviceInfo {
  19334. price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  19335. total_one := price * subItem.PrescribingNumber
  19336. total = total + total_one
  19337. }
  19338. }
  19339. if item.Type == 2 { //项目
  19340. for _, subItem := range item.HisPrescriptionProject {
  19341. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  19342. price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  19343. total_one := price * cnt
  19344. total = total + total_one
  19345. }
  19346. }
  19347. }
  19348. allTotal := fmt.Sprintf("%.2f", total)
  19349. //if adminUser.CurrentOrgId == 9919 {
  19350. //
  19351. // allTotal = fmt.Sprintf("%.2f", total)
  19352. //
  19353. //} else {
  19354. //
  19355. // allTotal = fmt.Sprintf("%.2f", total)
  19356. //
  19357. //}
  19358. if res.Infcode == 0 {
  19359. var rf []*ResultFive
  19360. json.Unmarshal([]byte(his.Iinfo), &rf)
  19361. chrg_bchno := chrg_bchno
  19362. cert_no := his.Certno
  19363. var insutypes []string
  19364. var insutype string
  19365. var is390 int = 0
  19366. var is310 int = 0
  19367. for _, item := range rf {
  19368. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  19369. insutypes = append(insutypes, item.Insutype)
  19370. }
  19371. }
  19372. if len(insutypes) == 1 {
  19373. insutype = insutypes[0]
  19374. } else {
  19375. for _, i := range insutypes {
  19376. if i == "390" {
  19377. is390 = 1
  19378. }
  19379. if i == "310" {
  19380. is310 = 1
  19381. }
  19382. }
  19383. }
  19384. if is390 == 1 {
  19385. insutype = "390"
  19386. }
  19387. if is310 == 1 {
  19388. insutype = "310"
  19389. }
  19390. if len(insutypes) == 0 {
  19391. insutype = "310"
  19392. }
  19393. if len(insutypes) == 2 {
  19394. insutype = strconv.FormatInt(his.SocialType, 10)
  19395. }
  19396. insutype = strconv.FormatInt(his.SocialType, 10)
  19397. //insutype = "390"
  19398. if his.IdCardType == 1 {
  19399. // cert_no = his.MedicalInsuranceNumber
  19400. cert_no = his.Certno
  19401. } else {
  19402. cert_no = his.Certno
  19403. }
  19404. var res ResultSeven
  19405. var resSeven10265 ResultSeven10265
  19406. var gzresSeven10265Two GZResultSeven10265Two
  19407. var src_resquest string
  19408. var result2 string
  19409. if miConfig.MdtrtareaAdmvs == "421300" {
  19410. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  19411. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  19412. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  19413. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  19414. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  19415. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  19416. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  19417. resp, requestErr := http.Get(api)
  19418. if requestErr != nil {
  19419. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19420. return
  19421. }
  19422. body, ioErr := ioutil.ReadAll(resp.Body)
  19423. if ioErr != nil {
  19424. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19425. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19426. return
  19427. }
  19428. var respJSON map[string]interface{}
  19429. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  19430. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19431. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19432. return
  19433. }
  19434. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  19435. result, _ := json.Marshal(respJSON)
  19436. if miConfig.Code == "H15049901371" {
  19437. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  19438. utils.ErrorLog("解析失败:%v", err)
  19439. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19440. return
  19441. }
  19442. res.InfRefmsgid = resSeven10265.InfRefmsgid
  19443. res.Output = resSeven10265.Output
  19444. res.ErrMsg = resSeven10265.ErrMsg
  19445. res.Cainfo = resSeven10265.Cainfo
  19446. res.WarnMsg = resSeven10265.WarnMsg
  19447. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  19448. res.Infcode = infocode
  19449. } else {
  19450. if err := json.Unmarshal([]byte(result), &res); err != nil {
  19451. utils.ErrorLog("解析失败:%v", err)
  19452. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19453. return
  19454. }
  19455. }
  19456. } else if miConfig.MdtrtareaAdmvs == "420200" {
  19457. if reg_type == 11 && his.Insutype == "390" {
  19458. reg_type = 110104
  19459. }
  19460. api := "http://192.168.0.197:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  19461. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  19462. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  19463. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  19464. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  19465. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  19466. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  19467. resp, requestErr := http.Get(api)
  19468. if requestErr != nil {
  19469. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19470. return
  19471. }
  19472. body, ioErr := ioutil.ReadAll(resp.Body)
  19473. if ioErr != nil {
  19474. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19475. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19476. return
  19477. }
  19478. var respJSON map[string]interface{}
  19479. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  19480. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19481. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19482. return
  19483. }
  19484. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  19485. result, _ := json.Marshal(respJSON)
  19486. if miConfig.Code == "H15049901371" {
  19487. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  19488. utils.ErrorLog("解析失败:%v", err)
  19489. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19490. return
  19491. }
  19492. res.InfRefmsgid = resSeven10265.InfRefmsgid
  19493. res.Output = resSeven10265.Output
  19494. res.ErrMsg = resSeven10265.ErrMsg
  19495. res.Cainfo = resSeven10265.Cainfo
  19496. res.WarnMsg = resSeven10265.WarnMsg
  19497. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  19498. res.Infcode = infocode
  19499. } else {
  19500. if err := json.Unmarshal([]byte(result), &res); err != nil {
  19501. utils.ErrorLog("解析失败:%v", err)
  19502. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19503. return
  19504. }
  19505. }
  19506. } else if miConfig.MdtrtareaAdmvs == "420902" {
  19507. if reg_type == 11 && his.Insutype == "390" {
  19508. reg_type = 110104
  19509. }
  19510. api := miConfig.Url+ "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  19511. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  19512. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  19513. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  19514. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  19515. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  19516. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  19517. resp, requestErr := http.Get(api)
  19518. if requestErr != nil {
  19519. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19520. return
  19521. }
  19522. body, ioErr := ioutil.ReadAll(resp.Body)
  19523. if ioErr != nil {
  19524. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19525. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19526. return
  19527. }
  19528. var respJSON map[string]interface{}
  19529. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  19530. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19531. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19532. return
  19533. }
  19534. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  19535. result, _ := json.Marshal(respJSON)
  19536. if miConfig.Code == "H15049901371" {
  19537. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  19538. utils.ErrorLog("解析失败:%v", err)
  19539. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19540. return
  19541. }
  19542. res.InfRefmsgid = resSeven10265.InfRefmsgid
  19543. res.Output = resSeven10265.Output
  19544. res.ErrMsg = resSeven10265.ErrMsg
  19545. res.Cainfo = resSeven10265.Cainfo
  19546. res.WarnMsg = resSeven10265.WarnMsg
  19547. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  19548. res.Infcode = infocode
  19549. } else {
  19550. if err := json.Unmarshal([]byte(result), &res); err != nil {
  19551. utils.ErrorLog("解析失败:%v", err)
  19552. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19553. return
  19554. }
  19555. }
  19556. } else if miConfig.MdtrtareaAdmvs == "421182" {
  19557. if reg_type == 11 && his.Insutype == "390" {
  19558. reg_type = 110104
  19559. }
  19560. api := miConfig.Url + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  19561. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  19562. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  19563. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  19564. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  19565. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  19566. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  19567. resp, requestErr := http.Get(api)
  19568. if requestErr != nil {
  19569. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19570. return
  19571. }
  19572. body, ioErr := ioutil.ReadAll(resp.Body)
  19573. if ioErr != nil {
  19574. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19575. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19576. return
  19577. }
  19578. var respJSON map[string]interface{}
  19579. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  19580. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19581. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19582. return
  19583. }
  19584. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  19585. result, _ := json.Marshal(respJSON)
  19586. if miConfig.Code == "H15049901371" {
  19587. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  19588. utils.ErrorLog("解析失败:%v", err)
  19589. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19590. return
  19591. }
  19592. res.InfRefmsgid = resSeven10265.InfRefmsgid
  19593. res.Output = resSeven10265.Output
  19594. res.ErrMsg = resSeven10265.ErrMsg
  19595. res.Cainfo = resSeven10265.Cainfo
  19596. res.WarnMsg = resSeven10265.WarnMsg
  19597. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  19598. res.Infcode = infocode
  19599. } else {
  19600. if err := json.Unmarshal([]byte(result), &res); err != nil {
  19601. utils.ErrorLog("解析失败:%v", err)
  19602. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19603. return
  19604. }
  19605. }
  19606. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  19607. result3101 := Check3102(c, id, his_patient_id, admin_user_id, "7", order.ID)
  19608. if result3101.Infcode == "0" {
  19609. if len(result3101.Output.Result) > 0 {
  19610. var errMsgs []string
  19611. for _, item := range result3101.Output.Result {
  19612. errMsgs = append(errMsgs, item.VolaCont)
  19613. }
  19614. c.ServeSuccessJSON(map[string]interface{}{
  19615. "failed_code": -10,
  19616. "msg": errMsgs,
  19617. })
  19618. return
  19619. } else {
  19620. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  19621. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  19622. bas := strings.Split(psn_info.CardInfo, "|")
  19623. if his.IdCardType == 1 {
  19624. cert_no = bas[2]
  19625. } else if his.IdCardType == 3 {
  19626. cert_no = his.Certno
  19627. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  19628. } else if his.IdCardType == 4 {
  19629. cert_no = his.Certno
  19630. psn_info.VerifyNumber = psn_info.VerifyNumber
  19631. }
  19632. var api string
  19633. if miConfig.MdtrtareaAdmvs == "320921" {
  19634. api = "http://192.168.2.3:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  19635. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  19636. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  19637. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  19638. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  19639. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  19640. "&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
  19641. } else {
  19642. api = "http://192.168.5.251:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  19643. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  19644. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  19645. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  19646. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  19647. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  19648. "&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
  19649. }
  19650. resp, requestErr := http.Get(api)
  19651. if requestErr != nil {
  19652. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19653. return
  19654. }
  19655. body, ioErr := ioutil.ReadAll(resp.Body)
  19656. if ioErr != nil {
  19657. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19658. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19659. return
  19660. }
  19661. var respJSON map[string]interface{}
  19662. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  19663. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19664. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19665. return
  19666. }
  19667. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  19668. result, _ := json.Marshal(respJSON)
  19669. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  19670. utils.ErrorLog("解析失败:%v", err)
  19671. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19672. return
  19673. }
  19674. res.InfRefmsgid = resSeven10265.InfRefmsgid
  19675. res.Output = resSeven10265.Output
  19676. res.ErrMsg = resSeven10265.ErrMsg
  19677. res.Cainfo = resSeven10265.Cainfo
  19678. res.WarnMsg = resSeven10265.WarnMsg
  19679. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  19680. res.Infcode = infocode
  19681. }
  19682. }
  19683. } else if miConfig.MdtrtareaAdmvs == "150499" {
  19684. psn_info, _ := service.GetPsnByPatientId(id)
  19685. var verify_number string
  19686. if psn_info.IdCardType == 4 {
  19687. verify_number = psn_info.VerifyNumber
  19688. } else if psn_info.IdCardType == 1 {
  19689. bas := strings.Split(psn_info.CardInfo, "|")
  19690. cardNumber := bas[2]
  19691. verify_number = cardNumber
  19692. } else {
  19693. psn_info.IdCardType = 2
  19694. verify_number = psn_info.Certno
  19695. }
  19696. var api string
  19697. api = "http://172.16.13.254:9532/" + "nmyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  19698. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  19699. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  19700. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  19701. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  19702. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  19703. "&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
  19704. resp, requestErr := http.Get(api)
  19705. if requestErr != nil {
  19706. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19707. return
  19708. }
  19709. body, ioErr := ioutil.ReadAll(resp.Body)
  19710. if ioErr != nil {
  19711. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19712. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19713. return
  19714. }
  19715. var respJSON map[string]interface{}
  19716. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  19717. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19718. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19719. return
  19720. }
  19721. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  19722. result, _ := json.Marshal(respJSON)
  19723. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  19724. utils.ErrorLog("解析失败:%v", err)
  19725. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19726. return
  19727. }
  19728. res.InfRefmsgid = resSeven10265.InfRefmsgid
  19729. res.Output = resSeven10265.Output
  19730. res.ErrMsg = resSeven10265.ErrMsg
  19731. res.Cainfo = resSeven10265.Cainfo
  19732. res.WarnMsg = resSeven10265.WarnMsg
  19733. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  19734. res.Infcode = infocode
  19735. } else if miConfig.MdtrtareaAdmvs == "350500" {
  19736. var cert_no string
  19737. if his.IdCardType == 4 {
  19738. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  19739. cert_no = psn_info.VerifyNumber
  19740. 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)
  19741. } else if his.IdCardType == 1 {
  19742. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  19743. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  19744. 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)
  19745. }
  19746. //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)
  19747. var dat map[string]interface{}
  19748. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  19749. fmt.Println(dat)
  19750. } else {
  19751. fmt.Println(err)
  19752. }
  19753. saveLog(result2, src_resquest, "2207", "结算")
  19754. userJSONBytes, _ := json.Marshal(dat)
  19755. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  19756. utils.ErrorLog("解析失败:%v", err)
  19757. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19758. return
  19759. }
  19760. res.InfRefmsgid = resSeven10265.InfRefmsgid
  19761. res.Output = resSeven10265.Output
  19762. res.ErrMsg = resSeven10265.ErrMsg
  19763. res.Cainfo = resSeven10265.Cainfo
  19764. res.WarnMsg = resSeven10265.WarnMsg
  19765. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  19766. res.Infcode = infocode
  19767. } else if miConfig.MdtrtareaAdmvs == "450721" {
  19768. res2 := c.GetoleInfo()
  19769. if res2.Infcode == 0 {
  19770. var result string
  19771. var request_log string
  19772. var result_log string
  19773. if res2.Output.MdtrtCertType == "02" {
  19774. 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)
  19775. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  19776. } else if res2.Output.MdtrtCertType == "01" {
  19777. 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)
  19778. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  19779. } else {
  19780. 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)
  19781. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  19782. }
  19783. var dat map[string]interface{}
  19784. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  19785. fmt.Println(dat)
  19786. } else {
  19787. fmt.Println(err)
  19788. }
  19789. userJSONBytes, _ := json.Marshal(dat)
  19790. var res5 ResultTwo
  19791. //var resTwo10265 ResultTwo10265
  19792. if err := json.Unmarshal(userJSONBytes, &res5); err != nil {
  19793. utils.ErrorLog("解析失败:%v", err)
  19794. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19795. return
  19796. }
  19797. if res5.Infcode == -1 {
  19798. c.ServeSuccessJSON(map[string]interface{}{
  19799. "failed_code": -10,
  19800. "msg": res5.ErrMsg,
  19801. })
  19802. return
  19803. }
  19804. var insutypes []string
  19805. var insutype string
  19806. var is390 int = 0
  19807. var is310 int = 0
  19808. for _, item := range res5.Output.Iinfo {
  19809. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  19810. insutypes = append(insutypes, item.Insutype)
  19811. }
  19812. }
  19813. if len(insutypes) == 1 {
  19814. insutype = insutypes[0]
  19815. } else {
  19816. for _, i := range insutypes {
  19817. if i == "390" {
  19818. is390 = 1
  19819. }
  19820. if i == "310" {
  19821. is310 = 1
  19822. }
  19823. }
  19824. }
  19825. if is390 == 1 {
  19826. insutype = "390"
  19827. }
  19828. if is310 == 1 {
  19829. insutype = "310"
  19830. }
  19831. if len(insutypes) == 0 {
  19832. insutype = "310"
  19833. }
  19834. Iinfos, _ := json.Marshal(res5.Output.Iinfo)
  19835. Idetinfos, _ := json.Marshal(res5.Output.Idetinfo)
  19836. infoStr := string(Iinfos)
  19837. idetinfoStr := string(Idetinfos)
  19838. psn := &models.HisPsn{
  19839. PsnNo: res5.Output.Baseinfo.PsnNo,
  19840. PatientId: id,
  19841. Certno: res5.Output.Baseinfo.Certno,
  19842. Gend: res5.Output.Baseinfo.Gend,
  19843. Naty: res5.Output.Baseinfo.Naty,
  19844. PsnCertType: res5.Output.Baseinfo.PsnCertType,
  19845. PsnName: res5.Output.Baseinfo.PsnName,
  19846. Idetinfo: idetinfoStr,
  19847. Insuinfo: infoStr,
  19848. CardInfo: res2.Output.CardNo + "|" + res2.Output.CardSN,
  19849. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  19850. VerifyNumber: res2.Output.EcToken,
  19851. }
  19852. if res2.Output.MdtrtCertType == "01" {
  19853. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  19854. psn.VerifyNumber = res2.Output.EcToken
  19855. } else if res2.Output.MdtrtCertType == "02" {
  19856. psn.VerifyNumber = res2.Output.CardNo
  19857. } else {
  19858. psn.VerifyNumber = res2.Output.MdtrtCertNo
  19859. }
  19860. service.CreateHisPsn(psn)
  19861. if res2.Output.MdtrtCertType == "01" {
  19862. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  19863. token := res2.Output.EcToken
  19864. 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)
  19865. } else if res2.Output.MdtrtCertType == "02" {
  19866. 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)
  19867. } else {
  19868. 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)
  19869. }
  19870. var dat2 map[string]interface{}
  19871. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  19872. fmt.Println(dat2)
  19873. } else {
  19874. fmt.Println(err)
  19875. }
  19876. userJSONBytes3, _ := json.Marshal(dat2)
  19877. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  19878. utils.ErrorLog("解析失败:%v", err)
  19879. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19880. return
  19881. }
  19882. saveLog(result2, src_resquest, "2207", "结算")
  19883. } else {
  19884. c.ServeSuccessJSON(map[string]interface{}{
  19885. "failed_code": -10,
  19886. "msg": res2.ErrMsg,
  19887. })
  19888. return
  19889. }
  19890. } else {
  19891. if miConfig.Code == "H15049901371" {
  19892. //赤峰地区国家医保医疗类别
  19893. //职工透析:医疗类别选特殊情况门诊990502
  19894. //居民定额血透门慢: 医疗类别选门诊慢病140104
  19895. var med_type string
  19896. if his.Insutype == "390" {
  19897. if reg_type == 14 {
  19898. med_type = "9933"
  19899. } else if reg_type == 11 {
  19900. med_type = "11"
  19901. }
  19902. } else if his.Insutype == "310" {
  19903. if reg_type == 14 {
  19904. med_type = "990502"
  19905. } else if reg_type == 11 {
  19906. med_type = "11"
  19907. }
  19908. }
  19909. 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)
  19910. } else {
  19911. if his.IdCardType == 4 {
  19912. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  19913. var token string
  19914. token = psn_info.VerifyNumber
  19915. 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)
  19916. } else {
  19917. if his.IdCardType == 1 {
  19918. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  19919. bas := strings.Split(psn_info.CardInfo, "|")
  19920. basNumber := bas[2]
  19921. cert_no = basNumber
  19922. }
  19923. 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)
  19924. }
  19925. }
  19926. //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)
  19927. var dat map[string]interface{}
  19928. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  19929. fmt.Println(dat)
  19930. } else {
  19931. fmt.Println(err)
  19932. }
  19933. saveLog(result2, src_resquest, "2207", "结算")
  19934. userJSONBytes, _ := json.Marshal(dat)
  19935. if miConfig.Code == "H15049901371" {
  19936. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  19937. utils.ErrorLog("解析失败:%v", err)
  19938. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19939. return
  19940. }
  19941. res.InfRefmsgid = resSeven10265.InfRefmsgid
  19942. res.Output = resSeven10265.Output
  19943. res.ErrMsg = resSeven10265.ErrMsg
  19944. res.Cainfo = resSeven10265.Cainfo
  19945. res.WarnMsg = resSeven10265.WarnMsg
  19946. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  19947. res.Infcode = infocode
  19948. } else {
  19949. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  19950. if err := json.Unmarshal(userJSONBytes, &gzresSeven10265Two); err != nil {
  19951. utils.ErrorLog("解析失败:%v", err)
  19952. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19953. return
  19954. }
  19955. res.InfRefmsgid = gzresSeven10265Two.InfRefmsgid
  19956. res.Output.Setlinfo.AcctMulaidPay = gzresSeven10265Two.Output.Setlinfo.AcctMulaidPay
  19957. res.Output.Setlinfo.AcctPay = gzresSeven10265Two.Output.Setlinfo.AcctPay
  19958. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  19959. res.Output.Setlinfo.ActPayDedc = gzresSeven10265Two.Output.Setlinfo.ActPayDedc
  19960. res.Output.Setlinfo.Age = gzresSeven10265Two.Output.Setlinfo.Age
  19961. res.Output.Setlinfo.Balc = gzresSeven10265Two.Output.Setlinfo.Balc
  19962. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  19963. res.Output.Setlinfo.Certno = gzresSeven10265Two.Output.Setlinfo.Certno
  19964. res.Output.Setlinfo.ClrOptins = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  19965. res.Output.Setlinfo.ClrType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  19966. res.Output.Setlinfo.ClrWay = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  19967. res.Output.Setlinfo.CvlservFlag = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  19968. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  19969. res.Output.Setlinfo.FulamtOwnpayAmt = gzresSeven10265Two.Output.Setlinfo.FulamtOwnpayAmt
  19970. res.Output.Setlinfo.FundPaySumamt = gzresSeven10265Two.Output.Setlinfo.FundPaySumamt
  19971. res.Output.Setlinfo.Gend = gzresSeven10265Two.Output.Setlinfo.Gend
  19972. res.Output.Setlinfo.HifesPay = gzresSeven10265Two.Output.Setlinfo.HifesPay
  19973. res.Output.Setlinfo.HifmiPay = gzresSeven10265Two.Output.Setlinfo.HifmiPay
  19974. res.Output.Setlinfo.HifpPay = gzresSeven10265Two.Output.Setlinfo.HifpPay
  19975. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  19976. res.Output.Setlinfo.HospPartAmt = gzresSeven10265Two.Output.Setlinfo.HospPartAmt
  19977. res.Output.Setlinfo.InscpScpAmt = gzresSeven10265Two.Output.Setlinfo.InscpScpAmt
  19978. res.Output.Setlinfo.Insutype = gzresSeven10265Two.Output.Setlinfo.Insutype
  19979. res.Output.Setlinfo.MafPay = gzresSeven10265Two.Output.Setlinfo.MafPay
  19980. res.Output.Setlinfo.MdtrtCertType = gzresSeven10265Two.Output.Setlinfo.MdtrtCertType
  19981. res.Output.Setlinfo.HifobPay = gzresSeven10265Two.Output.Setlinfo.HifobPay
  19982. res.Output.Setlinfo.MdtrtID = gzresSeven10265Two.Output.Setlinfo.MdtrtID
  19983. res.Output.Setlinfo.MedType = gzresSeven10265Two.Output.Setlinfo.MedType
  19984. res.Output.Setlinfo.MedfeeSumamt = gzresSeven10265Two.Output.Setlinfo.MedfeeSumamt
  19985. res.Output.Setlinfo.MedinsSetlID = gzresSeven10265Two.Output.Setlinfo.MedinsSetlID
  19986. res.Output.Setlinfo.Naty = gzresSeven10265Two.Output.Setlinfo.Naty
  19987. res.Output.Setlinfo.OthPay = gzresSeven10265Two.Output.Setlinfo.OthPay
  19988. res.Output.Setlinfo.OverlmtSelfpay = gzresSeven10265Two.Output.Setlinfo.OverlmtSelfpay
  19989. PoolPropSelfpay, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.PoolPropSelfpay, 64)
  19990. res.Output.Setlinfo.PoolPropSelfpay = PoolPropSelfpay
  19991. res.Output.Setlinfo.PreselfpayAmt = gzresSeven10265Two.Output.Setlinfo.PreselfpayAmt
  19992. res.Output.Setlinfo.PsnCashPay = gzresSeven10265Two.Output.Setlinfo.PsnCashPay
  19993. res.Output.Setlinfo.PsnCertType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  19994. res.Output.Setlinfo.PsnName = gzresSeven10265Two.Output.Setlinfo.PsnName
  19995. res.Output.Setlinfo.PsnNo = gzresSeven10265Two.Output.Setlinfo.PsnNo
  19996. res.Output.Setlinfo.PsnPartAmt = gzresSeven10265Two.Output.Setlinfo.PsnPartAmt
  19997. res.Output.Setlinfo.PsnType = gzresSeven10265Two.Output.Setlinfo.PsnType
  19998. res.Output.Setlinfo.SetlID = gzresSeven10265Two.Output.Setlinfo.SetlID
  19999. res.Output.Setlinfo.SetlTime = gzresSeven10265Two.Output.Setlinfo.SetlTime
  20000. //res.Output.Setldetail = gzresSeven10265Two.Output.Setldetail
  20001. res.ErrMsg = gzresSeven10265Two.ErrMsg
  20002. res.Cainfo = gzresSeven10265Two.Cainfo
  20003. res.WarnMsg = gzresSeven10265Two.WarnMsg
  20004. //infocode, _ := strconv.ParseInt(resSeven10265Two.Infcode, 10, 64)
  20005. //res.Infcode = infocode
  20006. } else {
  20007. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20008. utils.ErrorLog("解析失败:%v", err)
  20009. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20010. return
  20011. }
  20012. }
  20013. }
  20014. }
  20015. if res.Infcode == -1 {
  20016. errlog := &models.HisOrderError{
  20017. UserOrgId: adminUser.CurrentOrgId,
  20018. Ctime: time.Now().Unix(),
  20019. Mtime: time.Now().Unix(),
  20020. Number: chrg_bchno,
  20021. ErrMsg: res.ErrMsg,
  20022. Status: 1,
  20023. PatientId: id,
  20024. RecordTime: recordDateTime,
  20025. Stage: 6,
  20026. }
  20027. service.CreateErrMsgLog(errlog)
  20028. c.ServeSuccessJSON(map[string]interface{}{
  20029. "failed_code": -10,
  20030. "msg": res.ErrMsg,
  20031. })
  20032. return
  20033. } else {
  20034. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  20035. order.OrderStatus = 2
  20036. order.Status = 1
  20037. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  20038. order.SetlId = res.Output.Setlinfo.SetlID
  20039. order.PsnNo = res.Output.Setlinfo.PsnNo
  20040. order.PsnName = res.Output.Setlinfo.PsnName
  20041. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  20042. order.Certno = res.Output.Setlinfo.Certno
  20043. order.Gend = res.Output.Setlinfo.Gend
  20044. order.Naty = res.Output.Setlinfo.Naty
  20045. order.Age = res.Output.Setlinfo.Age
  20046. order.Insutype = res.Output.Setlinfo.Insutype
  20047. order.PsnType = res.Output.Setlinfo.PsnType
  20048. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  20049. order.SetlTime = res.Output.Setlinfo.SetlTime
  20050. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  20051. if res.Output.Setlinfo.MedType == "140101" {
  20052. order.MedType = "14"
  20053. } else {
  20054. if res.Output.Setlinfo.MedType == "110104" {
  20055. order.MedType = "11"
  20056. } else {
  20057. order.MedType = res.Output.Setlinfo.MedType
  20058. }
  20059. }
  20060. if reg_type == 1112 {
  20061. order.MedType = "1112"
  20062. }
  20063. if reg_type == 1111 {
  20064. order.MedType = "1111"
  20065. }
  20066. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  20067. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  20068. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  20069. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  20070. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  20071. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  20072. order.HifpPay = res.Output.Setlinfo.HifpPay
  20073. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  20074. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  20075. order.HifesPay = res.Output.Setlinfo.HifesPay
  20076. order.HifobPay = res.Output.Setlinfo.HifobPay
  20077. order.MafPay = res.Output.Setlinfo.MafPay
  20078. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  20079. order.OthPay = res.Output.Setlinfo.OthPay
  20080. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  20081. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  20082. order.AcctPay = res.Output.Setlinfo.AcctPay
  20083. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  20084. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  20085. order.Balc = res.Output.Setlinfo.Balc
  20086. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  20087. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  20088. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  20089. order.ClrType = res.Output.Setlinfo.ClrType
  20090. order.ClrWay = res.Output.Setlinfo.ClrWay
  20091. order.Creator = order.Creator
  20092. order.Modify = roles.AdminUserId
  20093. order.RequestLog = src_resquest
  20094. order.FaPiaoNumber = fapiao_number
  20095. order.FaPiaoCode = fapiao_code
  20096. //setlDetail, _ := json.Marshal(res.Output.Setldetail)
  20097. //detailStr := string(setlDetail)
  20098. //order.SetlDetail = detailStr
  20099. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  20100. err = service.UpDateOrder(order)
  20101. if err == nil {
  20102. //判断是否使用了押金
  20103. if dec_way == "true" {
  20104. tmpstring := strconv.FormatInt(order.ID, 10)
  20105. order.Decimal = decimal
  20106. service.UpDateOrder(order)
  20107. //扣押金
  20108. errmsg = service.SpendDeposit(c.GetAdminUserInfo().CurrentOrgId, id, c.GetAdminUserInfo().AdminUser.Id, tmpstring, decimal)
  20109. if errmsg != nil {
  20110. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, errmsg.Error())
  20111. return
  20112. }
  20113. }
  20114. c.ServeSuccessJSON(map[string]interface{}{
  20115. "msg": "结算成功",
  20116. })
  20117. } else {
  20118. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  20119. return
  20120. }
  20121. }
  20122. } else {
  20123. adminUser := c.GetAdminUserInfo()
  20124. errlog := &models.HisOrderError{
  20125. UserOrgId: adminUser.CurrentOrgId,
  20126. Ctime: time.Now().Unix(),
  20127. Mtime: time.Now().Unix(),
  20128. ErrMsg: res.ErrMsg,
  20129. Status: 1,
  20130. PatientId: id,
  20131. RecordTime: recordDateTime,
  20132. Stage: 4,
  20133. }
  20134. service.CreateErrMsgLog(errlog)
  20135. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  20136. return
  20137. }
  20138. } else {
  20139. adminUser := c.GetAdminUserInfo()
  20140. errlog := &models.HisOrderError{
  20141. UserOrgId: adminUser.CurrentOrgId,
  20142. Ctime: time.Now().Unix(),
  20143. Mtime: time.Now().Unix(),
  20144. ErrMsg: res.ErrMsg,
  20145. Status: 1,
  20146. PatientId: id,
  20147. RecordTime: recordDateTime,
  20148. Stage: 4,
  20149. }
  20150. service.CreateErrMsgLog(errlog)
  20151. c.ServeSuccessJSON(map[string]interface{}{
  20152. "failed_code": -10,
  20153. "msg": res.ErrMsg,
  20154. })
  20155. return
  20156. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  20157. //return
  20158. }
  20159. }
  20160. }
  20161. } else if tempOrder.ID > 0 {
  20162. if tempOrder.IsPre == 1 {
  20163. allTotal := fmt.Sprintf("%.2f", tempOrder.MedfeeSumamt)
  20164. var rf []*ResultFive
  20165. json.Unmarshal([]byte(his.Iinfo), &rf)
  20166. chrg_bchno := tempOrder.Number
  20167. cert_no := his.Certno
  20168. var insutypes []string
  20169. var insutype string
  20170. var is390 int = 0
  20171. var is310 int = 0
  20172. for _, item := range rf {
  20173. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  20174. insutypes = append(insutypes, item.Insutype)
  20175. }
  20176. }
  20177. if len(insutypes) == 1 {
  20178. insutype = insutypes[0]
  20179. } else {
  20180. for _, i := range insutypes {
  20181. if i == "390" {
  20182. is390 = 1
  20183. }
  20184. if i == "310" {
  20185. is310 = 1
  20186. }
  20187. }
  20188. }
  20189. if is390 == 1 {
  20190. insutype = "390"
  20191. }
  20192. if is310 == 1 {
  20193. insutype = "310"
  20194. }
  20195. if len(insutypes) == 0 {
  20196. insutype = "310"
  20197. }
  20198. if len(insutypes) == 2 {
  20199. insutype = strconv.FormatInt(his.SocialType, 10)
  20200. }
  20201. //insutype = "390"
  20202. if his.IdCardType == 1 {
  20203. // cert_no = his.MedicalInsuranceNumber
  20204. cert_no = his.Certno
  20205. } else {
  20206. cert_no = his.Certno
  20207. }
  20208. var res ResultSeven
  20209. var ahres ResultSevenAH
  20210. var resSeven10265 ResultSeven10265
  20211. var gzresSeven10265Two GZResultSeven10265Two
  20212. var src_resquest string
  20213. var result2 string
  20214. if miConfig.MdtrtareaAdmvs == "450721" {
  20215. res2 := c.GetoleInfo()
  20216. if res2.Infcode == 0 {
  20217. var result string
  20218. var request_log string
  20219. var result_log string
  20220. if res2.Output.MdtrtCertType == "02" {
  20221. 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)
  20222. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  20223. } else if res2.Output.MdtrtCertType == "01" {
  20224. 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)
  20225. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  20226. } else {
  20227. 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)
  20228. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  20229. }
  20230. var dat map[string]interface{}
  20231. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  20232. fmt.Println(dat)
  20233. } else {
  20234. fmt.Println(err)
  20235. }
  20236. userJSONBytes, _ := json.Marshal(dat)
  20237. var res5 ResultTwo
  20238. //var resTwo10265 ResultTwo10265
  20239. if err := json.Unmarshal(userJSONBytes, &res5); err != nil {
  20240. utils.ErrorLog("解析失败:%v", err)
  20241. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20242. return
  20243. }
  20244. //utils.ErrorLog("解析失败:%v", res5.Infcode)
  20245. if res5.Infcode == -1 {
  20246. c.ServeSuccessJSON(map[string]interface{}{
  20247. "failed_code": -10,
  20248. "msg": res5.ErrMsg,
  20249. })
  20250. return
  20251. }
  20252. var insutypes []string
  20253. var insutype string
  20254. var is390 int = 0
  20255. var is310 int = 0
  20256. for _, item := range res5.Output.Iinfo {
  20257. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  20258. insutypes = append(insutypes, item.Insutype)
  20259. }
  20260. }
  20261. if len(insutypes) == 1 {
  20262. insutype = insutypes[0]
  20263. } else {
  20264. for _, i := range insutypes {
  20265. if i == "390" {
  20266. is390 = 1
  20267. }
  20268. if i == "310" {
  20269. is310 = 1
  20270. }
  20271. }
  20272. }
  20273. if is390 == 1 {
  20274. insutype = "390"
  20275. }
  20276. if is310 == 1 {
  20277. insutype = "310"
  20278. }
  20279. if len(insutypes) == 0 {
  20280. insutype = "310"
  20281. }
  20282. Iinfos, _ := json.Marshal(res5.Output.Iinfo)
  20283. Idetinfos, _ := json.Marshal(res5.Output.Idetinfo)
  20284. infoStr := string(Iinfos)
  20285. idetinfoStr := string(Idetinfos)
  20286. psn := &models.HisPsn{
  20287. PsnNo: res5.Output.Baseinfo.PsnNo,
  20288. PatientId: id,
  20289. Certno: res5.Output.Baseinfo.Certno,
  20290. Gend: res5.Output.Baseinfo.Gend,
  20291. Naty: res5.Output.Baseinfo.Naty,
  20292. PsnCertType: res5.Output.Baseinfo.PsnCertType,
  20293. PsnName: res5.Output.Baseinfo.PsnName,
  20294. Idetinfo: idetinfoStr,
  20295. Insuinfo: infoStr,
  20296. CardInfo: res2.Output.CardNo + "|" + res2.Output.CardSN,
  20297. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  20298. VerifyNumber: res2.Output.EcToken,
  20299. }
  20300. service.CreateHisPsn(psn)
  20301. if res2.Output.MdtrtCertType == "01" {
  20302. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  20303. token := res2.Output.EcToken
  20304. 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)
  20305. } else if res2.Output.MdtrtCertType == "02" {
  20306. 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)
  20307. } else {
  20308. 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)
  20309. }
  20310. var dat2 map[string]interface{}
  20311. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  20312. fmt.Println(dat2)
  20313. } else {
  20314. fmt.Println(err)
  20315. }
  20316. userJSONBytes3, _ := json.Marshal(dat2)
  20317. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  20318. utils.ErrorLog("解析失败:%v", err)
  20319. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20320. return
  20321. }
  20322. saveLog(result2, src_resquest, "2207", "结算")
  20323. } else {
  20324. c.ServeSuccessJSON(map[string]interface{}{
  20325. "failed_code": -10,
  20326. "msg": res2.ErrMsg,
  20327. })
  20328. return
  20329. }
  20330. } else if miConfig.MdtrtareaAdmvs == "421300" {
  20331. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  20332. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  20333. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  20334. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  20335. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  20336. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  20337. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  20338. resp, requestErr := http.Get(api)
  20339. if requestErr != nil {
  20340. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20341. return
  20342. }
  20343. body, ioErr := ioutil.ReadAll(resp.Body)
  20344. if ioErr != nil {
  20345. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  20346. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20347. return
  20348. }
  20349. var respJSON map[string]interface{}
  20350. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  20351. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  20352. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20353. return
  20354. }
  20355. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  20356. result, _ := json.Marshal(respJSON)
  20357. fmt.Println("log")
  20358. fmt.Println(string(result))
  20359. if err := json.Unmarshal([]byte(result), &res); err != nil {
  20360. utils.ErrorLog("解析失败:%v", err)
  20361. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20362. return
  20363. }
  20364. } else if miConfig.MdtrtareaAdmvs == "420200" {
  20365. if reg_type == 11 && his.Insutype == "390" {
  20366. reg_type = 110104
  20367. }
  20368. api := "http://192.168.0.197:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  20369. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  20370. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  20371. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  20372. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  20373. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  20374. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  20375. resp, requestErr := http.Get(api)
  20376. if requestErr != nil {
  20377. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20378. return
  20379. }
  20380. body, ioErr := ioutil.ReadAll(resp.Body)
  20381. if ioErr != nil {
  20382. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  20383. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20384. return
  20385. }
  20386. var respJSON map[string]interface{}
  20387. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  20388. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  20389. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20390. return
  20391. }
  20392. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  20393. result, _ := json.Marshal(respJSON)
  20394. fmt.Println("log")
  20395. fmt.Println(string(result))
  20396. if err := json.Unmarshal([]byte(result), &res); err != nil {
  20397. utils.ErrorLog("解析失败:%v", err)
  20398. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20399. return
  20400. }
  20401. }else if miConfig.MdtrtareaAdmvs == "420902" {
  20402. if reg_type == 11 && his.Insutype == "390" {
  20403. reg_type = 110104
  20404. }
  20405. api := miConfig.Url + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  20406. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  20407. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  20408. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  20409. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  20410. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  20411. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  20412. resp, requestErr := http.Get(api)
  20413. if requestErr != nil {
  20414. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20415. return
  20416. }
  20417. body, ioErr := ioutil.ReadAll(resp.Body)
  20418. if ioErr != nil {
  20419. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  20420. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20421. return
  20422. }
  20423. var respJSON map[string]interface{}
  20424. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  20425. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  20426. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20427. return
  20428. }
  20429. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  20430. result, _ := json.Marshal(respJSON)
  20431. fmt.Println("log")
  20432. fmt.Println(string(result))
  20433. if err := json.Unmarshal([]byte(result), &res); err != nil {
  20434. utils.ErrorLog("解析失败:%v", err)
  20435. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20436. return
  20437. }
  20438. } else if miConfig.MdtrtareaAdmvs == "421182" {
  20439. if reg_type == 11 && his.Insutype == "390" {
  20440. reg_type = 110104
  20441. }
  20442. api := miConfig.Url + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  20443. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  20444. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  20445. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  20446. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  20447. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  20448. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  20449. resp, requestErr := http.Get(api)
  20450. if requestErr != nil {
  20451. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20452. return
  20453. }
  20454. body, ioErr := ioutil.ReadAll(resp.Body)
  20455. if ioErr != nil {
  20456. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  20457. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20458. return
  20459. }
  20460. var respJSON map[string]interface{}
  20461. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  20462. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  20463. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20464. return
  20465. }
  20466. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  20467. result, _ := json.Marshal(respJSON)
  20468. fmt.Println("log")
  20469. fmt.Println(string(result))
  20470. if err := json.Unmarshal([]byte(result), &res); err != nil {
  20471. utils.ErrorLog("解析失败:%v", err)
  20472. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20473. return
  20474. }
  20475. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  20476. result3101 := Check3102(c, id, his_patient_id, admin_user_id, "7", tempOrder.ID)
  20477. if result3101.Infcode == "0" {
  20478. if len(result3101.Output.Result) > 0 {
  20479. var errMsgs []string
  20480. for _, item := range result3101.Output.Result {
  20481. errMsgs = append(errMsgs, item.VolaCont)
  20482. }
  20483. c.ServeSuccessJSON(map[string]interface{}{
  20484. "failed_code": -10,
  20485. "msg": errMsgs,
  20486. })
  20487. return
  20488. } else {
  20489. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  20490. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  20491. bas := strings.Split(psn_info.CardInfo, "|")
  20492. if his.IdCardType == 1 {
  20493. cert_no = bas[2]
  20494. } else if his.IdCardType == 3 {
  20495. cert_no = his.Certno
  20496. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  20497. } else if his.IdCardType == 4 {
  20498. cert_no = his.Certno
  20499. psn_info.VerifyNumber = psn_info.VerifyNumber
  20500. }
  20501. //江苏地区国家医保医疗类别
  20502. //职工透析:医疗类别选特殊情况门诊9933
  20503. //居民血透门慢: 医疗类别选门诊慢病1402
  20504. //var med_type string
  20505. //if his.Insutype == "310" {
  20506. // if reg_type == 14 {
  20507. // med_type = "9933"
  20508. // } else if reg_type == 11 {
  20509. // med_type = "11"
  20510. //
  20511. // }
  20512. //} else if his.Insutype == "390" {
  20513. // if reg_type == 14 {
  20514. // med_type = "1402"
  20515. // } else if reg_type == 11 {
  20516. // med_type = "11"
  20517. // }
  20518. //}
  20519. var api string
  20520. if miConfig.MdtrtareaAdmvs == "320921" {
  20521. api = "http://192.168.2.3:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  20522. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  20523. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  20524. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  20525. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  20526. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  20527. "&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
  20528. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  20529. } else {
  20530. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  20531. api = "http://192.168.5.251:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  20532. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  20533. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  20534. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  20535. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  20536. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  20537. "&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
  20538. }
  20539. resp, requestErr := http.Get(api)
  20540. if requestErr != nil {
  20541. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20542. return
  20543. }
  20544. body, ioErr := ioutil.ReadAll(resp.Body)
  20545. if ioErr != nil {
  20546. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  20547. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20548. return
  20549. }
  20550. var respJSON map[string]interface{}
  20551. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  20552. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  20553. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20554. return
  20555. }
  20556. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  20557. result, _ := json.Marshal(respJSON)
  20558. fmt.Println("log")
  20559. fmt.Println(string(result))
  20560. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  20561. utils.ErrorLog("解析失败:%v", err)
  20562. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20563. return
  20564. }
  20565. res.InfRefmsgid = resSeven10265.InfRefmsgid
  20566. res.Output = resSeven10265.Output
  20567. res.InfRefmsgid = resSeven10265.InfRefmsgid
  20568. res.ErrMsg = resSeven10265.ErrMsg
  20569. res.Cainfo = resSeven10265.Cainfo
  20570. res.WarnMsg = resSeven10265.WarnMsg
  20571. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  20572. res.Infcode = infocode
  20573. }
  20574. }
  20575. } else if miConfig.MdtrtareaAdmvs == "150499" {
  20576. psn_info, _ := service.GetPsnByPatientId(id)
  20577. var verify_number string
  20578. if psn_info.IdCardType == 4 {
  20579. verify_number = psn_info.VerifyNumber
  20580. } else if psn_info.IdCardType == 1 {
  20581. bas := strings.Split(psn_info.CardInfo, "|")
  20582. cardNumber := bas[2]
  20583. verify_number = cardNumber
  20584. } else {
  20585. verify_number = psn_info.Certno
  20586. psn_info.IdCardType = 2
  20587. }
  20588. var api string
  20589. api = "http://172.16.13.254:9532/" + "nmyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  20590. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  20591. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  20592. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  20593. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(psn_info.IdCardType, 10) +
  20594. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  20595. "&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
  20596. resp, requestErr := http.Get(api)
  20597. if requestErr != nil {
  20598. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20599. return
  20600. }
  20601. body, ioErr := ioutil.ReadAll(resp.Body)
  20602. if ioErr != nil {
  20603. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  20604. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20605. return
  20606. }
  20607. var respJSON map[string]interface{}
  20608. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  20609. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  20610. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20611. return
  20612. }
  20613. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  20614. result, _ := json.Marshal(respJSON)
  20615. fmt.Println("log")
  20616. fmt.Println(string(result))
  20617. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  20618. utils.ErrorLog("解析失败:%v", err)
  20619. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20620. return
  20621. }
  20622. res.InfRefmsgid = resSeven10265.InfRefmsgid
  20623. res.Output = resSeven10265.Output
  20624. res.InfRefmsgid = resSeven10265.InfRefmsgid
  20625. res.ErrMsg = resSeven10265.ErrMsg
  20626. res.Cainfo = resSeven10265.Cainfo
  20627. res.WarnMsg = resSeven10265.WarnMsg
  20628. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  20629. res.Infcode = infocode
  20630. } else if miConfig.MdtrtareaAdmvs == "350500" {
  20631. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  20632. var cert_no string
  20633. if his.IdCardType == 1 {
  20634. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  20635. } else {
  20636. cert_no = psn_info.VerifyNumber
  20637. }
  20638. 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)
  20639. var dat map[string]interface{}
  20640. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  20641. fmt.Println(dat)
  20642. } else {
  20643. fmt.Println(err)
  20644. }
  20645. saveLog(result2, src_resquest, "2207", "结算")
  20646. userJSONBytes, _ := json.Marshal(dat)
  20647. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20648. utils.ErrorLog("解析失败:%v", err)
  20649. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20650. return
  20651. }
  20652. } else if miConfig.MdtrtareaAdmvs == "360302" {
  20653. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  20654. var cert_no string
  20655. var card_sn string
  20656. if his.IdCardType == 1 {
  20657. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  20658. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  20659. bas := strings.Split(psn_info.CardInfo, "|")
  20660. card_sn = bas[3]
  20661. } else if his.IdCardType == 2 {
  20662. cert_no = his.IdCardNo
  20663. } else {
  20664. cert_no = psn_info.VerifyNumber
  20665. }
  20666. var rf []*ResultFive
  20667. json.Unmarshal([]byte(his.Iinfo), &rf)
  20668. var psn_type string
  20669. for _, item := range rf {
  20670. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  20671. psn_type = item.PsnType
  20672. }
  20673. }
  20674. 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)
  20675. var dat map[string]interface{}
  20676. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  20677. fmt.Println(dat)
  20678. } else {
  20679. fmt.Println(err)
  20680. }
  20681. saveLog(result2, src_resquest, "2207", "结算")
  20682. userJSONBytes, _ := json.Marshal(dat)
  20683. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20684. utils.ErrorLog("解析失败:%v", err)
  20685. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20686. return
  20687. }
  20688. } else if miConfig.MdtrtareaAdmvs == "341203" {
  20689. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  20690. if his.IdCardType == 1 {
  20691. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  20692. bas := strings.Split(psn_info.CardInfo, "|")
  20693. cert_no = bas[2]
  20694. } else if his.IdCardType == 3 {
  20695. cert_no = his.Certno
  20696. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  20697. } else if his.IdCardType == 4 {
  20698. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  20699. cert_no = his.Certno
  20700. psn_info.VerifyNumber = psn_info.VerifyNumber
  20701. } else {
  20702. cert_no = his.Certno
  20703. psn_info.VerifyNumber = his.Certno
  20704. }
  20705. var api string
  20706. var med_type string
  20707. if his.Insutype == "390" {
  20708. if reg_type == 992102 {
  20709. med_type = "992102"
  20710. }
  20711. if reg_type == 140104 {
  20712. med_type = "140104"
  20713. }
  20714. if reg_type == 14 {
  20715. med_type = "14"
  20716. }
  20717. } else if his.Insutype == "310" {
  20718. if reg_type == 992102 {
  20719. med_type = "992102"
  20720. }
  20721. if reg_type == 14 {
  20722. med_type = "14"
  20723. }
  20724. }
  20725. api = miConfig.SecretKey + "ahyb/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=" + 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
  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. status := respJSON["data"].(map[string]interface{})["status"].(string)
  20750. if status == "0" {
  20751. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  20752. c.ServeSuccessJSON(map[string]interface{}{
  20753. "failed_code": -10,
  20754. "msg": err_msg,
  20755. })
  20756. return
  20757. }
  20758. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  20759. result, _ := json.Marshal(respJSON)
  20760. fmt.Println("log")
  20761. fmt.Println(string(result))
  20762. if err := json.Unmarshal(result, &ahres); err != nil {
  20763. utils.ErrorLog("解析失败:%v", err)
  20764. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20765. return
  20766. }
  20767. res.InfRefmsgid = ahres.InfRefmsgid
  20768. timestamp := int64(ahres.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  20769. // 创建对应的Time类型
  20770. t := time.UnixMilli(timestamp)
  20771. // 格式化成指定的日期字符串
  20772. str := t.Format("2006-01-02 15:04:05")
  20773. res.Output.Setlinfo.SetlTime = str
  20774. res.Output.Setlinfo.AcctMulaidPay = ahres.Output.Setlinfo.AcctMulaidPay
  20775. res.Output.Setlinfo.AcctPay = ahres.Output.Setlinfo.AcctPay
  20776. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  20777. res.Output.Setlinfo.ActPayDedc = ahres.Output.Setlinfo.ActPayDedc
  20778. res.Output.Setlinfo.Age = ahres.Output.Setlinfo.Age
  20779. res.Output.Setlinfo.Balc = ahres.Output.Setlinfo.Balc
  20780. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  20781. res.Output.Setlinfo.Certno = ahres.Output.Setlinfo.Certno
  20782. res.Output.Setlinfo.ClrOptins = ahres.Output.Setlinfo.ClrOptins
  20783. res.Output.Setlinfo.ClrType = ahres.Output.Setlinfo.ClrOptins
  20784. res.Output.Setlinfo.ClrWay = ahres.Output.Setlinfo.ClrOptins
  20785. res.Output.Setlinfo.CvlservFlag = ahres.Output.Setlinfo.ClrOptins
  20786. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  20787. res.Output.Setlinfo.FulamtOwnpayAmt = ahres.Output.Setlinfo.FulamtOwnpayAmt
  20788. res.Output.Setlinfo.FundPaySumamt = ahres.Output.Setlinfo.FundPaySumamt
  20789. res.Output.Setlinfo.Gend = ahres.Output.Setlinfo.Gend
  20790. res.Output.Setlinfo.HifesPay = ahres.Output.Setlinfo.HifesPay
  20791. res.Output.Setlinfo.HifmiPay = ahres.Output.Setlinfo.HifmiPay
  20792. res.Output.Setlinfo.HifpPay = ahres.Output.Setlinfo.HifpPay
  20793. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  20794. res.Output.Setlinfo.HospPartAmt = ahres.Output.Setlinfo.HospPartAmt
  20795. res.Output.Setlinfo.InscpScpAmt = ahres.Output.Setlinfo.InscpScpAmt
  20796. res.Output.Setlinfo.Insutype = ahres.Output.Setlinfo.Insutype
  20797. res.Output.Setlinfo.MafPay = ahres.Output.Setlinfo.MafPay
  20798. res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  20799. res.Output.Setlinfo.HifobPay = ahres.Output.Setlinfo.HifobPay
  20800. res.Output.Setlinfo.MdtrtID = ahres.Output.Setlinfo.MdtrtID
  20801. res.Output.Setlinfo.MedType = ahres.Output.Setlinfo.MedType
  20802. res.Output.Setlinfo.MedfeeSumamt = ahres.Output.Setlinfo.MedfeeSumamt
  20803. res.Output.Setlinfo.MedinsSetlID = ahres.Output.Setlinfo.MedinsSetlID
  20804. res.Output.Setlinfo.Naty = ahres.Output.Setlinfo.Naty
  20805. res.Output.Setlinfo.OthPay = ahres.Output.Setlinfo.OthPay
  20806. res.Output.Setlinfo.OverlmtSelfpay = ahres.Output.Setlinfo.OverlmtSelfpay
  20807. res.Output.Setlinfo.PoolPropSelfpay = ahres.Output.Setlinfo.PoolPropSelfpay
  20808. res.Output.Setlinfo.PreselfpayAmt = ahres.Output.Setlinfo.PreselfpayAmt
  20809. res.Output.Setlinfo.PsnCashPay = ahres.Output.Setlinfo.PsnCashPay
  20810. res.Output.Setlinfo.PsnCertType = ahres.Output.Setlinfo.ClrOptins
  20811. res.Output.Setlinfo.ClrType = ahres.Output.Setlinfo.ClrType
  20812. res.Output.Setlinfo.PsnName = ahres.Output.Setlinfo.PsnName
  20813. res.Output.Setlinfo.PsnNo = ahres.Output.Setlinfo.PsnNo
  20814. res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  20815. res.Output.Setlinfo.PsnType = ahres.Output.Setlinfo.PsnType
  20816. res.Output.Setlinfo.SetlID = ahres.Output.Setlinfo.SetlID
  20817. res.Output.Setldetail = ahres.Output.Setldetail
  20818. res.ErrMsg = ahres.ErrMsg
  20819. res.Cainfo = ahres.Cainfo
  20820. res.WarnMsg = ahres.WarnMsg
  20821. res.Infcode = ahres.Infcode
  20822. } else if miConfig.MdtrtareaAdmvs == "430800" {
  20823. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  20824. var cert_no string
  20825. if his.IdCardType == 1 {
  20826. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  20827. } else if his.IdCardType == 2 {
  20828. cert_no = his.IdCardNo
  20829. } else {
  20830. cert_no = psn_info.VerifyNumber
  20831. }
  20832. 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, "")
  20833. var dat map[string]interface{}
  20834. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  20835. fmt.Println(dat)
  20836. } else {
  20837. fmt.Println(err)
  20838. }
  20839. saveLog(result2, src_resquest, "2207", "结算")
  20840. userJSONBytes, _ := json.Marshal(dat)
  20841. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20842. utils.ErrorLog("解析失败:%v", err)
  20843. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20844. return
  20845. }
  20846. } else if miConfig.MdtrtareaAdmvs == "441799" {
  20847. psn_info, _ := service.GetPsnByPatientId(id)
  20848. var verify_number string
  20849. if psn_info.IdCardType == 4 {
  20850. verify_number = psn_info.VerifyNumber
  20851. } else if psn_info.IdCardType == 1 {
  20852. bas := strings.Split(psn_info.CardInfo, "|")
  20853. cardNumber := bas[2]
  20854. verify_number = cardNumber
  20855. } else {
  20856. verify_number = psn_info.Certno
  20857. psn_info.IdCardType = 2
  20858. }
  20859. var api string
  20860. api = miConfig.Url + "gdyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  20861. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  20862. "&operator=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  20863. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  20864. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(psn_info.IdCardType, 10) +
  20865. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  20866. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + tempOrder.MedType + "&acct_used_flag=" + acct_used_flag + "&verify_number=" + verify_number
  20867. resp, requestErr := http.Get(api)
  20868. if requestErr != nil {
  20869. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20870. return
  20871. }
  20872. body, ioErr := ioutil.ReadAll(resp.Body)
  20873. if ioErr != nil {
  20874. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  20875. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20876. return
  20877. }
  20878. var respJSON map[string]interface{}
  20879. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  20880. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  20881. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20882. return
  20883. }
  20884. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  20885. result, _ := json.Marshal(respJSON)
  20886. if err := json.Unmarshal([]byte(result), &res); err != nil {
  20887. utils.ErrorLog("解析失败:%v", err)
  20888. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20889. return
  20890. }
  20891. } else {
  20892. var src_resquest string
  20893. if miConfig.Code == "H15049901371" {
  20894. //赤峰地区国家医保医疗类别
  20895. //职工透析:医疗类别选特殊情况门诊990502
  20896. //居民定额血透门慢: 医疗类别选门诊慢病140104
  20897. var med_type string
  20898. if his.Insutype == "390" {
  20899. if reg_type == 14 {
  20900. med_type = "9933"
  20901. } else if reg_type == 11 {
  20902. med_type = "11"
  20903. }
  20904. } else if his.Insutype == "310" {
  20905. if reg_type == 14 {
  20906. med_type = "990502"
  20907. } else if reg_type == 11 {
  20908. med_type = "11"
  20909. }
  20910. }
  20911. 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)
  20912. } else {
  20913. if his.IdCardType == 4 {
  20914. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  20915. token := psn_info.VerifyNumber
  20916. 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)
  20917. } else {
  20918. 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)
  20919. }
  20920. }
  20921. var dat map[string]interface{}
  20922. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  20923. fmt.Println(dat)
  20924. } else {
  20925. fmt.Println(err)
  20926. }
  20927. saveLog(result2, src_resquest, "2207", "结算")
  20928. userJSONBytes, _ := json.Marshal(dat)
  20929. if miConfig.Code == "H15049901371" {
  20930. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  20931. utils.ErrorLog("解析失败:%v", err)
  20932. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20933. return
  20934. }
  20935. res.InfRefmsgid = resSeven10265.InfRefmsgid
  20936. res.Output = resSeven10265.Output
  20937. res.ErrMsg = resSeven10265.ErrMsg
  20938. res.Cainfo = resSeven10265.Cainfo
  20939. res.WarnMsg = resSeven10265.WarnMsg
  20940. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  20941. res.Infcode = infocode
  20942. } else {
  20943. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  20944. if err := json.Unmarshal(userJSONBytes, &gzresSeven10265Two); err != nil {
  20945. utils.ErrorLog("解析失败:%v", err)
  20946. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20947. return
  20948. }
  20949. res.InfRefmsgid = gzresSeven10265Two.InfRefmsgid
  20950. res.Output.Setlinfo.AcctMulaidPay = gzresSeven10265Two.Output.Setlinfo.AcctMulaidPay
  20951. res.Output.Setlinfo.AcctPay = gzresSeven10265Two.Output.Setlinfo.AcctPay
  20952. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  20953. res.Output.Setlinfo.ActPayDedc = gzresSeven10265Two.Output.Setlinfo.ActPayDedc
  20954. res.Output.Setlinfo.Age = gzresSeven10265Two.Output.Setlinfo.Age
  20955. res.Output.Setlinfo.Balc = gzresSeven10265Two.Output.Setlinfo.Balc
  20956. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  20957. res.Output.Setlinfo.Certno = gzresSeven10265Two.Output.Setlinfo.Certno
  20958. res.Output.Setlinfo.ClrOptins = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  20959. res.Output.Setlinfo.ClrType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  20960. res.Output.Setlinfo.ClrWay = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  20961. res.Output.Setlinfo.CvlservFlag = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  20962. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  20963. res.Output.Setlinfo.FulamtOwnpayAmt = gzresSeven10265Two.Output.Setlinfo.FulamtOwnpayAmt
  20964. res.Output.Setlinfo.FundPaySumamt = gzresSeven10265Two.Output.Setlinfo.FundPaySumamt
  20965. res.Output.Setlinfo.Gend = gzresSeven10265Two.Output.Setlinfo.Gend
  20966. res.Output.Setlinfo.HifesPay = gzresSeven10265Two.Output.Setlinfo.HifesPay
  20967. res.Output.Setlinfo.HifmiPay = gzresSeven10265Two.Output.Setlinfo.HifmiPay
  20968. res.Output.Setlinfo.HifpPay = gzresSeven10265Two.Output.Setlinfo.HifpPay
  20969. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  20970. res.Output.Setlinfo.HospPartAmt = gzresSeven10265Two.Output.Setlinfo.HospPartAmt
  20971. res.Output.Setlinfo.InscpScpAmt = gzresSeven10265Two.Output.Setlinfo.InscpScpAmt
  20972. res.Output.Setlinfo.Insutype = gzresSeven10265Two.Output.Setlinfo.Insutype
  20973. res.Output.Setlinfo.MafPay = gzresSeven10265Two.Output.Setlinfo.MafPay
  20974. res.Output.Setlinfo.MdtrtCertType = gzresSeven10265Two.Output.Setlinfo.MdtrtCertType
  20975. res.Output.Setlinfo.HifobPay = gzresSeven10265Two.Output.Setlinfo.HifobPay
  20976. res.Output.Setlinfo.MdtrtID = gzresSeven10265Two.Output.Setlinfo.MdtrtID
  20977. res.Output.Setlinfo.MedType = gzresSeven10265Two.Output.Setlinfo.MedType
  20978. res.Output.Setlinfo.MedfeeSumamt = gzresSeven10265Two.Output.Setlinfo.MedfeeSumamt
  20979. res.Output.Setlinfo.MedinsSetlID = gzresSeven10265Two.Output.Setlinfo.MedinsSetlID
  20980. res.Output.Setlinfo.Naty = gzresSeven10265Two.Output.Setlinfo.Naty
  20981. res.Output.Setlinfo.OthPay = gzresSeven10265Two.Output.Setlinfo.OthPay
  20982. res.Output.Setlinfo.OverlmtSelfpay = gzresSeven10265Two.Output.Setlinfo.OverlmtSelfpay
  20983. PoolPropSelfpay, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.PoolPropSelfpay, 64)
  20984. res.Output.Setlinfo.PoolPropSelfpay = PoolPropSelfpay
  20985. res.Output.Setlinfo.PreselfpayAmt = gzresSeven10265Two.Output.Setlinfo.PreselfpayAmt
  20986. res.Output.Setlinfo.PsnCashPay = gzresSeven10265Two.Output.Setlinfo.PsnCashPay
  20987. res.Output.Setlinfo.PsnCertType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  20988. res.Output.Setlinfo.PsnName = gzresSeven10265Two.Output.Setlinfo.PsnName
  20989. res.Output.Setlinfo.PsnNo = gzresSeven10265Two.Output.Setlinfo.PsnNo
  20990. res.Output.Setlinfo.PsnPartAmt = gzresSeven10265Two.Output.Setlinfo.PsnPartAmt
  20991. res.Output.Setlinfo.PsnType = gzresSeven10265Two.Output.Setlinfo.PsnType
  20992. res.Output.Setlinfo.SetlID = gzresSeven10265Two.Output.Setlinfo.SetlID
  20993. res.Output.Setlinfo.SetlTime = gzresSeven10265Two.Output.Setlinfo.SetlTime
  20994. //res.Output.Setldetail = gzresSeven10265Two.Output.Setldetail
  20995. res.ErrMsg = gzresSeven10265Two.ErrMsg
  20996. res.Cainfo = gzresSeven10265Two.Cainfo
  20997. res.WarnMsg = gzresSeven10265Two.WarnMsg
  20998. //infocode, _ := strconv.ParseInt(resSeven10265Two.Infcode, 10, 64)
  20999. //res.Infcode = infocode
  21000. } else {
  21001. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  21002. utils.ErrorLog("解析失败:%v", err)
  21003. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21004. return
  21005. }
  21006. }
  21007. }
  21008. }
  21009. if res.Infcode != 0 {
  21010. errlog := &models.HisOrderError{
  21011. UserOrgId: adminUser.CurrentOrgId,
  21012. Ctime: time.Now().Unix(),
  21013. Mtime: time.Now().Unix(),
  21014. Number: chrg_bchno,
  21015. ErrMsg: res.ErrMsg,
  21016. Status: 1,
  21017. PatientId: id,
  21018. RecordTime: recordDateTime,
  21019. Stage: 6,
  21020. }
  21021. service.CreateErrMsgLog(errlog)
  21022. c.ServeSuccessJSON(map[string]interface{}{
  21023. "failed_code": -10,
  21024. "msg": res.ErrMsg,
  21025. })
  21026. return
  21027. } else {
  21028. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  21029. order.OrderStatus = 2
  21030. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  21031. order.SetlId = res.Output.Setlinfo.SetlID
  21032. order.PsnNo = res.Output.Setlinfo.PsnNo
  21033. order.PsnName = res.Output.Setlinfo.PsnName
  21034. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  21035. order.Certno = res.Output.Setlinfo.Certno
  21036. order.Gend = res.Output.Setlinfo.Gend
  21037. order.Naty = res.Output.Setlinfo.Naty
  21038. order.Age = res.Output.Setlinfo.Age
  21039. order.Insutype = res.Output.Setlinfo.Insutype
  21040. order.PsnType = res.Output.Setlinfo.PsnType
  21041. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  21042. order.SetlTime = res.Output.Setlinfo.SetlTime
  21043. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  21044. order.PayWays = pay_ways
  21045. order.AcctUsedFlag = acct_used_flag
  21046. order.WechatPay = wechat_pay
  21047. order.AliPay = ali_pay
  21048. order.JifenPay = jifen_pay
  21049. order.BandCardPay = band_card_pay
  21050. order.CashPay = cash_pay
  21051. order.OthDesc = oth_desc
  21052. //order.MedType = res.Output.Setlinfo.MedType
  21053. if reg_type == 1112 {
  21054. order.MedType = "1112"
  21055. }
  21056. if reg_type == 1111 {
  21057. order.MedType = "1111"
  21058. }
  21059. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  21060. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  21061. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  21062. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  21063. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  21064. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  21065. order.HifpPay = res.Output.Setlinfo.HifpPay
  21066. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  21067. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  21068. order.HifesPay = res.Output.Setlinfo.HifesPay
  21069. order.HifobPay = res.Output.Setlinfo.HifobPay
  21070. order.MafPay = res.Output.Setlinfo.MafPay
  21071. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  21072. order.OthPay = res.Output.Setlinfo.OthPay
  21073. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  21074. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  21075. order.AcctPay = res.Output.Setlinfo.AcctPay
  21076. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  21077. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  21078. order.Balc = res.Output.Setlinfo.Balc
  21079. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  21080. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  21081. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  21082. order.ClrWay = res.Output.Setlinfo.ClrWay
  21083. order.Creator = order.Creator
  21084. order.ClrType = res.Output.Setlinfo.ClrType
  21085. order.Modify = roles.AdminUserId
  21086. order.RequestLog = src_resquest
  21087. order.Diagnosis = diagnosis_id
  21088. order.FaPiaoNumber = fapiao_number
  21089. order.FaPiaoCode = fapiao_code
  21090. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  21091. detailStr := string(setlDetail)
  21092. order.SetlDetail = detailStr
  21093. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  21094. err = service.UpDateOrder(order)
  21095. if err == nil {
  21096. //判断是否使用了押金
  21097. if dec_way == "true" {
  21098. tmpstring := strconv.FormatInt(order.ID, 10)
  21099. //扣押金
  21100. order.Decimal = decimal
  21101. service.UpDateOrder(order)
  21102. errmsg = service.SpendDeposit(c.GetAdminUserInfo().CurrentOrgId, id, c.GetAdminUserInfo().AdminUser.Id, tmpstring, decimal)
  21103. if errmsg != nil {
  21104. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, errmsg.Error())
  21105. return
  21106. }
  21107. }
  21108. c.ServeSuccessJSON(map[string]interface{}{
  21109. "msg": "结算成功",
  21110. })
  21111. } else {
  21112. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  21113. return
  21114. }
  21115. }
  21116. }
  21117. }
  21118. }
  21119. // 上传明细-预结算-
  21120. func (c *HisApiController) GetPreUploadInfo() {
  21121. id, _ := c.GetInt64("id")
  21122. record_time := c.GetString("record_time")
  21123. his_patient_id, _ := c.GetInt64("his_patient_id")
  21124. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  21125. admin_user_id, _ := c.GetInt64("admin_user_id")
  21126. diagnosis_id := c.GetString("diagnosis")
  21127. sick_type, _ := c.GetInt64("sick_type")
  21128. reg_type, _ := c.GetInt64("p_type")
  21129. begin_time := c.GetString("begin_time")
  21130. acct_used_flag := c.GetString("acct_used_flag")
  21131. id_str := c.GetString("ids")
  21132. ids_arr := strings.Split(id_str, ",")
  21133. timeLayout := "2006-01-02"
  21134. loc, _ := time.LoadLocation("Local")
  21135. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  21136. if err != nil {
  21137. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  21138. return
  21139. }
  21140. recordDateTime := theTime.Unix()
  21141. adminUser := c.GetAdminUserInfo()
  21142. diagnosis_ids := strings.Split(diagnosis_id, ",")
  21143. var config []*models.HisXtDiagnoseConfig
  21144. for _, item := range diagnosis_ids {
  21145. id, _ := strconv.ParseInt(item, 10, 64)
  21146. diagnosisConfig, _ := service.FindDiagnoseById(id)
  21147. config = append(config, &diagnosisConfig)
  21148. }
  21149. //diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  21150. sickConfig, _ := service.FindSickById(sick_type)
  21151. var prescriptions []*models.HisPrescription
  21152. var start_time int64
  21153. var end_time int64
  21154. var isSuccess bool = true
  21155. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  21156. fmt.Println(his_patient_id)
  21157. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  21158. timestamp := time.Now().Unix()
  21159. tempTime := time.Unix(timestamp, 0)
  21160. timeFormat := tempTime.Format("20060102150405")
  21161. chrgBchno := rand.Intn(100000) + 10000
  21162. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10)
  21163. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  21164. var patientPrescription models.HisPrescriptionInfo
  21165. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  21166. if patientPrescription.ID == 0 {
  21167. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  21168. }
  21169. //miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  21170. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  21171. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  21172. strconv.FormatInt(his.PatientId, 10)
  21173. var res2406 Result2406
  21174. //安徽单病种处理
  21175. if miConfig.MdtrtareaAdmvs == "341203" && reg_type == 992102 {
  21176. data := make(map[string]interface{})
  21177. client := &http.Client{}
  21178. data["psn_no"] = his.PsnNo
  21179. data["mdtrt_id"] = his.Number
  21180. data["operator"] = roles.UserName
  21181. data["cert_no"] = his.IdCardNo
  21182. data["org_name"] = miConfig.OrgName
  21183. data["psn_name"] = his.Name
  21184. data["ipt_otp_no"] = his.IptOtpNo
  21185. data["ipt_psn_sp_flag_type"] = "0901"
  21186. data["ipt_psn_sp_flag"] = "1"
  21187. data["fixmedins_code"] = miConfig.Code
  21188. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  21189. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  21190. data["url"] = miConfig.Url
  21191. utils.ErrorLog("接口返回数据解析JSON失败: %v", data)
  21192. bytesData, _ := json.Marshal(data)
  21193. var req *http.Request
  21194. utils.ErrorLog("接口返回数据解析JSON失败: %v", miConfig.SecretKey)
  21195. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2406", bytes.NewReader(bytesData))
  21196. resp, _ := client.Do(req)
  21197. defer resp.Body.Close()
  21198. body, ioErr := ioutil.ReadAll(resp.Body)
  21199. if ioErr != nil {
  21200. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  21201. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21202. return
  21203. }
  21204. var respJSON map[string]interface{}
  21205. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  21206. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21207. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21208. return
  21209. }
  21210. status := respJSON["data"].(map[string]interface{})["status"].(string)
  21211. if status == "0" {
  21212. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  21213. c.ServeSuccessJSON(map[string]interface{}{
  21214. "failed_code": -10,
  21215. "msg": err_msg,
  21216. })
  21217. return
  21218. }
  21219. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  21220. userJSONBytes, _ := json.Marshal(respJSON)
  21221. fmt.Println("log")
  21222. fmt.Println(string(userJSONBytes))
  21223. if err := json.Unmarshal(userJSONBytes, &res2406); err != nil {
  21224. utils.ErrorLog("解析失败:%v", err)
  21225. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21226. return
  21227. }
  21228. }
  21229. if res2406.Infcode != 0 {
  21230. adminUser := c.GetAdminUserInfo()
  21231. errlog := &models.HisOrderError{
  21232. UserOrgId: adminUser.CurrentOrgId,
  21233. Ctime: time.Now().Unix(),
  21234. Mtime: time.Now().Unix(),
  21235. ErrMsg: res2406.ErrMsg,
  21236. Status: 1,
  21237. PatientId: id,
  21238. RecordTime: recordDateTime,
  21239. Stage: 3,
  21240. }
  21241. service.CreateErrMsgLog(errlog)
  21242. c.ServeSuccessJSON(map[string]interface{}{
  21243. "failed_code": -10,
  21244. "msg": res2406.ErrMsg,
  21245. })
  21246. return
  21247. }
  21248. var res2 ResultSix
  21249. var res3 GZResultSix
  21250. var resSix10265 ResultSix10265
  21251. //var time_stamp string
  21252. if miConfig.MdtrtareaAdmvs == "421300" {
  21253. data := make(map[string]interface{})
  21254. client := &http.Client{}
  21255. data["psn_no"] = his.PsnNo
  21256. data["mdtrt_id"] = his.Number
  21257. data["department"] = department.Name
  21258. data["org_name"] = miConfig.OrgName
  21259. data["med_type"] = strconv.FormatInt(reg_type, 10)
  21260. data["doctor_id"] = doctor_info.DoctorNumber
  21261. data["doctor_name"] = roles.UserName
  21262. data["fixmedins_code"] = miConfig.Code
  21263. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  21264. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  21265. data["secret_key"] = miConfig.SecretKey
  21266. data["sick_code"] = sickConfig.CountryCode
  21267. data["sick_name"] = sickConfig.ClassName
  21268. data["begin_time"] = begin_time
  21269. data["dept"] = strconv.FormatInt(department.ID, 10)
  21270. data["config"] = config
  21271. data["opter"] = roles.UserName
  21272. fmt.Println(data)
  21273. bytesData, _ := json.Marshal(data)
  21274. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  21275. resp, _ := client.Do(req)
  21276. defer resp.Body.Close()
  21277. body, ioErr := ioutil.ReadAll(resp.Body)
  21278. if ioErr != nil {
  21279. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  21280. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21281. return
  21282. }
  21283. var respJSON map[string]interface{}
  21284. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  21285. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21286. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21287. return
  21288. }
  21289. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  21290. userJSONBytes, _ := json.Marshal(respJSON)
  21291. fmt.Println("log")
  21292. fmt.Println(string(userJSONBytes))
  21293. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  21294. utils.ErrorLog("解析失败:%v", err)
  21295. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21296. return
  21297. }
  21298. } else if miConfig.MdtrtareaAdmvs == "420200" {
  21299. data := make(map[string]interface{})
  21300. client := &http.Client{}
  21301. data["psn_no"] = his.PsnNo
  21302. data["mdtrt_id"] = his.Number
  21303. data["department"] = department.Name
  21304. data["org_name"] = miConfig.OrgName
  21305. if reg_type == 11 && his.Insutype == "390" {
  21306. data["med_type"] = "110104"
  21307. } else {
  21308. data["med_type"] = strconv.FormatInt(reg_type, 10)
  21309. }
  21310. data["doctor_id"] = doctor_info.DoctorNumber
  21311. data["doctor_name"] = roles.UserName
  21312. data["fixmedins_code"] = miConfig.Code
  21313. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  21314. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  21315. data["secret_key"] = miConfig.SecretKey
  21316. data["sick_code"] = sickConfig.CountryCode
  21317. data["sick_name"] = sickConfig.ClassName
  21318. data["begin_time"] = begin_time
  21319. data["dept"] = strconv.FormatInt(department.ID, 10)
  21320. data["config"] = config
  21321. data["opter"] = roles.UserName
  21322. fmt.Println(data)
  21323. bytesData, _ := json.Marshal(data)
  21324. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  21325. resp, _ := client.Do(req)
  21326. defer resp.Body.Close()
  21327. body, ioErr := ioutil.ReadAll(resp.Body)
  21328. if ioErr != nil {
  21329. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  21330. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21331. return
  21332. }
  21333. var respJSON map[string]interface{}
  21334. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  21335. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21336. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21337. return
  21338. }
  21339. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  21340. userJSONBytes, _ := json.Marshal(respJSON)
  21341. fmt.Println("log")
  21342. fmt.Println(string(userJSONBytes))
  21343. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  21344. utils.ErrorLog("解析失败:%v", err)
  21345. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21346. return
  21347. }
  21348. } else if miConfig.MdtrtareaAdmvs == "420902" {
  21349. data := make(map[string]interface{})
  21350. client := &http.Client{}
  21351. data["psn_no"] = his.PsnNo
  21352. data["mdtrt_id"] = his.Number
  21353. data["department"] = department.Name
  21354. data["org_name"] = miConfig.OrgName
  21355. if reg_type == 11 && his.Insutype == "390" {
  21356. data["med_type"] = "110104"
  21357. } else {
  21358. data["med_type"] = strconv.FormatInt(reg_type, 10)
  21359. }
  21360. data["doctor_id"] = doctor_info.DoctorNumber
  21361. data["doctor_name"] = roles.UserName
  21362. data["fixmedins_code"] = miConfig.Code
  21363. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  21364. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  21365. data["secret_key"] = miConfig.SecretKey
  21366. data["sick_code"] = sickConfig.CountryCode
  21367. data["sick_name"] = sickConfig.ClassName
  21368. data["begin_time"] = begin_time
  21369. data["dept"] = strconv.FormatInt(department.ID, 10)
  21370. data["config"] = config
  21371. data["opter"] = roles.UserName
  21372. fmt.Println(data)
  21373. bytesData, _ := json.Marshal(data)
  21374. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2203", bytes.NewReader(bytesData))
  21375. resp, _ := client.Do(req)
  21376. defer resp.Body.Close()
  21377. body, ioErr := ioutil.ReadAll(resp.Body)
  21378. if ioErr != nil {
  21379. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  21380. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21381. return
  21382. }
  21383. var respJSON map[string]interface{}
  21384. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  21385. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21386. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21387. return
  21388. }
  21389. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  21390. userJSONBytes, _ := json.Marshal(respJSON)
  21391. fmt.Println("log")
  21392. fmt.Println(string(userJSONBytes))
  21393. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  21394. utils.ErrorLog("解析失败:%v", err)
  21395. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21396. return
  21397. }
  21398. } else if miConfig.MdtrtareaAdmvs == "421182" {
  21399. data := make(map[string]interface{})
  21400. client := &http.Client{}
  21401. data["psn_no"] = his.PsnNo
  21402. data["mdtrt_id"] = his.Number
  21403. data["department"] = department.Name
  21404. data["org_name"] = miConfig.OrgName
  21405. if reg_type == 11 && his.Insutype == "390" {
  21406. data["med_type"] = "110104"
  21407. } else {
  21408. data["med_type"] = strconv.FormatInt(reg_type, 10)
  21409. }
  21410. data["doctor_id"] = doctor_info.DoctorNumber
  21411. data["doctor_name"] = roles.UserName
  21412. data["fixmedins_code"] = miConfig.Code
  21413. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  21414. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  21415. data["secret_key"] = miConfig.SecretKey
  21416. data["sick_code"] = sickConfig.CountryCode
  21417. data["sick_name"] = sickConfig.ClassName
  21418. data["begin_time"] = begin_time
  21419. data["dept"] = strconv.FormatInt(department.ID, 10)
  21420. data["config"] = config
  21421. data["opter"] = roles.UserName
  21422. fmt.Println(data)
  21423. bytesData, _ := json.Marshal(data)
  21424. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2203", bytes.NewReader(bytesData))
  21425. resp, _ := client.Do(req)
  21426. defer resp.Body.Close()
  21427. body, ioErr := ioutil.ReadAll(resp.Body)
  21428. if ioErr != nil {
  21429. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  21430. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21431. return
  21432. }
  21433. var respJSON map[string]interface{}
  21434. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  21435. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21436. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21437. return
  21438. }
  21439. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  21440. userJSONBytes, _ := json.Marshal(respJSON)
  21441. fmt.Println("log")
  21442. fmt.Println(string(userJSONBytes))
  21443. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  21444. utils.ErrorLog("解析失败:%v", err)
  21445. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21446. return
  21447. }
  21448. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  21449. data := make(map[string]interface{})
  21450. client := &http.Client{}
  21451. data["psn_no"] = his.PsnNo
  21452. data["mdtrt_id"] = his.Number
  21453. data["doctor"] = roles.UserName
  21454. data["department"] = department.Name
  21455. data["org_name"] = miConfig.OrgName
  21456. data["med_type"] = strconv.FormatInt(reg_type, 10)
  21457. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  21458. data["fixmedins_code"] = miConfig.Code
  21459. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  21460. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  21461. data["secret_key"] = miConfig.SecretKey
  21462. data["sick_code"] = sickConfig.CountryCode
  21463. data["sick_name"] = sickConfig.ClassName
  21464. data["begin_time"] = begin_time
  21465. data["dept"] = strconv.FormatInt(department.ID, 10)
  21466. data["config"] = config
  21467. data["url"] = miConfig.Url
  21468. data["ak"] = miConfig.AccessKey
  21469. data["cainfo"] = miConfig.Cainfo
  21470. bytesData, _ := json.Marshal(data)
  21471. var req *http.Request
  21472. if miConfig.MdtrtareaAdmvs == "320921" {
  21473. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  21474. } else {
  21475. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  21476. }
  21477. resp, _ := client.Do(req)
  21478. defer resp.Body.Close()
  21479. body, ioErr := ioutil.ReadAll(resp.Body)
  21480. if ioErr != nil {
  21481. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  21482. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21483. return
  21484. }
  21485. var respJSON map[string]interface{}
  21486. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  21487. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21488. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21489. return
  21490. }
  21491. //time_stamp := strconv.FormatInt(int64(respJSON["data"].(map[string]interface{})["time_stamp"].(float64)), 10)
  21492. //fmt.Println(respJSON["data"].(map[string]interface{})["time_stamp"].(string))
  21493. //time_stamp = respJSON["data"].(map[string]interface{})["time_stamp"].(string)
  21494. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  21495. userJSONBytes, _ := json.Marshal(respJSON)
  21496. fmt.Println("log")
  21497. fmt.Println(string(userJSONBytes))
  21498. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  21499. utils.ErrorLog("解析失败:%v", err)
  21500. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21501. return
  21502. }
  21503. res2.InfRefmsgid = resSix10265.InfRefmsgid
  21504. res2.Output = resSix10265.Output
  21505. res2.ErrMsg = resSix10265.ErrMsg
  21506. res2.Cainfo = resSix10265.Cainfo
  21507. res2.WarnMsg = resSix10265.WarnMsg
  21508. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  21509. res2.Infcode = infocode
  21510. } else if miConfig.MdtrtareaAdmvs == "150499" {
  21511. data := make(map[string]interface{})
  21512. client := &http.Client{}
  21513. data["psn_no"] = his.PsnNo
  21514. data["mdtrt_id"] = his.Number
  21515. data["doctor"] = roles.UserName
  21516. data["department"] = department.Name
  21517. data["org_name"] = miConfig.OrgName
  21518. data["med_type"] = strconv.FormatInt(reg_type, 10)
  21519. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  21520. data["fixmedins_code"] = miConfig.Code
  21521. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  21522. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  21523. data["secret_key"] = miConfig.SecretKey
  21524. data["sick_code"] = sickConfig.CountryCode
  21525. data["sick_name"] = sickConfig.ClassName
  21526. data["begin_time"] = begin_time
  21527. data["dept"] = strconv.FormatInt(department.ID, 10)
  21528. data["config"] = config
  21529. //data["url"] = miConfig.Url
  21530. //data["ak"] = miConfig.AccessKey
  21531. data["cainfo"] = miConfig.Cainfo
  21532. fmt.Println(data)
  21533. bytesData, _ := json.Marshal(data)
  21534. var req *http.Request
  21535. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2203", bytes.NewReader(bytesData))
  21536. resp, _ := client.Do(req)
  21537. defer resp.Body.Close()
  21538. body, ioErr := ioutil.ReadAll(resp.Body)
  21539. if ioErr != nil {
  21540. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  21541. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21542. return
  21543. }
  21544. var respJSON map[string]interface{}
  21545. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  21546. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21547. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21548. return
  21549. }
  21550. //time_stamp := strconv.FormatInt(int64(respJSON["data"].(map[string]interface{})["time_stamp"].(float64)), 10)
  21551. //fmt.Println(respJSON["data"].(map[string]interface{})["time_stamp"].(string))
  21552. //time_stamp = respJSON["data"].(map[string]interface{})["time_stamp"].(string)
  21553. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  21554. userJSONBytes, _ := json.Marshal(respJSON)
  21555. fmt.Println("log")
  21556. fmt.Println(string(userJSONBytes))
  21557. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  21558. utils.ErrorLog("解析失败:%v", err)
  21559. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21560. return
  21561. }
  21562. res2.InfRefmsgid = resSix10265.InfRefmsgid
  21563. res2.Output = resSix10265.Output
  21564. res2.ErrMsg = resSix10265.ErrMsg
  21565. res2.Cainfo = resSix10265.Cainfo
  21566. res2.WarnMsg = resSix10265.WarnMsg
  21567. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  21568. res2.Infcode = infocode
  21569. } else if miConfig.MdtrtareaAdmvs == "350500" {
  21570. 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)
  21571. saveLog(result, requestLog, "2203", "上传就诊信息")
  21572. var respJSON2 map[string]interface{}
  21573. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  21574. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21575. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21576. return
  21577. }
  21578. userJSONBytes2, _ := json.Marshal(respJSON2)
  21579. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  21580. utils.ErrorLog("解析失败:%v", err)
  21581. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21582. return
  21583. }
  21584. } else if miConfig.MdtrtareaAdmvs == "360302" {
  21585. var result string
  21586. var requestLog string
  21587. 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, "")
  21588. saveLog(result, requestLog, "2203", "上传就诊信息")
  21589. var respJSON2 map[string]interface{}
  21590. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  21591. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21592. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21593. return
  21594. }
  21595. userJSONBytes2, _ := json.Marshal(respJSON2)
  21596. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  21597. utils.ErrorLog("解析失败:%v", err)
  21598. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21599. return
  21600. }
  21601. } else if miConfig.MdtrtareaAdmvs == "341203" {
  21602. data := make(map[string]interface{})
  21603. client := &http.Client{}
  21604. data["psn_no"] = his.PsnNo
  21605. data["mdtrt_id"] = his.Number
  21606. data["operator"] = roles.UserName
  21607. data["department"] = department.Name
  21608. data["org_name"] = miConfig.OrgName
  21609. var med_type string
  21610. if his.Insutype == "390" {
  21611. if reg_type == 992102 {
  21612. med_type = "992102"
  21613. data["sick_code"] = "ZDZ940"
  21614. data["sick_name"] = "慢性肾衰竭"
  21615. }
  21616. if reg_type == 140104 {
  21617. med_type = "140104"
  21618. data["sick_code"] = sickConfig.CountryCode
  21619. data["sick_name"] = sickConfig.ClassName
  21620. }
  21621. if reg_type == 14 {
  21622. med_type = "140104"
  21623. data["sick_code"] = sickConfig.CountryCode
  21624. data["sick_name"] = sickConfig.ClassName
  21625. }
  21626. } else if his.Insutype == "310" {
  21627. if reg_type == 992102 {
  21628. med_type = "992102"
  21629. data["sick_code"] = "ZDZ940"
  21630. data["sick_name"] = "慢性肾衰竭"
  21631. }
  21632. if reg_type == 140104 {
  21633. med_type = "140104"
  21634. data["sick_code"] = sickConfig.CountryCode
  21635. data["sick_name"] = sickConfig.ClassName
  21636. }
  21637. if reg_type == 14 {
  21638. med_type = "14"
  21639. data["sick_code"] = sickConfig.CountryCode
  21640. data["sick_name"] = sickConfig.ClassName
  21641. }
  21642. }
  21643. data["med_type"] = med_type
  21644. data["doctor_number"] = doctor_info.DoctorNumber
  21645. data["doctor_name"] = doctor_info.UserName
  21646. data["fixmedins_code"] = miConfig.Code
  21647. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  21648. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  21649. data["secret_key"] = miConfig.SecretKey
  21650. data["begin_time"] = begin_time
  21651. data["dept"] = strconv.FormatInt(department.ID, 10)
  21652. data["config"] = config
  21653. data["url"] = miConfig.Url
  21654. data["ak"] = miConfig.AccessKey
  21655. data["cainfo"] = miConfig.Cainfo
  21656. bytesData, _ := json.Marshal(data)
  21657. var req *http.Request
  21658. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2203", bytes.NewReader(bytesData))
  21659. resp, _ := client.Do(req)
  21660. defer resp.Body.Close()
  21661. body, ioErr := ioutil.ReadAll(resp.Body)
  21662. if ioErr != nil {
  21663. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  21664. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21665. return
  21666. }
  21667. var respJSON map[string]interface{}
  21668. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  21669. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21670. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21671. return
  21672. }
  21673. status := respJSON["data"].(map[string]interface{})["status"].(string)
  21674. if status == "0" {
  21675. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  21676. c.ServeSuccessJSON(map[string]interface{}{
  21677. "failed_code": -10,
  21678. "msg": err_msg,
  21679. })
  21680. return
  21681. }
  21682. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  21683. userJSONBytes, _ := json.Marshal(respJSON)
  21684. fmt.Println("log")
  21685. fmt.Println(string(userJSONBytes))
  21686. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  21687. utils.ErrorLog("解析失败:%v", err)
  21688. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21689. return
  21690. }
  21691. } else if miConfig.MdtrtareaAdmvs == "430800" {
  21692. var result string
  21693. var requestLog string
  21694. 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, "")
  21695. saveLog(result, requestLog, "2203", "上传就诊信息")
  21696. var respJSON2 map[string]interface{}
  21697. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  21698. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21699. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21700. return
  21701. }
  21702. userJSONBytes2, _ := json.Marshal(respJSON2)
  21703. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  21704. utils.ErrorLog("解析失败:%v", err)
  21705. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21706. return
  21707. }
  21708. } else if miConfig.MdtrtareaAdmvs == "441799" {
  21709. data := make(map[string]interface{})
  21710. client := &http.Client{}
  21711. data["psn_no"] = his.PsnNo
  21712. data["mdtrt_id"] = his.Number
  21713. data["doctor"] = roles.UserName
  21714. data["department"] = department.Name
  21715. data["org_name"] = miConfig.OrgName
  21716. data["med_type"] = strconv.FormatInt(reg_type, 10)
  21717. data["doctor_id"] = doctor_info.DoctorNumber
  21718. data["fixmedins_code"] = miConfig.Code
  21719. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  21720. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  21721. data["secret_key"] = miConfig.SecretKey
  21722. data["sick_code"] = sickConfig.CountryCode
  21723. data["sick_name"] = sickConfig.ClassName
  21724. data["begin_time"] = begin_time
  21725. data["new_doctor_name"] = doctor_info.UserName
  21726. data["dept"] = strconv.FormatInt(department.ID, 10)
  21727. data["config"] = config
  21728. bytesData, _ := json.Marshal(data)
  21729. var req *http.Request
  21730. req, _ = http.NewRequest("POST", miConfig.Url+"gdyb/2203", bytes.NewReader(bytesData))
  21731. resp, _ := client.Do(req)
  21732. defer resp.Body.Close()
  21733. body, ioErr := ioutil.ReadAll(resp.Body)
  21734. if ioErr != nil {
  21735. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  21736. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21737. return
  21738. }
  21739. var respJSON map[string]interface{}
  21740. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  21741. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21742. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21743. return
  21744. }
  21745. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  21746. userJSONBytes, _ := json.Marshal(respJSON)
  21747. fmt.Println("log")
  21748. fmt.Println(string(userJSONBytes))
  21749. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  21750. utils.ErrorLog("解析失败:%v", err)
  21751. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21752. return
  21753. }
  21754. } else {
  21755. var result string
  21756. var requestLog string
  21757. if miConfig.MdtrtareaAdmvs == "440781" { //
  21758. 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)
  21759. } else {
  21760. if miConfig.Code == "H15049901371" {
  21761. //赤峰地区国家医保医疗类别
  21762. //职工透析:医疗类别选特殊情况门诊990502
  21763. //居民定额血透门慢: 医疗类别选门诊慢病140104
  21764. var med_type string
  21765. if his.Insutype == "390" {
  21766. if reg_type == 14 {
  21767. med_type = "9933"
  21768. } else if reg_type == 11 {
  21769. med_type = "11"
  21770. }
  21771. } else if his.Insutype == "310" {
  21772. if reg_type == 14 {
  21773. med_type = "990502"
  21774. } else if reg_type == 11 {
  21775. med_type = "11"
  21776. }
  21777. }
  21778. 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)
  21779. } else {
  21780. 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)
  21781. }
  21782. saveLog(result, requestLog, "2203", "上传就诊信息")
  21783. var respJSON2 map[string]interface{}
  21784. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  21785. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21786. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21787. return
  21788. }
  21789. userJSONBytes2, _ := json.Marshal(respJSON2)
  21790. if miConfig.Code == "H15049901371" {
  21791. if err := json.Unmarshal(userJSONBytes2, &resSix10265); err != nil {
  21792. utils.ErrorLog("解析失败:%v", err)
  21793. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21794. return
  21795. }
  21796. res2.InfRefmsgid = resSix10265.InfRefmsgid
  21797. res2.Output = resSix10265.Output
  21798. res2.ErrMsg = resSix10265.ErrMsg
  21799. res2.Cainfo = resSix10265.Cainfo
  21800. res2.WarnMsg = resSix10265.WarnMsg
  21801. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  21802. res2.Infcode = infocode
  21803. } else {
  21804. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  21805. if err := json.Unmarshal(userJSONBytes2, &res3); err != nil {
  21806. utils.ErrorLog("解析失败:%v", err)
  21807. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21808. return
  21809. }
  21810. res2.Infcode = res3.Infcode
  21811. } else {
  21812. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  21813. utils.ErrorLog("解析失败:%v", err)
  21814. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21815. return
  21816. }
  21817. }
  21818. }
  21819. }
  21820. }
  21821. if res2.Infcode == -1 {
  21822. adminUser := c.GetAdminUserInfo()
  21823. errlog := &models.HisOrderError{
  21824. UserOrgId: adminUser.CurrentOrgId,
  21825. Ctime: time.Now().Unix(),
  21826. Mtime: time.Now().Unix(),
  21827. ErrMsg: res2.ErrMsg,
  21828. Status: 1,
  21829. PatientId: id,
  21830. RecordTime: recordDateTime,
  21831. Stage: 3,
  21832. }
  21833. service.CreateErrMsgLog(errlog)
  21834. c.ServeSuccessJSON(map[string]interface{}{
  21835. "failed_code": -10,
  21836. "msg": res2.ErrMsg,
  21837. })
  21838. return
  21839. }
  21840. if res2.Infcode != 0 {
  21841. adminUser := c.GetAdminUserInfo()
  21842. errlog := &models.HisOrderError{
  21843. UserOrgId: adminUser.CurrentOrgId,
  21844. Ctime: time.Now().Unix(),
  21845. Mtime: time.Now().Unix(),
  21846. ErrMsg: res2.ErrMsg,
  21847. Status: 1,
  21848. PatientId: id,
  21849. RecordTime: recordDateTime,
  21850. Stage: 3,
  21851. }
  21852. service.CreateErrMsgLog(errlog)
  21853. c.ServeSuccessJSON(map[string]interface{}{
  21854. "failed_code": -10,
  21855. "msg": res2.ErrMsg,
  21856. })
  21857. return
  21858. } else {
  21859. his.Diagnosis = diagnosis_id
  21860. his.SickType = sickConfig.ID
  21861. his.PType = fmt.Sprintf("%d", reg_type)
  21862. service.UpdateHisPatientThree(&his)
  21863. data := make(map[string]interface{})
  21864. if settle_accounts_type == 1 { //日结
  21865. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  21866. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  21867. } else {
  21868. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  21869. }
  21870. data["pre"] = prescriptions
  21871. } else { //月结
  21872. start_time_str := c.GetString("start_time")
  21873. end_time_str := c.GetString("end_time")
  21874. timeLayout := "2006-01-02"
  21875. loc, _ := time.LoadLocation("Local")
  21876. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  21877. if err != nil {
  21878. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  21879. return
  21880. }
  21881. recordStartTime := theStartTime.Unix()
  21882. start_time = recordStartTime
  21883. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  21884. if err != nil {
  21885. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  21886. return
  21887. }
  21888. recordEndTime := theEndTime.Unix()
  21889. end_time = recordEndTime
  21890. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  21891. data["pre"] = prescriptions
  21892. }
  21893. client := &http.Client{}
  21894. data["psn_no"] = his.PsnNo
  21895. data["mdtrt_id"] = his.Number
  21896. data["chrg_bchno"] = chrg_bchno
  21897. data["org_name"] = miConfig.OrgName
  21898. data["doctor"] = doctor_info.UserName
  21899. data["doctor_id"] = doctor_info.DoctorNumber
  21900. data["dept"] = department.Name
  21901. data["fixmedins_code"] = miConfig.Code
  21902. data["opter"] = roles.UserName
  21903. data["dept_code"] = department.Number
  21904. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  21905. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  21906. data["secret_key"] = miConfig.SecretKey
  21907. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  21908. data["url"] = miConfig.Url
  21909. data["ak"] = miConfig.AccessKey
  21910. data["new_doctor_name"] = patientPrescription.Doctor
  21911. if his.Insutype == "390" {
  21912. if reg_type == 992102 {
  21913. data["diag_code"] = "ZDZ940"
  21914. }
  21915. if reg_type == 140104 {
  21916. data["diag_code"] = sickConfig.CountryCode
  21917. }
  21918. if reg_type == 14 {
  21919. data["diag_code"] = sickConfig.CountryCode
  21920. }
  21921. } else if his.Insutype == "310" {
  21922. if reg_type == 992102 {
  21923. data["diag_code"] = "ZDZ940"
  21924. }
  21925. if reg_type == 14 {
  21926. data["diag_code"] = sickConfig.CountryCode
  21927. }
  21928. }
  21929. data["cainfo"] = miConfig.Cainfo
  21930. data["opter"] = roles.UserName
  21931. var ids []int64
  21932. for _, item := range prescriptions {
  21933. ids = append(ids, item.ID)
  21934. }
  21935. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  21936. if config.IsOpen == 1 { //对接了医保,走医保流程
  21937. var res ResultFour
  21938. var resFour10265 ResultFour10265
  21939. if miConfig.MdtrtareaAdmvs == "421300" {
  21940. bytesData, _ := json.Marshal(data)
  21941. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  21942. resp, _ := client.Do(req)
  21943. defer resp.Body.Close()
  21944. body, ioErr := ioutil.ReadAll(resp.Body)
  21945. if ioErr != nil {
  21946. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  21947. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21948. return
  21949. }
  21950. var respJSON map[string]interface{}
  21951. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  21952. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21953. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21954. return
  21955. }
  21956. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  21957. userJSONBytes, _ := json.Marshal(respJSON)
  21958. fmt.Println("log")
  21959. fmt.Println(string(userJSONBytes))
  21960. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  21961. utils.ErrorLog("解析失败:%v", err)
  21962. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21963. return
  21964. }
  21965. } else if miConfig.MdtrtareaAdmvs == "420200" {
  21966. bytesData, _ := json.Marshal(data)
  21967. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  21968. resp, _ := client.Do(req)
  21969. defer resp.Body.Close()
  21970. body, ioErr := ioutil.ReadAll(resp.Body)
  21971. if ioErr != nil {
  21972. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  21973. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21974. return
  21975. }
  21976. var respJSON map[string]interface{}
  21977. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  21978. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21979. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21980. return
  21981. }
  21982. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  21983. userJSONBytes, _ := json.Marshal(respJSON)
  21984. fmt.Println("log")
  21985. fmt.Println(string(userJSONBytes))
  21986. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  21987. utils.ErrorLog("解析失败:%v", err)
  21988. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21989. return
  21990. }
  21991. }else if miConfig.MdtrtareaAdmvs == "420902" {
  21992. bytesData, _ := json.Marshal(data)
  21993. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2204", bytes.NewReader(bytesData))
  21994. resp, _ := client.Do(req)
  21995. defer resp.Body.Close()
  21996. body, ioErr := ioutil.ReadAll(resp.Body)
  21997. if ioErr != nil {
  21998. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  21999. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22000. return
  22001. }
  22002. var respJSON map[string]interface{}
  22003. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  22004. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22005. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22006. return
  22007. }
  22008. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22009. userJSONBytes, _ := json.Marshal(respJSON)
  22010. fmt.Println("log")
  22011. fmt.Println(string(userJSONBytes))
  22012. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  22013. utils.ErrorLog("解析失败:%v", err)
  22014. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22015. return
  22016. }
  22017. } else if miConfig.MdtrtareaAdmvs == "421182" {
  22018. bytesData, _ := json.Marshal(data)
  22019. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2204", bytes.NewReader(bytesData))
  22020. resp, _ := client.Do(req)
  22021. defer resp.Body.Close()
  22022. body, ioErr := ioutil.ReadAll(resp.Body)
  22023. if ioErr != nil {
  22024. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  22025. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22026. return
  22027. }
  22028. var respJSON map[string]interface{}
  22029. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  22030. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22031. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22032. return
  22033. }
  22034. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22035. userJSONBytes, _ := json.Marshal(respJSON)
  22036. fmt.Println("log")
  22037. fmt.Println(string(userJSONBytes))
  22038. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  22039. utils.ErrorLog("解析失败:%v", err)
  22040. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22041. return
  22042. }
  22043. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  22044. result3101 := Check3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  22045. if result3101.Infcode == "0" {
  22046. if len(result3101.Output.Result) > 0 {
  22047. var errMsgs []string
  22048. for _, item := range result3101.Output.Result {
  22049. errMsgs = append(errMsgs, item.VolaCont)
  22050. }
  22051. c.ServeSuccessJSON(map[string]interface{}{
  22052. "failed_code": -10,
  22053. "msg": errMsgs,
  22054. })
  22055. return
  22056. } else {
  22057. if miConfig.MdtrtareaAdmvs == "320921" {
  22058. data["doctor_id"] = "D320923012139"
  22059. } else {
  22060. data["doctor_id"] = "D371621008686"
  22061. }
  22062. bytesData, _ := json.Marshal(data)
  22063. var req *http.Request
  22064. if miConfig.MdtrtareaAdmvs == "320921" {
  22065. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  22066. } else {
  22067. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  22068. }
  22069. resp, _ := client.Do(req)
  22070. defer resp.Body.Close()
  22071. body, ioErr := ioutil.ReadAll(resp.Body)
  22072. if ioErr != nil {
  22073. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  22074. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22075. return
  22076. }
  22077. var respJSON map[string]interface{}
  22078. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  22079. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22080. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22081. return
  22082. }
  22083. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22084. userJSONBytes, _ := json.Marshal(respJSON)
  22085. fmt.Println("log")
  22086. fmt.Println(string(userJSONBytes))
  22087. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  22088. utils.ErrorLog("解析失败:%v", err)
  22089. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22090. return
  22091. }
  22092. res.InfRefmsgid = resFour10265.InfRefmsgid
  22093. res.Output = resFour10265.Output
  22094. res.ErrMsg = resFour10265.ErrMsg
  22095. res.Cainfo = resFour10265.Cainfo
  22096. res.WarnMsg = resFour10265.WarnMsg
  22097. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  22098. res.Infcode = infocode
  22099. }
  22100. }
  22101. } else if miConfig.MdtrtareaAdmvs == "150499" {
  22102. var pagesize int = 5
  22103. var start int = 1
  22104. var stop int
  22105. var pagecount int
  22106. var curpage int
  22107. data["doctor_id"] = doctor_info.DoctorNumber
  22108. var res2 ResultFour
  22109. //var result res.
  22110. //总页数,向上取整,注意除之前要先转换类型为float64
  22111. pagecount = int(math.Ceil(float64(len(prescriptions)) / float64(pagesize)))
  22112. for curpage = 1; curpage <= pagecount; curpage++ {
  22113. if curpage == 1 {
  22114. start = 1
  22115. } else {
  22116. start = (curpage-1)*pagesize + 1
  22117. }
  22118. stop = curpage * pagesize
  22119. if stop > len(prescriptions) {
  22120. stop = len(prescriptions)
  22121. }
  22122. //var requestLog string
  22123. data["pre"] = prescriptions[start-1 : stop]
  22124. fmt.Println(data["pre"])
  22125. bytesData, _ := json.Marshal(data)
  22126. var req *http.Request
  22127. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2204", bytes.NewReader(bytesData))
  22128. resp, _ := client.Do(req)
  22129. defer resp.Body.Close()
  22130. body, ioErr := ioutil.ReadAll(resp.Body)
  22131. if ioErr != nil {
  22132. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  22133. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22134. return
  22135. }
  22136. var respJSON map[string]interface{}
  22137. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  22138. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22139. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22140. return
  22141. }
  22142. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22143. userJSONBytes, _ := json.Marshal(respJSON)
  22144. fmt.Println("log")
  22145. fmt.Println(string(userJSONBytes))
  22146. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  22147. utils.ErrorLog("解析失败:%v", err)
  22148. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22149. return
  22150. }
  22151. res.InfRefmsgid = resFour10265.InfRefmsgid
  22152. res.Output = resFour10265.Output
  22153. res.ErrMsg = resFour10265.ErrMsg
  22154. res.Cainfo = resFour10265.Cainfo
  22155. res.WarnMsg = resFour10265.WarnMsg
  22156. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  22157. res.Infcode = infocode
  22158. if infocode == 0 {
  22159. res2.Output.Result = append(res2.Output.Result, res.Output.Result...)
  22160. } else {
  22161. isSuccess = false
  22162. res2.ErrMsg = res2.ErrMsg + "," + res.ErrMsg
  22163. res.Infcode = -1
  22164. res.ErrMsg = resFour10265.ErrMsg
  22165. errlog := &models.HisOrderError{
  22166. UserOrgId: adminUser.CurrentOrgId,
  22167. Ctime: time.Now().Unix(),
  22168. Mtime: time.Now().Unix(),
  22169. Number: chrg_bchno,
  22170. ErrMsg: "",
  22171. Status: 1,
  22172. PatientId: id,
  22173. RecordTime: recordDateTime,
  22174. Stage: 4,
  22175. }
  22176. service.CreateErrMsgLog(errlog)
  22177. }
  22178. }
  22179. if isSuccess {
  22180. res.Infcode = 0
  22181. res.Output.Result = res2.Output.Result
  22182. } else {
  22183. order := &models.HisOrder{
  22184. UserOrgId: adminUser.CurrentOrgId,
  22185. HisPatientId: his.ID,
  22186. PatientId: his.PatientId,
  22187. SettleAccountsDate: recordDateTime,
  22188. Ctime: time.Now().Unix(),
  22189. Mtime: time.Now().Unix(),
  22190. MdtrtId: his.Number,
  22191. PsnNo: his.PsnNo,
  22192. MedType: strconv.FormatInt(reg_type, 10),
  22193. Status: 1,
  22194. Number: chrg_bchno,
  22195. Infcode: res.Infcode,
  22196. WarnMsg: res.WarnMsg,
  22197. Cainfo: res.Cainfo,
  22198. ErrMsg: res.ErrMsg,
  22199. RespondTime: res.RefmsgTime,
  22200. InfRefmsgid: res.InfRefmsgid,
  22201. OrderStatus: 1,
  22202. IsMedicineInsurance: 1,
  22203. SettleType: settle_accounts_type,
  22204. SettleStartTime: start_time,
  22205. SettleEndTime: end_time,
  22206. Creator: roles.AdminUserId,
  22207. Modify: roles.AdminUserId,
  22208. PType: 2,
  22209. Diagnosis: diagnosis_id,
  22210. }
  22211. err = service.CreateOrder(order)
  22212. if err != nil {
  22213. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  22214. return
  22215. }
  22216. c.ServeSuccessJSON(map[string]interface{}{
  22217. "failed_code": -10,
  22218. "msg": res2.ErrMsg,
  22219. })
  22220. return
  22221. }
  22222. } else if miConfig.MdtrtareaAdmvs == "350500" {
  22223. 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)
  22224. var dat map[string]interface{}
  22225. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  22226. fmt.Println(dat)
  22227. } else {
  22228. fmt.Println(err)
  22229. }
  22230. saveLog(result, request_log, "2204", "上传费用明细")
  22231. userJSONBytes, _ := json.Marshal(dat)
  22232. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  22233. utils.ErrorLog("解析失败:%v", err)
  22234. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22235. return
  22236. }
  22237. } else if miConfig.MdtrtareaAdmvs == "360302" {
  22238. 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, "", "")
  22239. var dat map[string]interface{}
  22240. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  22241. fmt.Println(dat)
  22242. } else {
  22243. fmt.Println(err)
  22244. }
  22245. saveLog(result, request_log, "2204", "上传费用明细")
  22246. userJSONBytes, _ := json.Marshal(dat)
  22247. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  22248. utils.ErrorLog("解析失败:%v", err)
  22249. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22250. return
  22251. }
  22252. } else if miConfig.MdtrtareaAdmvs == "341203" {
  22253. bytesData, _ := json.Marshal(data)
  22254. var req *http.Request
  22255. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2204", bytes.NewReader(bytesData))
  22256. resp, _ := client.Do(req)
  22257. defer resp.Body.Close()
  22258. body, ioErr := ioutil.ReadAll(resp.Body)
  22259. if ioErr != nil {
  22260. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  22261. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22262. return
  22263. }
  22264. var respJSON map[string]interface{}
  22265. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  22266. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22267. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22268. return
  22269. }
  22270. status := respJSON["data"].(map[string]interface{})["status"].(string)
  22271. if status == "0" {
  22272. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  22273. c.ServeSuccessJSON(map[string]interface{}{
  22274. "failed_code": -10,
  22275. "msg": err_msg,
  22276. })
  22277. return
  22278. }
  22279. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22280. userJSONBytes, _ := json.Marshal(respJSON)
  22281. fmt.Println("log")
  22282. fmt.Println(string(userJSONBytes))
  22283. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  22284. utils.ErrorLog("解析失败:%v", err)
  22285. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22286. return
  22287. }
  22288. } else if miConfig.MdtrtareaAdmvs == "430800" {
  22289. 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, "", "")
  22290. var dat map[string]interface{}
  22291. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  22292. fmt.Println(dat)
  22293. } else {
  22294. fmt.Println(err)
  22295. }
  22296. saveLog(result, request_log, "2204", "上传费用明细")
  22297. userJSONBytes, _ := json.Marshal(dat)
  22298. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  22299. utils.ErrorLog("解析失败:%v", err)
  22300. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22301. return
  22302. }
  22303. } else if miConfig.MdtrtareaAdmvs == "441799" {
  22304. bytesData, _ := json.Marshal(data)
  22305. req, _ := http.NewRequest("POST", miConfig.Url+"gdyb/2204", bytes.NewReader(bytesData))
  22306. resp, _ := client.Do(req)
  22307. defer resp.Body.Close()
  22308. body, ioErr := ioutil.ReadAll(resp.Body)
  22309. if ioErr != nil {
  22310. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  22311. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22312. return
  22313. }
  22314. var respJSON map[string]interface{}
  22315. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  22316. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22317. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22318. return
  22319. }
  22320. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22321. userJSONBytes, _ := json.Marshal(respJSON)
  22322. fmt.Println("log")
  22323. fmt.Println(string(userJSONBytes))
  22324. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  22325. utils.ErrorLog("解析失败:%v", err)
  22326. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22327. return
  22328. }
  22329. } else {
  22330. if miConfig.MdtrtareaAdmvs == "441202" {
  22331. result3101 := Checkgd3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  22332. if result3101.Infcode == 0 {
  22333. if len(result3101.Output.Result) > 0 {
  22334. var errMsgs []string
  22335. for _, item := range result3101.Output.Result {
  22336. errMsgs = append(errMsgs, item.VolaCont)
  22337. }
  22338. c.ServeSuccessJSON(map[string]interface{}{
  22339. "failed_code": -10,
  22340. "msg": errMsgs,
  22341. })
  22342. return
  22343. } else {
  22344. 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)
  22345. var dat map[string]interface{}
  22346. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  22347. fmt.Println(dat)
  22348. } else {
  22349. fmt.Println(err)
  22350. }
  22351. saveLog(result, request_log, "2204", "上传费用明细")
  22352. userJSONBytes, _ := json.Marshal(dat)
  22353. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  22354. utils.ErrorLog("解析失败:%v", err)
  22355. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22356. return
  22357. }
  22358. }
  22359. } else {
  22360. c.ServeSuccessJSON(map[string]interface{}{
  22361. "failed_code": -10,
  22362. "msg": result3101.ErrMsg,
  22363. })
  22364. return
  22365. }
  22366. } else {
  22367. if miConfig.Code == "H15049901371" {
  22368. 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)
  22369. var dat map[string]interface{}
  22370. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  22371. fmt.Println(dat)
  22372. } else {
  22373. fmt.Println(err)
  22374. }
  22375. saveLog(result, request_log, "2204", "上传费用明细")
  22376. userJSONBytes, _ := json.Marshal(dat)
  22377. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  22378. utils.ErrorLog("解析失败:%v", err)
  22379. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22380. return
  22381. }
  22382. res.InfRefmsgid = resFour10265.InfRefmsgid
  22383. res.Output = resFour10265.Output
  22384. res.ErrMsg = resFour10265.ErrMsg
  22385. res.Cainfo = resFour10265.Cainfo
  22386. res.WarnMsg = resFour10265.WarnMsg
  22387. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  22388. res.Infcode = infocode
  22389. } else {
  22390. 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)
  22391. var dat map[string]interface{}
  22392. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  22393. fmt.Println(dat)
  22394. } else {
  22395. fmt.Println(err)
  22396. }
  22397. saveLog(result, request_log, "2204", "上传费用明细")
  22398. userJSONBytes, _ := json.Marshal(dat)
  22399. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  22400. utils.ErrorLog("解析失败:%v", err)
  22401. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22402. return
  22403. }
  22404. }
  22405. }
  22406. }
  22407. var total_two float64
  22408. if res.Infcode == 0 {
  22409. order := &models.HisOrder{
  22410. UserOrgId: adminUser.CurrentOrgId,
  22411. HisPatientId: his.ID,
  22412. PatientId: his.PatientId,
  22413. SettleAccountsDate: recordDateTime,
  22414. Ctime: time.Now().Unix(),
  22415. Mtime: time.Now().Unix(),
  22416. MdtrtId: his.Number,
  22417. PsnNo: his.PsnNo,
  22418. MedType: strconv.FormatInt(reg_type, 10),
  22419. Status: 1,
  22420. Number: chrg_bchno,
  22421. Infcode: res.Infcode,
  22422. WarnMsg: res.WarnMsg,
  22423. Cainfo: res.Cainfo,
  22424. ErrMsg: res.ErrMsg,
  22425. RespondTime: res.RefmsgTime,
  22426. InfRefmsgid: res.InfRefmsgid,
  22427. OrderStatus: 1,
  22428. IsMedicineInsurance: 1,
  22429. SettleType: settle_accounts_type,
  22430. SettleStartTime: start_time,
  22431. SettleEndTime: end_time,
  22432. Creator: roles.AdminUserId,
  22433. Modify: roles.AdminUserId,
  22434. PType: 2,
  22435. Diagnosis: diagnosis_id,
  22436. }
  22437. err = service.CreateOrder(order)
  22438. if err != nil {
  22439. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  22440. return
  22441. }
  22442. for _, item := range res.Output.Result {
  22443. temp := strings.Split(item.FeedetlSn, "-")
  22444. var advice_id int64 = 0
  22445. var project_id int64 = 0
  22446. var types int64 = 0
  22447. id, _ := strconv.ParseInt(temp[2], 10, 64)
  22448. types, _ = strconv.ParseInt(temp[1], 10, 64)
  22449. if temp[1] == "1" {
  22450. advice_id = id
  22451. project_id = 0
  22452. } else if temp[1] == "2" {
  22453. advice_id = 0
  22454. project_id = id
  22455. }
  22456. total_two = total_two + item.DetItemFeeSumamt
  22457. info := &models.HisOrderInfo{
  22458. OrderNumber: order.Number,
  22459. FeedetlSn: item.FeedetlSn,
  22460. UploadDate: time.Now().Unix(),
  22461. AdviceId: advice_id,
  22462. DetItemFeeSumamt: item.DetItemFeeSumamt,
  22463. Cnt: item.Cnt,
  22464. Pric: float64(item.Pric),
  22465. PatientId: his.PatientId,
  22466. PricUplmtAmt: item.PricUplmtAmt,
  22467. SelfpayProp: item.SelfpayProp,
  22468. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  22469. OverlmtAmt: item.OverlmtAmt,
  22470. PreselfpayAmt: item.PreselfpayAmt,
  22471. BasMednFlag: item.BasMednFlag,
  22472. MedChrgitmType: item.MedChrgitmType,
  22473. HiNegoDrugFlag: item.HiNegoDrugFlag,
  22474. Status: 1,
  22475. Memo: item.Memo,
  22476. Mtime: time.Now().Unix(),
  22477. InscpScpAmt: item.InscpScpAmt,
  22478. DrtReimFlag: item.DrtReimFlag,
  22479. Ctime: time.Now().Unix(),
  22480. ListSpItemFlag: item.ListSpItemFlag,
  22481. ChldMedcFlag: item.ChldMedcFlag,
  22482. LmtUsedFlag: item.LmtUsedFlag,
  22483. ChrgitmLv: item.ChrgitmLv,
  22484. UserOrgId: adminUser.CurrentOrgId,
  22485. HisPatientId: his.ID,
  22486. OrderId: order.ID,
  22487. ProjectId: project_id,
  22488. Type: types,
  22489. }
  22490. service.CreateOrderInfo(info)
  22491. }
  22492. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  22493. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  22494. var total float64
  22495. for _, item := range prescriptions {
  22496. if item.Type == 1 { //药品
  22497. for _, subItem := range item.HisDoctorAdviceInfo {
  22498. price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  22499. total_one := price * subItem.PrescribingNumber
  22500. fmt.Println("subItem")
  22501. fmt.Println(subItem.Price)
  22502. fmt.Println("price")
  22503. fmt.Println(price)
  22504. fmt.Println("total_one")
  22505. fmt.Println(total_one)
  22506. total = total + total_one
  22507. fmt.Println(total)
  22508. }
  22509. }
  22510. if item.Type == 2 { //项目
  22511. for _, subItem := range item.HisPrescriptionProject {
  22512. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  22513. price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  22514. total_one := price * cnt
  22515. total = total + total_one
  22516. }
  22517. }
  22518. }
  22519. allTotal := fmt.Sprintf("%.2f", total)
  22520. if res.Infcode == 0 {
  22521. var rf []*ResultFive
  22522. json.Unmarshal([]byte(his.Iinfo), &rf)
  22523. chrg_bchno := chrg_bchno
  22524. cert_no := his.Certno
  22525. var insutypes []string
  22526. var insutype string
  22527. var is390 int = 0
  22528. var is310 int = 0
  22529. for _, item := range rf {
  22530. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  22531. insutypes = append(insutypes, item.Insutype)
  22532. }
  22533. }
  22534. if len(insutypes) == 1 {
  22535. insutype = insutypes[0]
  22536. } else {
  22537. for _, i := range insutypes {
  22538. if i == "390" {
  22539. is390 = 1
  22540. }
  22541. if i == "310" {
  22542. is310 = 1
  22543. }
  22544. }
  22545. }
  22546. if is390 == 1 {
  22547. insutype = "390"
  22548. }
  22549. if is310 == 1 {
  22550. insutype = "310"
  22551. }
  22552. if len(insutypes) == 0 {
  22553. insutype = "390"
  22554. }
  22555. if len(insutypes) == 2 {
  22556. insutype = strconv.FormatInt(his.SocialType, 10)
  22557. }
  22558. //insutype = "390"
  22559. if his.IdCardType == 1 {
  22560. cert_no = his.MedicalInsuranceNumber
  22561. } else {
  22562. cert_no = his.Certno
  22563. }
  22564. var res ResultSeven
  22565. var ahres ResultSevenAH
  22566. var resSeven10265 ResultSeven10265
  22567. var resSeven10265Two ResultSeven10265Two
  22568. var gzresSeven10265Two GZResultSeven10265Two
  22569. if miConfig.MdtrtareaAdmvs == "421300" {
  22570. formattedString := strconv.FormatFloat(total, 'f', 2, 64)
  22571. api := "http://192.168.124.4:9532/" + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  22572. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  22573. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  22574. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  22575. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  22576. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  22577. "&insutype=" + insutype + "&total=" + formattedString + "&med_type=" + strconv.FormatInt(reg_type, 10)
  22578. resp, requestErr := http.Get(api)
  22579. if requestErr != nil {
  22580. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22581. return
  22582. }
  22583. body, ioErr := ioutil.ReadAll(resp.Body)
  22584. if ioErr != nil {
  22585. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  22586. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22587. return
  22588. }
  22589. var respJSON map[string]interface{}
  22590. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  22591. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22592. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22593. return
  22594. }
  22595. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22596. result, _ := json.Marshal(respJSON)
  22597. fmt.Println("log")
  22598. fmt.Println(string(result))
  22599. if err := json.Unmarshal([]byte(result), &res); err != nil {
  22600. utils.ErrorLog("解析失败:%v", err)
  22601. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22602. return
  22603. }
  22604. } else if miConfig.MdtrtareaAdmvs == "420200" {
  22605. if reg_type == 11 && his.Insutype == "390" {
  22606. reg_type = 110104
  22607. }
  22608. api := "http://192.168.0.197:9532/" + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  22609. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  22610. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  22611. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  22612. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  22613. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  22614. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  22615. resp, requestErr := http.Get(api)
  22616. if requestErr != nil {
  22617. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22618. return
  22619. }
  22620. body, ioErr := ioutil.ReadAll(resp.Body)
  22621. if ioErr != nil {
  22622. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  22623. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22624. return
  22625. }
  22626. var respJSON map[string]interface{}
  22627. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  22628. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22629. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22630. return
  22631. }
  22632. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22633. result, _ := json.Marshal(respJSON)
  22634. fmt.Println("log")
  22635. fmt.Println(string(result))
  22636. if err := json.Unmarshal([]byte(result), &res); err != nil {
  22637. utils.ErrorLog("解析失败:%v", err)
  22638. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22639. return
  22640. }
  22641. } else if miConfig.MdtrtareaAdmvs == "420902" {
  22642. if reg_type == 11 && his.Insutype == "390" {
  22643. reg_type = 110104
  22644. }
  22645. api := miConfig.Url + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  22646. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  22647. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  22648. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  22649. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  22650. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  22651. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  22652. resp, requestErr := http.Get(api)
  22653. if requestErr != nil {
  22654. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22655. return
  22656. }
  22657. body, ioErr := ioutil.ReadAll(resp.Body)
  22658. if ioErr != nil {
  22659. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  22660. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22661. return
  22662. }
  22663. var respJSON map[string]interface{}
  22664. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  22665. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22666. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22667. return
  22668. }
  22669. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22670. result, _ := json.Marshal(respJSON)
  22671. fmt.Println("log")
  22672. fmt.Println(string(result))
  22673. if err := json.Unmarshal([]byte(result), &res); err != nil {
  22674. utils.ErrorLog("解析失败:%v", err)
  22675. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22676. return
  22677. }
  22678. } else if miConfig.MdtrtareaAdmvs == "421182" {
  22679. if reg_type == 11 && his.Insutype == "390" {
  22680. reg_type = 110104
  22681. }
  22682. api := miConfig.Url + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  22683. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  22684. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  22685. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  22686. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  22687. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  22688. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  22689. resp, requestErr := http.Get(api)
  22690. if requestErr != nil {
  22691. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22692. return
  22693. }
  22694. body, ioErr := ioutil.ReadAll(resp.Body)
  22695. if ioErr != nil {
  22696. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  22697. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22698. return
  22699. }
  22700. var respJSON map[string]interface{}
  22701. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  22702. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22703. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22704. return
  22705. }
  22706. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22707. result, _ := json.Marshal(respJSON)
  22708. fmt.Println("log")
  22709. fmt.Println(string(result))
  22710. if err := json.Unmarshal([]byte(result), &res); err != nil {
  22711. utils.ErrorLog("解析失败:%v", err)
  22712. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22713. return
  22714. }
  22715. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  22716. result3101 := Check3102(c, id, his_patient_id, admin_user_id, "6", order.ID)
  22717. if result3101.Infcode == "0" {
  22718. if len(result3101.Output.Result) > 0 {
  22719. var errMsgs []string
  22720. for _, item := range result3101.Output.Result {
  22721. errMsgs = append(errMsgs, item.VolaCont)
  22722. }
  22723. c.ServeSuccessJSON(map[string]interface{}{
  22724. "failed_code": -10,
  22725. "msg": errMsgs,
  22726. })
  22727. return
  22728. } else {
  22729. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  22730. if his.IdCardType != 4 {
  22731. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  22732. bas := strings.Split(psn_info.CardInfo, "|")
  22733. if his.IdCardType == 1 {
  22734. cert_no = bas[2]
  22735. } else {
  22736. cert_no = bas[1]
  22737. }
  22738. } else {
  22739. cert_no = his.Certno
  22740. }
  22741. //江苏地区国家医保医疗类别
  22742. //职工透析:医疗类别选特殊情况门诊9933
  22743. //居民血透门慢: 医疗类别选门诊慢病1402
  22744. //var med_type string
  22745. //if his.Insutype == "310" {
  22746. // if reg_type == 14 {
  22747. // med_type = "9933"
  22748. // } else if reg_type == 11 {
  22749. // med_type = "11"
  22750. //
  22751. // }
  22752. //} else if his.Insutype == "390" {
  22753. // if reg_type == 14 {
  22754. // med_type = "1402"
  22755. // } else if reg_type == 11 {
  22756. // med_type = "11"
  22757. // }
  22758. //}
  22759. var api string
  22760. if miConfig.MdtrtareaAdmvs == "320921" {
  22761. api = "http://192.168.2.3:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  22762. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  22763. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  22764. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  22765. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  22766. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  22767. "&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
  22768. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  22769. } else {
  22770. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  22771. api = "http://192.168.5.251:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  22772. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  22773. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  22774. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  22775. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  22776. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  22777. "&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
  22778. }
  22779. resp, requestErr := http.Get(api)
  22780. if requestErr != nil {
  22781. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22782. return
  22783. }
  22784. body, ioErr := ioutil.ReadAll(resp.Body)
  22785. if ioErr != nil {
  22786. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  22787. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22788. return
  22789. }
  22790. var respJSON map[string]interface{}
  22791. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  22792. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22793. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22794. return
  22795. }
  22796. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22797. result, _ := json.Marshal(respJSON)
  22798. fmt.Println("log")
  22799. fmt.Println(string(result))
  22800. if strings.Contains(miConfig.MdtrtareaAdmvs, "3209") {
  22801. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  22802. utils.ErrorLog("解析失败:%v", err)
  22803. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22804. return
  22805. }
  22806. res.InfRefmsgid = resSeven10265.InfRefmsgid
  22807. res.Output = resSeven10265.Output
  22808. res.ErrMsg = resSeven10265.ErrMsg
  22809. res.Cainfo = resSeven10265.Cainfo
  22810. res.WarnMsg = resSeven10265.WarnMsg
  22811. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  22812. res.Infcode = infocode
  22813. } else {
  22814. if err := json.Unmarshal([]byte(result), &resSeven10265Two); err != nil {
  22815. utils.ErrorLog("解析失败:%v", err)
  22816. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22817. return
  22818. }
  22819. res.InfRefmsgid = resSeven10265Two.InfRefmsgid
  22820. //AcctMulaidPay, _ := strconv.ParseFloat(resSeven10265Two.Output.Setlinfo.AcctMulaidPay, 64)
  22821. //res.Output.Setlinfo.AcctMulaidPay = AcctMulaidPay
  22822. res.Output.Setlinfo.AcctPay = resSeven10265Two.Output.Setlinfo.AcctPay
  22823. res.Output.Setlinfo.CvlservPay = resSeven10265Two.Output.Setlinfo.CvlservPay
  22824. res.Output.Setlinfo.ActPayDedc = resSeven10265Two.Output.Setlinfo.ActPayDedc
  22825. res.Output.Setlinfo.Age = resSeven10265Two.Output.Setlinfo.Age
  22826. res.Output.Setlinfo.Balc = resSeven10265Two.Output.Setlinfo.Balc
  22827. //res.Output.Setlinfo.Brdy = resSeven10265Two.Output.Setlinfo.Brdy
  22828. res.Output.Setlinfo.Certno = resSeven10265Two.Output.Setlinfo.Certno
  22829. res.Output.Setlinfo.ClrOptins = resSeven10265Two.Output.Setlinfo.ClrOptins
  22830. res.Output.Setlinfo.ClrType = resSeven10265Two.Output.Setlinfo.ClrOptins
  22831. res.Output.Setlinfo.ClrWay = resSeven10265Two.Output.Setlinfo.ClrOptins
  22832. res.Output.Setlinfo.CvlservFlag = resSeven10265Two.Output.Setlinfo.ClrOptins
  22833. res.Output.Setlinfo.CvlservPay = resSeven10265Two.Output.Setlinfo.CvlservPay
  22834. res.Output.Setlinfo.FulamtOwnpayAmt = resSeven10265Two.Output.Setlinfo.FulamtOwnpayAmt
  22835. res.Output.Setlinfo.FundPaySumamt = resSeven10265Two.Output.Setlinfo.FundPaySumamt
  22836. res.Output.Setlinfo.Gend = resSeven10265Two.Output.Setlinfo.Gend
  22837. res.Output.Setlinfo.HifesPay = resSeven10265Two.Output.Setlinfo.HifesPay
  22838. res.Output.Setlinfo.HifmiPay = resSeven10265Two.Output.Setlinfo.HifmiPay
  22839. res.Output.Setlinfo.HifpPay = resSeven10265Two.Output.Setlinfo.HifpPay
  22840. HospPartAmt, _ := strconv.ParseFloat(resSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  22841. res.Output.Setlinfo.HospPartAmt = HospPartAmt
  22842. res.Output.Setlinfo.InscpScpAmt = resSeven10265Two.Output.Setlinfo.InscpScpAmt
  22843. res.Output.Setlinfo.Insutype = resSeven10265Two.Output.Setlinfo.Insutype
  22844. res.Output.Setlinfo.MafPay = resSeven10265Two.Output.Setlinfo.MafPay
  22845. res.Output.Setlinfo.MdtrtCertType = resSeven10265Two.Output.Setlinfo.MdtrtCertType
  22846. res.Output.Setlinfo.HifobPay = resSeven10265Two.Output.Setlinfo.HifobPay
  22847. res.Output.Setlinfo.MdtrtID = resSeven10265Two.Output.Setlinfo.MdtrtID
  22848. res.Output.Setlinfo.MedType = resSeven10265Two.Output.Setlinfo.MedType
  22849. res.Output.Setlinfo.MedfeeSumamt = resSeven10265Two.Output.Setlinfo.MedfeeSumamt
  22850. res.Output.Setlinfo.MedinsSetlID = resSeven10265Two.Output.Setlinfo.MedinsSetlID
  22851. res.Output.Setlinfo.Naty = resSeven10265Two.Output.Setlinfo.Naty
  22852. res.Output.Setlinfo.OthPay = resSeven10265Two.Output.Setlinfo.OthPay
  22853. res.Output.Setlinfo.OverlmtSelfpay = resSeven10265Two.Output.Setlinfo.OverlmtSelfpay
  22854. PoolPropSelfpay, _ := strconv.ParseFloat(resSeven10265Two.Output.Setlinfo.PoolPropSelfpay, 64)
  22855. res.Output.Setlinfo.PoolPropSelfpay = PoolPropSelfpay
  22856. res.Output.Setlinfo.PreselfpayAmt = resSeven10265Two.Output.Setlinfo.PreselfpayAmt
  22857. res.Output.Setlinfo.PsnCashPay = resSeven10265Two.Output.Setlinfo.PsnCashPay
  22858. res.Output.Setlinfo.PsnCertType = resSeven10265Two.Output.Setlinfo.ClrOptins
  22859. res.Output.Setlinfo.PsnName = resSeven10265Two.Output.Setlinfo.PsnName
  22860. res.Output.Setlinfo.PsnNo = resSeven10265Two.Output.Setlinfo.PsnNo
  22861. res.Output.Setlinfo.PsnPartAmt = resSeven10265Two.Output.Setlinfo.PsnPartAmt
  22862. res.Output.Setlinfo.PsnType = resSeven10265Two.Output.Setlinfo.PsnType
  22863. res.Output.Setlinfo.SetlID = resSeven10265Two.Output.Setlinfo.SetlID
  22864. res.Output.Setlinfo.SetlTime = resSeven10265Two.Output.Setlinfo.SetlTime
  22865. //res.Output.Setldetail = resSeven10265Two.Output.Setldetail
  22866. res.ErrMsg = resSeven10265Two.ErrMsg
  22867. res.Cainfo = resSeven10265Two.Cainfo
  22868. res.WarnMsg = resSeven10265Two.WarnMsg
  22869. infocode, _ := strconv.ParseInt(resSeven10265Two.Infcode, 10, 64)
  22870. res.Infcode = infocode
  22871. }
  22872. }
  22873. }
  22874. } else if miConfig.MdtrtareaAdmvs == "150499" {
  22875. psn_info, _ := service.GetPsnByPatientId(id)
  22876. var verify_number string
  22877. if psn_info.IdCardType == 4 {
  22878. verify_number = psn_info.VerifyNumber
  22879. } else if psn_info.IdCardType == 1 {
  22880. bas := strings.Split(psn_info.CardInfo, "|")
  22881. cardNumber := bas[2]
  22882. verify_number = cardNumber
  22883. } else {
  22884. psn_info.IdCardType = 2
  22885. verify_number = psn_info.Certno
  22886. }
  22887. var api string
  22888. api = "http://172.16.13.254:9532/" + "nmyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  22889. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  22890. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  22891. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  22892. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(psn_info.IdCardType, 10) +
  22893. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  22894. "&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
  22895. resp, requestErr := http.Get(api)
  22896. if requestErr != nil {
  22897. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22898. return
  22899. }
  22900. body, ioErr := ioutil.ReadAll(resp.Body)
  22901. if ioErr != nil {
  22902. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  22903. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22904. return
  22905. }
  22906. var respJSON map[string]interface{}
  22907. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  22908. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22909. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22910. return
  22911. }
  22912. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22913. result, _ := json.Marshal(respJSON)
  22914. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  22915. utils.ErrorLog("解析失败:%v", err)
  22916. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22917. return
  22918. }
  22919. res.InfRefmsgid = resSeven10265.InfRefmsgid
  22920. res.Output.Setlinfo.AcctMulaidPay = resSeven10265.Output.Setlinfo.AcctMulaidPay
  22921. res.Output.Setlinfo.AcctPay = resSeven10265.Output.Setlinfo.AcctPay
  22922. res.Output.Setlinfo.CvlservPay = resSeven10265.Output.Setlinfo.CvlservPay
  22923. res.Output.Setlinfo.ActPayDedc = resSeven10265.Output.Setlinfo.ActPayDedc
  22924. res.Output.Setlinfo.Age = resSeven10265.Output.Setlinfo.Age
  22925. res.Output.Setlinfo.Balc = resSeven10265.Output.Setlinfo.Balc
  22926. //res.Output.Setlinfo.Brdy = resSeven10265.Output.Setlinfo.Brdy
  22927. res.Output.Setlinfo.Certno = resSeven10265.Output.Setlinfo.Certno
  22928. res.Output.Setlinfo.ClrOptins = resSeven10265.Output.Setlinfo.ClrOptins
  22929. res.Output.Setlinfo.ClrType = resSeven10265.Output.Setlinfo.ClrOptins
  22930. res.Output.Setlinfo.ClrWay = resSeven10265.Output.Setlinfo.ClrOptins
  22931. res.Output.Setlinfo.CvlservFlag = resSeven10265.Output.Setlinfo.ClrOptins
  22932. res.Output.Setlinfo.CvlservPay = resSeven10265.Output.Setlinfo.CvlservPay
  22933. res.Output.Setlinfo.FulamtOwnpayAmt = resSeven10265.Output.Setlinfo.FulamtOwnpayAmt
  22934. res.Output.Setlinfo.FundPaySumamt = resSeven10265.Output.Setlinfo.FundPaySumamt
  22935. res.Output.Setlinfo.Gend = resSeven10265.Output.Setlinfo.Gend
  22936. res.Output.Setlinfo.HifesPay = resSeven10265.Output.Setlinfo.HifesPay
  22937. res.Output.Setlinfo.HifmiPay = resSeven10265.Output.Setlinfo.HifmiPay
  22938. res.Output.Setlinfo.HifpPay = resSeven10265.Output.Setlinfo.HifpPay
  22939. //HospPartAmt, _ := strconv.ParseFloat(resSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  22940. res.Output.Setlinfo.HospPartAmt = resSeven10265.Output.Setlinfo.HospPartAmt
  22941. res.Output.Setlinfo.InscpScpAmt = resSeven10265.Output.Setlinfo.InscpScpAmt
  22942. res.Output.Setlinfo.Insutype = resSeven10265.Output.Setlinfo.Insutype
  22943. res.Output.Setlinfo.MafPay = resSeven10265.Output.Setlinfo.MafPay
  22944. res.Output.Setlinfo.MdtrtCertType = resSeven10265.Output.Setlinfo.MdtrtCertType
  22945. res.Output.Setlinfo.HifobPay = resSeven10265.Output.Setlinfo.HifobPay
  22946. res.Output.Setlinfo.MdtrtID = resSeven10265.Output.Setlinfo.MdtrtID
  22947. res.Output.Setlinfo.MedType = resSeven10265.Output.Setlinfo.MedType
  22948. res.Output.Setlinfo.MedfeeSumamt = resSeven10265.Output.Setlinfo.MedfeeSumamt
  22949. res.Output.Setlinfo.MedinsSetlID = resSeven10265.Output.Setlinfo.MedinsSetlID
  22950. res.Output.Setlinfo.Naty = resSeven10265.Output.Setlinfo.Naty
  22951. res.Output.Setlinfo.OthPay = resSeven10265.Output.Setlinfo.OthPay
  22952. res.Output.Setlinfo.OverlmtSelfpay = resSeven10265.Output.Setlinfo.OverlmtSelfpay
  22953. //PoolPropSelfpay, _ := strconv.ParseFloat(resSeven10265Two.Output.Setlinfo.PoolPropSelfpay, 64)
  22954. res.Output.Setlinfo.PoolPropSelfpay = resSeven10265.Output.Setlinfo.PoolPropSelfpay
  22955. res.Output.Setlinfo.PreselfpayAmt = resSeven10265.Output.Setlinfo.PreselfpayAmt
  22956. res.Output.Setlinfo.PsnCashPay = resSeven10265.Output.Setlinfo.PsnCashPay
  22957. res.Output.Setlinfo.PsnCertType = resSeven10265.Output.Setlinfo.ClrOptins
  22958. res.Output.Setlinfo.PsnName = resSeven10265.Output.Setlinfo.PsnName
  22959. res.Output.Setlinfo.PsnNo = resSeven10265.Output.Setlinfo.PsnNo
  22960. res.Output.Setlinfo.PsnPartAmt = resSeven10265.Output.Setlinfo.PsnPartAmt
  22961. res.Output.Setlinfo.PsnType = resSeven10265.Output.Setlinfo.PsnType
  22962. res.Output.Setlinfo.SetlID = resSeven10265.Output.Setlinfo.SetlID
  22963. res.Output.Setlinfo.SetlTime = resSeven10265.Output.Setlinfo.SetlTime
  22964. //res.Output.Setldetail = resSeven10265.Output.Setldetail
  22965. res.ErrMsg = resSeven10265.ErrMsg
  22966. res.Cainfo = resSeven10265.Cainfo
  22967. res.WarnMsg = resSeven10265.WarnMsg
  22968. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  22969. res.Infcode = infocode
  22970. } else if miConfig.MdtrtareaAdmvs == "350500" {
  22971. acct_used_flag := "1"
  22972. psn_info, _ := service.GetPsnByPatientIdTwo(his.PatientId)
  22973. var result string
  22974. var request_log string
  22975. if his.IdCardType == 4 && len(psn_info.VerifyNumber) > 0 {
  22976. 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)
  22977. } else {
  22978. 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)
  22979. }
  22980. var dat map[string]interface{}
  22981. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  22982. fmt.Println(dat)
  22983. } else {
  22984. fmt.Println(err)
  22985. }
  22986. saveLog(result, request_log, "2206", "预结算")
  22987. userJSONBytes, _ := json.Marshal(dat)
  22988. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  22989. utils.ErrorLog("解析失败:%v", err)
  22990. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22991. return
  22992. }
  22993. } else if miConfig.MdtrtareaAdmvs == "360302" {
  22994. var result string
  22995. var request_log string
  22996. if his.IdCardType == 2 {
  22997. 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, "")
  22998. } else if his.IdCardType == 1 {
  22999. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  23000. bas := strings.Split(psn_info.CardInfo, "|")
  23001. basNumber := bas[2]
  23002. card_sn := bas[3]
  23003. var rf []*ResultFive
  23004. json.Unmarshal([]byte(his.Iinfo), &rf)
  23005. var psn_type string
  23006. for _, item := range rf {
  23007. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  23008. psn_type = item.PsnType
  23009. }
  23010. }
  23011. 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)
  23012. } else {
  23013. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  23014. 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, "")
  23015. }
  23016. var dat map[string]interface{}
  23017. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  23018. fmt.Println(dat)
  23019. } else {
  23020. fmt.Println(err)
  23021. }
  23022. saveLog(result, request_log, "2206", "预结算")
  23023. userJSONBytes, _ := json.Marshal(dat)
  23024. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  23025. utils.ErrorLog("解析失败:%v", err)
  23026. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23027. return
  23028. }
  23029. } else if miConfig.MdtrtareaAdmvs == "341203" {
  23030. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  23031. if his.IdCardType == 4 {
  23032. psn_info.VerifyNumber = psn_info.VerifyNumber
  23033. cert_no = psn_info.Certno
  23034. } else if his.IdCardType == 2 {
  23035. cert_no = psn_info.Certno
  23036. psn_info.VerifyNumber = psn_info.Certno
  23037. } else {
  23038. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  23039. bas := strings.Split(psn_info.CardInfo, "|")
  23040. if his.IdCardType == 1 {
  23041. cert_no = bas[2]
  23042. } else {
  23043. cert_no = bas[1]
  23044. }
  23045. }
  23046. var api string
  23047. var med_type string
  23048. if his.Insutype == "390" {
  23049. if reg_type == 992102 {
  23050. med_type = "992102"
  23051. }
  23052. if reg_type == 140104 {
  23053. med_type = "140104"
  23054. }
  23055. if reg_type == 14 {
  23056. med_type = "140104"
  23057. }
  23058. } else if his.Insutype == "310" {
  23059. if reg_type == 992102 {
  23060. med_type = "992102"
  23061. }
  23062. if reg_type == 14 {
  23063. med_type = "14"
  23064. }
  23065. }
  23066. api = miConfig.SecretKey + "ahyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  23067. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  23068. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  23069. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  23070. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  23071. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  23072. "&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
  23073. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  23074. resp, requestErr := http.Get(api)
  23075. if requestErr != nil {
  23076. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23077. return
  23078. }
  23079. body, ioErr := ioutil.ReadAll(resp.Body)
  23080. if ioErr != nil {
  23081. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  23082. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23083. return
  23084. }
  23085. var respJSON map[string]interface{}
  23086. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  23087. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23088. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23089. return
  23090. }
  23091. status := respJSON["data"].(map[string]interface{})["status"].(string)
  23092. if status == "0" {
  23093. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  23094. c.ServeSuccessJSON(map[string]interface{}{
  23095. "failed_code": -10,
  23096. "msg": err_msg,
  23097. })
  23098. return
  23099. }
  23100. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23101. result, _ := json.Marshal(respJSON)
  23102. fmt.Println("log")
  23103. fmt.Println(string(result))
  23104. if err := json.Unmarshal([]byte(result), &ahres); err != nil {
  23105. utils.ErrorLog("解析失败:%v", err)
  23106. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23107. return
  23108. }
  23109. res.InfRefmsgid = ahres.InfRefmsgid
  23110. timestamp := int64(ahres.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  23111. // 创建对应的Time类型
  23112. t := time.UnixMilli(timestamp)
  23113. // 格式化成指定的日期字符串
  23114. str := t.Format("2006-01-02 15:04:05")
  23115. res.Output.Setlinfo.SetlTime = str
  23116. res.Output.Setlinfo.AcctMulaidPay = ahres.Output.Setlinfo.AcctMulaidPay
  23117. res.Output.Setlinfo.AcctPay = ahres.Output.Setlinfo.AcctPay
  23118. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  23119. res.Output.Setlinfo.ActPayDedc = ahres.Output.Setlinfo.ActPayDedc
  23120. res.Output.Setlinfo.Age = ahres.Output.Setlinfo.Age
  23121. res.Output.Setlinfo.Balc = ahres.Output.Setlinfo.Balc
  23122. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  23123. res.Output.Setlinfo.Certno = ahres.Output.Setlinfo.Certno
  23124. res.Output.Setlinfo.ClrOptins = ahres.Output.Setlinfo.ClrOptins
  23125. res.Output.Setlinfo.ClrType = ahres.Output.Setlinfo.ClrOptins
  23126. res.Output.Setlinfo.ClrWay = ahres.Output.Setlinfo.ClrOptins
  23127. res.Output.Setlinfo.CvlservFlag = ahres.Output.Setlinfo.ClrOptins
  23128. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  23129. res.Output.Setlinfo.FulamtOwnpayAmt = ahres.Output.Setlinfo.FulamtOwnpayAmt
  23130. res.Output.Setlinfo.FundPaySumamt = ahres.Output.Setlinfo.FundPaySumamt
  23131. res.Output.Setlinfo.Gend = ahres.Output.Setlinfo.Gend
  23132. res.Output.Setlinfo.HifesPay = ahres.Output.Setlinfo.HifesPay
  23133. res.Output.Setlinfo.HifmiPay = ahres.Output.Setlinfo.HifmiPay
  23134. res.Output.Setlinfo.HifpPay = ahres.Output.Setlinfo.HifpPay
  23135. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  23136. res.Output.Setlinfo.HospPartAmt = ahres.Output.Setlinfo.HospPartAmt
  23137. res.Output.Setlinfo.InscpScpAmt = ahres.Output.Setlinfo.InscpScpAmt
  23138. res.Output.Setlinfo.Insutype = ahres.Output.Setlinfo.Insutype
  23139. res.Output.Setlinfo.MafPay = ahres.Output.Setlinfo.MafPay
  23140. res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  23141. res.Output.Setlinfo.HifobPay = ahres.Output.Setlinfo.HifobPay
  23142. res.Output.Setlinfo.MdtrtID = ahres.Output.Setlinfo.MdtrtID
  23143. res.Output.Setlinfo.MedType = ahres.Output.Setlinfo.MedType
  23144. res.Output.Setlinfo.MedfeeSumamt = ahres.Output.Setlinfo.MedfeeSumamt
  23145. res.Output.Setlinfo.MedinsSetlID = ahres.Output.Setlinfo.MedinsSetlID
  23146. res.Output.Setlinfo.Naty = ahres.Output.Setlinfo.Naty
  23147. res.Output.Setlinfo.OthPay = ahres.Output.Setlinfo.OthPay
  23148. res.Output.Setlinfo.OverlmtSelfpay = ahres.Output.Setlinfo.OverlmtSelfpay
  23149. res.Output.Setlinfo.PoolPropSelfpay = ahres.Output.Setlinfo.PoolPropSelfpay
  23150. res.Output.Setlinfo.PreselfpayAmt = ahres.Output.Setlinfo.PreselfpayAmt
  23151. res.Output.Setlinfo.PsnCashPay = ahres.Output.Setlinfo.PsnCashPay
  23152. res.Output.Setlinfo.PsnCertType = ahres.Output.Setlinfo.ClrOptins
  23153. res.Output.Setlinfo.PsnName = ahres.Output.Setlinfo.PsnName
  23154. res.Output.Setlinfo.PsnNo = ahres.Output.Setlinfo.PsnNo
  23155. res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  23156. res.Output.Setlinfo.PsnType = ahres.Output.Setlinfo.PsnType
  23157. res.Output.Setlinfo.SetlID = ahres.Output.Setlinfo.SetlID
  23158. //res.Output.Setldetail = ahres.Output.Setldetail
  23159. res.ErrMsg = ahres.ErrMsg
  23160. res.Cainfo = ahres.Cainfo
  23161. res.WarnMsg = ahres.WarnMsg
  23162. res.Infcode = ahres.Infcode
  23163. } else if miConfig.MdtrtareaAdmvs == "430800" {
  23164. var result string
  23165. var request_log string
  23166. if his.IdCardType == 2 {
  23167. 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")
  23168. } else if his.IdCardType == 1 {
  23169. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  23170. bas := strings.Split(psn_info.CardInfo, "|")
  23171. basNumber := bas[2]
  23172. card_sn := bas[3]
  23173. 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")
  23174. } else {
  23175. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  23176. 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")
  23177. }
  23178. var dat map[string]interface{}
  23179. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  23180. fmt.Println(dat)
  23181. } else {
  23182. fmt.Println(err)
  23183. }
  23184. saveLog(result, request_log, "2206", "预结算")
  23185. userJSONBytes, _ := json.Marshal(dat)
  23186. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  23187. utils.ErrorLog("解析失败:%v", err)
  23188. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23189. return
  23190. }
  23191. } else if miConfig.MdtrtareaAdmvs == "441799" {
  23192. api := miConfig.Url + "gdyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  23193. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  23194. "&operator=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  23195. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  23196. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  23197. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  23198. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  23199. resp, requestErr := http.Get(api)
  23200. if requestErr != nil {
  23201. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23202. return
  23203. }
  23204. body, ioErr := ioutil.ReadAll(resp.Body)
  23205. if ioErr != nil {
  23206. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  23207. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23208. return
  23209. }
  23210. var respJSON map[string]interface{}
  23211. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  23212. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23213. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23214. return
  23215. }
  23216. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23217. result, _ := json.Marshal(respJSON)
  23218. fmt.Println("log")
  23219. fmt.Println(string(result))
  23220. if err := json.Unmarshal([]byte(result), &res); err != nil {
  23221. utils.ErrorLog("解析失败:%v", err)
  23222. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23223. return
  23224. }
  23225. } else {
  23226. if miConfig.MdtrtareaAdmvs == "441202" {
  23227. result3101 := Checkgd3102(c, id, his_patient_id, admin_user_id, "6", order.ID)
  23228. if result3101.Infcode == 0 {
  23229. if len(result3101.Output.Result) > 0 {
  23230. var errMsgs []string
  23231. for _, item := range result3101.Output.Result {
  23232. errMsgs = append(errMsgs, item.VolaCont)
  23233. }
  23234. c.ServeSuccessJSON(map[string]interface{}{
  23235. "failed_code": -10,
  23236. "msg": errMsgs,
  23237. })
  23238. return
  23239. } else {
  23240. var result string
  23241. var request_log string
  23242. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  23243. allTotal = fmt.Sprintf("%.2f", total_two)
  23244. if his.IdCardType == 4 {
  23245. 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)
  23246. } else {
  23247. 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)
  23248. }
  23249. var dat map[string]interface{}
  23250. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  23251. fmt.Println(dat)
  23252. } else {
  23253. fmt.Println(err)
  23254. }
  23255. saveLog(result, request_log, "2206", "预结算")
  23256. //userJSONBytes, _ := json.Marshal(dat)
  23257. //
  23258. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  23259. // utils.ErrorLog("解析失败:%v", err)
  23260. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23261. // return
  23262. //}
  23263. userJSONBytes, _ := json.Marshal(dat)
  23264. if miConfig.Code == "H15049901371" {
  23265. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  23266. utils.ErrorLog("解析失败:%v", err)
  23267. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23268. return
  23269. }
  23270. res.InfRefmsgid = resSeven10265.InfRefmsgid
  23271. res.Output = resSeven10265.Output
  23272. res.ErrMsg = resSeven10265.ErrMsg
  23273. res.Cainfo = resSeven10265.Cainfo
  23274. res.WarnMsg = resSeven10265.WarnMsg
  23275. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  23276. res.Infcode = infocode
  23277. } else {
  23278. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  23279. utils.ErrorLog("解析失败:%v", err)
  23280. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23281. return
  23282. }
  23283. }
  23284. }
  23285. } else {
  23286. c.ServeSuccessJSON(map[string]interface{}{
  23287. "failed_code": -10,
  23288. "msg": result3101.ErrMsg,
  23289. })
  23290. return
  23291. }
  23292. } else {
  23293. var result string
  23294. var request_log string
  23295. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  23296. allTotal = fmt.Sprintf("%.2f", total_two)
  23297. if his.IdCardType == 4 {
  23298. 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)
  23299. } else {
  23300. 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)
  23301. }
  23302. var dat map[string]interface{}
  23303. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  23304. fmt.Println(dat)
  23305. } else {
  23306. fmt.Println(err)
  23307. }
  23308. saveLog(result, request_log, "2206", "预结算")
  23309. //userJSONBytes, _ := json.Marshal(dat)
  23310. //
  23311. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  23312. // utils.ErrorLog("解析失败:%v", err)
  23313. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23314. // return
  23315. //}
  23316. userJSONBytes, _ := json.Marshal(dat)
  23317. if miConfig.Code == "H15049901371" {
  23318. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  23319. utils.ErrorLog("解析失败:%v", err)
  23320. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23321. return
  23322. }
  23323. res.InfRefmsgid = resSeven10265.InfRefmsgid
  23324. res.Output = resSeven10265.Output
  23325. res.ErrMsg = resSeven10265.ErrMsg
  23326. res.Cainfo = resSeven10265.Cainfo
  23327. res.WarnMsg = resSeven10265.WarnMsg
  23328. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  23329. res.Infcode = infocode
  23330. } else {
  23331. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  23332. if err := json.Unmarshal(userJSONBytes, &gzresSeven10265Two); err != nil {
  23333. utils.ErrorLog("解析失败:%v", err)
  23334. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23335. return
  23336. }
  23337. res.InfRefmsgid = gzresSeven10265Two.InfRefmsgid
  23338. res.Output.Setlinfo.AcctMulaidPay = gzresSeven10265Two.Output.Setlinfo.AcctMulaidPay
  23339. res.Output.Setlinfo.AcctPay = gzresSeven10265Two.Output.Setlinfo.AcctPay
  23340. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  23341. res.Output.Setlinfo.ActPayDedc = gzresSeven10265Two.Output.Setlinfo.ActPayDedc
  23342. res.Output.Setlinfo.Age = gzresSeven10265Two.Output.Setlinfo.Age
  23343. res.Output.Setlinfo.Balc = gzresSeven10265Two.Output.Setlinfo.Balc
  23344. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  23345. res.Output.Setlinfo.Certno = gzresSeven10265Two.Output.Setlinfo.Certno
  23346. res.Output.Setlinfo.ClrOptins = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  23347. res.Output.Setlinfo.ClrType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  23348. res.Output.Setlinfo.ClrWay = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  23349. res.Output.Setlinfo.CvlservFlag = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  23350. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  23351. res.Output.Setlinfo.FulamtOwnpayAmt = gzresSeven10265Two.Output.Setlinfo.FulamtOwnpayAmt
  23352. res.Output.Setlinfo.FundPaySumamt = gzresSeven10265Two.Output.Setlinfo.FundPaySumamt
  23353. res.Output.Setlinfo.Gend = gzresSeven10265Two.Output.Setlinfo.Gend
  23354. res.Output.Setlinfo.HifesPay = gzresSeven10265Two.Output.Setlinfo.HifesPay
  23355. res.Output.Setlinfo.HifmiPay = gzresSeven10265Two.Output.Setlinfo.HifmiPay
  23356. res.Output.Setlinfo.HifpPay = gzresSeven10265Two.Output.Setlinfo.HifpPay
  23357. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  23358. res.Output.Setlinfo.HospPartAmt = gzresSeven10265Two.Output.Setlinfo.HospPartAmt
  23359. res.Output.Setlinfo.InscpScpAmt = gzresSeven10265Two.Output.Setlinfo.InscpScpAmt
  23360. res.Output.Setlinfo.Insutype = gzresSeven10265Two.Output.Setlinfo.Insutype
  23361. res.Output.Setlinfo.MafPay = gzresSeven10265Two.Output.Setlinfo.MafPay
  23362. res.Output.Setlinfo.MdtrtCertType = gzresSeven10265Two.Output.Setlinfo.MdtrtCertType
  23363. res.Output.Setlinfo.HifobPay = gzresSeven10265Two.Output.Setlinfo.HifobPay
  23364. res.Output.Setlinfo.MdtrtID = gzresSeven10265Two.Output.Setlinfo.MdtrtID
  23365. res.Output.Setlinfo.MedType = gzresSeven10265Two.Output.Setlinfo.MedType
  23366. res.Output.Setlinfo.MedfeeSumamt = gzresSeven10265Two.Output.Setlinfo.MedfeeSumamt
  23367. res.Output.Setlinfo.MedinsSetlID = gzresSeven10265Two.Output.Setlinfo.MedinsSetlID
  23368. res.Output.Setlinfo.Naty = gzresSeven10265Two.Output.Setlinfo.Naty
  23369. res.Output.Setlinfo.OthPay = gzresSeven10265Two.Output.Setlinfo.OthPay
  23370. res.Output.Setlinfo.OverlmtSelfpay = gzresSeven10265Two.Output.Setlinfo.OverlmtSelfpay
  23371. PoolPropSelfpay, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.PoolPropSelfpay, 64)
  23372. res.Output.Setlinfo.PoolPropSelfpay = PoolPropSelfpay
  23373. res.Output.Setlinfo.PreselfpayAmt = gzresSeven10265Two.Output.Setlinfo.PreselfpayAmt
  23374. res.Output.Setlinfo.PsnCashPay = gzresSeven10265Two.Output.Setlinfo.PsnCashPay
  23375. res.Output.Setlinfo.PsnCertType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  23376. res.Output.Setlinfo.PsnName = gzresSeven10265Two.Output.Setlinfo.PsnName
  23377. res.Output.Setlinfo.PsnNo = gzresSeven10265Two.Output.Setlinfo.PsnNo
  23378. res.Output.Setlinfo.PsnPartAmt = gzresSeven10265Two.Output.Setlinfo.PsnPartAmt
  23379. res.Output.Setlinfo.PsnType = gzresSeven10265Two.Output.Setlinfo.PsnType
  23380. res.Output.Setlinfo.SetlID = gzresSeven10265Two.Output.Setlinfo.SetlID
  23381. res.Output.Setlinfo.SetlTime = gzresSeven10265Two.Output.Setlinfo.SetlTime
  23382. //res.Output.Setldetail = gzresSeven10265Two.Output.Setldetail
  23383. res.ErrMsg = gzresSeven10265Two.ErrMsg
  23384. res.Cainfo = gzresSeven10265Two.Cainfo
  23385. res.WarnMsg = gzresSeven10265Two.WarnMsg
  23386. //infocode, _ := strconv.ParseInt(resSeven10265Two.Infcode, 10, 64)
  23387. //res.Infcode = infocode
  23388. } else {
  23389. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  23390. utils.ErrorLog("解析失败:%v", err)
  23391. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23392. return
  23393. }
  23394. }
  23395. }
  23396. }
  23397. }
  23398. utils.ErrorLog("解析失败:%v", res.Infcode)
  23399. if res.Infcode == -1 {
  23400. errlog := &models.HisOrderError{
  23401. UserOrgId: adminUser.CurrentOrgId,
  23402. Ctime: time.Now().Unix(),
  23403. Mtime: time.Now().Unix(),
  23404. Number: chrg_bchno,
  23405. ErrMsg: res.ErrMsg,
  23406. Status: 1,
  23407. PatientId: id,
  23408. RecordTime: recordDateTime,
  23409. Stage: 20,
  23410. }
  23411. service.CreateErrMsgLog(errlog)
  23412. c.ServeSuccessJSON(map[string]interface{}{
  23413. "failed_code": -10,
  23414. "msg": res.ErrMsg,
  23415. })
  23416. return
  23417. }
  23418. if res.Infcode != 0 {
  23419. errlog := &models.HisOrderError{
  23420. UserOrgId: adminUser.CurrentOrgId,
  23421. Ctime: time.Now().Unix(),
  23422. Mtime: time.Now().Unix(),
  23423. Number: chrg_bchno,
  23424. ErrMsg: res.ErrMsg,
  23425. Status: 1,
  23426. PatientId: id,
  23427. RecordTime: recordDateTime,
  23428. Stage: 20,
  23429. }
  23430. service.CreateErrMsgLog(errlog)
  23431. c.ServeSuccessJSON(map[string]interface{}{
  23432. "failed_code": -10,
  23433. "msg": res.ErrMsg,
  23434. })
  23435. return
  23436. } else {
  23437. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  23438. order.OrderStatus = 1
  23439. order.IsPre = 1
  23440. order.Status = 1
  23441. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  23442. order.SetlId = res.Output.Setlinfo.SetlID
  23443. order.PsnNo = res.Output.Setlinfo.PsnNo
  23444. order.PsnName = res.Output.Setlinfo.PsnName
  23445. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  23446. order.Certno = res.Output.Setlinfo.Certno
  23447. order.Gend = res.Output.Setlinfo.Gend
  23448. order.Naty = res.Output.Setlinfo.Naty
  23449. order.Age = res.Output.Setlinfo.Age
  23450. order.Insutype = res.Output.Setlinfo.Insutype
  23451. order.PsnType = res.Output.Setlinfo.PsnType
  23452. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  23453. order.SetlTime = res.Output.Setlinfo.SetlTime
  23454. order.AcctUsedFlag = acct_used_flag
  23455. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  23456. if res.Output.Setlinfo.MedType == "140101" {
  23457. order.MedType = "14"
  23458. } else {
  23459. if res.Output.Setlinfo.MedType == "110104" {
  23460. order.MedType = "11"
  23461. } else {
  23462. order.MedType = res.Output.Setlinfo.MedType
  23463. }
  23464. }
  23465. if res.Output.Setlinfo.MedType == "992102" {
  23466. order.MedType = "992102"
  23467. }
  23468. if res.Output.Setlinfo.MedType == "140104" {
  23469. order.MedType = "140104"
  23470. }
  23471. if res.Output.Setlinfo.MedType == "14" {
  23472. order.MedType = "14"
  23473. }
  23474. if reg_type == 1112 {
  23475. order.MedType = "1112"
  23476. }
  23477. if reg_type == 1111 {
  23478. order.MedType = "1111"
  23479. }
  23480. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  23481. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  23482. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  23483. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  23484. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  23485. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  23486. order.HifpPay = res.Output.Setlinfo.HifpPay
  23487. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  23488. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  23489. order.HifesPay = res.Output.Setlinfo.HifesPay
  23490. order.HifobPay = res.Output.Setlinfo.HifobPay
  23491. order.MafPay = res.Output.Setlinfo.MafPay
  23492. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  23493. order.OthPay = res.Output.Setlinfo.OthPay
  23494. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  23495. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  23496. order.AcctPay = res.Output.Setlinfo.AcctPay
  23497. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  23498. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  23499. order.Balc = res.Output.Setlinfo.Balc
  23500. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  23501. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  23502. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  23503. order.ClrWay = res.Output.Setlinfo.ClrWay
  23504. order.Creator = order.Creator
  23505. order.Modify = roles.AdminUserId
  23506. //setlDetail, _ := json.Marshal(res.Output.Setldetail)
  23507. //detailStr := string(setlDetail)
  23508. //order.SetlDetail = detailStr
  23509. //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  23510. err = service.UpDateOrder(order)
  23511. if err == nil {
  23512. c.ServeSuccessJSON(map[string]interface{}{
  23513. "msg": "预结算成功",
  23514. })
  23515. } else {
  23516. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  23517. return
  23518. }
  23519. }
  23520. } else {
  23521. adminUser := c.GetAdminUserInfo()
  23522. errlog := &models.HisOrderError{
  23523. UserOrgId: adminUser.CurrentOrgId,
  23524. Ctime: time.Now().Unix(),
  23525. Mtime: time.Now().Unix(),
  23526. ErrMsg: res.ErrMsg,
  23527. Status: 1,
  23528. PatientId: id,
  23529. RecordTime: recordDateTime,
  23530. Stage: 4,
  23531. }
  23532. service.CreateErrMsgLog(errlog)
  23533. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  23534. return
  23535. }
  23536. } else {
  23537. if miConfig.MdtrtareaAdmvs == "150499" {
  23538. order := &models.HisOrder{
  23539. UserOrgId: adminUser.CurrentOrgId,
  23540. HisPatientId: his.ID,
  23541. PatientId: his.PatientId,
  23542. SettleAccountsDate: recordDateTime,
  23543. Ctime: time.Now().Unix(),
  23544. Mtime: time.Now().Unix(),
  23545. MdtrtId: his.Number,
  23546. PsnNo: his.PsnNo,
  23547. MedType: strconv.FormatInt(reg_type, 10),
  23548. Status: 1,
  23549. Number: chrg_bchno,
  23550. Infcode: res.Infcode,
  23551. WarnMsg: res.WarnMsg,
  23552. Cainfo: res.Cainfo,
  23553. ErrMsg: res.ErrMsg,
  23554. RespondTime: res.RefmsgTime,
  23555. InfRefmsgid: res.InfRefmsgid,
  23556. OrderStatus: 1,
  23557. IsMedicineInsurance: 1,
  23558. SettleType: settle_accounts_type,
  23559. SettleStartTime: start_time,
  23560. SettleEndTime: end_time,
  23561. Creator: roles.AdminUserId,
  23562. Modify: roles.AdminUserId,
  23563. PType: 2,
  23564. Diagnosis: diagnosis_id,
  23565. }
  23566. err = service.CreateOrder(order)
  23567. if err != nil {
  23568. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  23569. return
  23570. }
  23571. }
  23572. adminUser := c.GetAdminUserInfo()
  23573. errlog := &models.HisOrderError{
  23574. UserOrgId: adminUser.CurrentOrgId,
  23575. Ctime: time.Now().Unix(),
  23576. Mtime: time.Now().Unix(),
  23577. ErrMsg: res.ErrMsg,
  23578. Status: 1,
  23579. PatientId: id,
  23580. RecordTime: recordDateTime,
  23581. Stage: 4,
  23582. }
  23583. service.CreateErrMsgLog(errlog)
  23584. c.ServeSuccessJSON(map[string]interface{}{
  23585. "failed_code": -10,
  23586. "msg": res.ErrMsg,
  23587. })
  23588. return
  23589. }
  23590. }
  23591. }
  23592. }
  23593. // 退款
  23594. func (c *HisApiController) Refund() {
  23595. order_id, _ := c.GetInt64("order_id")
  23596. admin_user_id, _ := c.GetInt64("admin_user_id")
  23597. adminUser := c.GetAdminUserInfo()
  23598. var order models.HisOrder
  23599. order, _ = service.GetHisOrderByID(order_id)
  23600. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  23601. if order.ID == 0 {
  23602. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  23603. return
  23604. }
  23605. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  23606. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  23607. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  23608. if config.IsOpen == 1 { //对接了医保,走医保流程
  23609. var res ResultSixteen
  23610. var ahres ResultSevenAH
  23611. var resSixteen10265 ResultSixteen10265
  23612. var resSixteen10265Two ResultSixteen10265Two
  23613. var gz ResultgzSixteen10265Two
  23614. var src_resquest string
  23615. var result string
  23616. if miConfig.MdtrtareaAdmvs == "421300" {
  23617. api3 := "http://192.168.124.4:9532/" + "hbyb/2208?psn_no=" + order.PsnNo +
  23618. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  23619. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  23620. resp3, requestErr3 := http.Get(api3)
  23621. if requestErr3 != nil {
  23622. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23623. return
  23624. }
  23625. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  23626. if ioErr3 != nil {
  23627. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  23628. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23629. return
  23630. }
  23631. var respJSON3 map[string]interface{}
  23632. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  23633. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23634. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23635. return
  23636. }
  23637. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23638. userJSONBytes3, _ := json.Marshal(respJSON3)
  23639. fmt.Println("log")
  23640. fmt.Println(string(userJSONBytes3))
  23641. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  23642. utils.ErrorLog("解析失败:%v", err)
  23643. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23644. return
  23645. }
  23646. } else if miConfig.MdtrtareaAdmvs == "420200" {
  23647. api3 := "http://192.168.0.197:9532/" + "hbyb/2208?psn_no=" + order.PsnNo +
  23648. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  23649. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  23650. resp3, requestErr3 := http.Get(api3)
  23651. if requestErr3 != nil {
  23652. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23653. return
  23654. }
  23655. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  23656. if ioErr3 != nil {
  23657. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  23658. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23659. return
  23660. }
  23661. var respJSON3 map[string]interface{}
  23662. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  23663. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23664. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23665. return
  23666. }
  23667. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23668. userJSONBytes3, _ := json.Marshal(respJSON3)
  23669. fmt.Println("log")
  23670. fmt.Println(string(userJSONBytes3))
  23671. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  23672. utils.ErrorLog("解析失败:%v", err)
  23673. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23674. return
  23675. }
  23676. } else if miConfig.MdtrtareaAdmvs == "420902" {
  23677. api3 := miConfig.Url + "hbyb/2208?psn_no=" + order.PsnNo +
  23678. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  23679. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  23680. resp3, requestErr3 := http.Get(api3)
  23681. if requestErr3 != nil {
  23682. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23683. return
  23684. }
  23685. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  23686. if ioErr3 != nil {
  23687. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  23688. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23689. return
  23690. }
  23691. var respJSON3 map[string]interface{}
  23692. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  23693. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23694. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23695. return
  23696. }
  23697. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23698. userJSONBytes3, _ := json.Marshal(respJSON3)
  23699. fmt.Println("log")
  23700. fmt.Println(string(userJSONBytes3))
  23701. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  23702. utils.ErrorLog("解析失败:%v", err)
  23703. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23704. return
  23705. }
  23706. } else if miConfig.MdtrtareaAdmvs == "421182" {
  23707. api3 := miConfig.Url + "hbyb/2208?psn_no=" + order.PsnNo +
  23708. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  23709. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  23710. resp3, requestErr3 := http.Get(api3)
  23711. if requestErr3 != nil {
  23712. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23713. return
  23714. }
  23715. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  23716. if ioErr3 != nil {
  23717. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  23718. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23719. return
  23720. }
  23721. var respJSON3 map[string]interface{}
  23722. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  23723. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23724. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23725. return
  23726. }
  23727. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23728. userJSONBytes3, _ := json.Marshal(respJSON3)
  23729. fmt.Println("log")
  23730. fmt.Println(string(userJSONBytes3))
  23731. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  23732. utils.ErrorLog("解析失败:%v", err)
  23733. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23734. return
  23735. }
  23736. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  23737. var api3 string
  23738. if miConfig.MdtrtareaAdmvs == "320921" {
  23739. api3 = "http://192.168.2.3:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  23740. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  23741. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  23742. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  23743. } else {
  23744. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  23745. api3 = "http://192.168.5.251:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  23746. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  23747. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  23748. }
  23749. resp3, requestErr3 := http.Get(api3)
  23750. if requestErr3 != nil {
  23751. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23752. return
  23753. }
  23754. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  23755. if ioErr3 != nil {
  23756. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  23757. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23758. return
  23759. }
  23760. var respJSON3 map[string]interface{}
  23761. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  23762. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23763. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23764. return
  23765. }
  23766. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23767. userJSONBytes3, _ := json.Marshal(respJSON3)
  23768. if err := json.Unmarshal(userJSONBytes3, &resSixteen10265Two); err != nil {
  23769. utils.ErrorLog("解析失败:%v", err)
  23770. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23771. return
  23772. }
  23773. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  23774. res.Output = resSixteen10265.Output
  23775. res.ErrMsg = resSixteen10265.ErrMsg
  23776. res.Cainfo = resSixteen10265.Cainfo
  23777. res.WarnMsg = resSixteen10265.WarnMsg
  23778. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  23779. res.Infcode = infocode
  23780. } else if miConfig.MdtrtareaAdmvs == "150499" {
  23781. var api3 string
  23782. api3 = "http://172.16.13.254:9532/" + "nmyb/2208?psn_no=" + order.PsnNo +
  23783. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  23784. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  23785. resp3, requestErr3 := http.Get(api3)
  23786. if requestErr3 != nil {
  23787. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23788. return
  23789. }
  23790. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  23791. if ioErr3 != nil {
  23792. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  23793. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23794. return
  23795. }
  23796. var respJSON3 map[string]interface{}
  23797. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  23798. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23799. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23800. return
  23801. }
  23802. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23803. userJSONBytes3, _ := json.Marshal(respJSON3)
  23804. if err := json.Unmarshal(userJSONBytes3, &resSixteen10265Two); err != nil {
  23805. utils.ErrorLog("解析失败:%v", err)
  23806. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23807. return
  23808. }
  23809. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  23810. res.Output = resSixteen10265.Output
  23811. res.ErrMsg = resSixteen10265.ErrMsg
  23812. res.Cainfo = resSixteen10265.Cainfo
  23813. res.WarnMsg = resSixteen10265.WarnMsg
  23814. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  23815. res.Infcode = infocode
  23816. } else if miConfig.MdtrtareaAdmvs == "350500" {
  23817. 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)
  23818. var dat map[string]interface{}
  23819. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  23820. fmt.Println(dat)
  23821. } else {
  23822. fmt.Println(err)
  23823. }
  23824. saveLog(result, src_resquest, "2208", "退费")
  23825. userJSONBytes, _ := json.Marshal(dat)
  23826. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  23827. utils.ErrorLog("解析失败:%v", err)
  23828. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23829. return
  23830. }
  23831. } else if miConfig.MdtrtareaAdmvs == "360302" {
  23832. 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, "")
  23833. var dat map[string]interface{}
  23834. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  23835. fmt.Println(dat)
  23836. } else {
  23837. fmt.Println(err)
  23838. }
  23839. saveLog(result, src_resquest, "2208", "退费")
  23840. userJSONBytes, _ := json.Marshal(dat)
  23841. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  23842. utils.ErrorLog("解析失败:%v", err)
  23843. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23844. return
  23845. }
  23846. } else if miConfig.MdtrtareaAdmvs == "341203" {
  23847. var api3 string
  23848. api3 = miConfig.SecretKey + "ahyb/2208?psn_no=" + order.PsnNo +
  23849. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  23850. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  23851. resp3, requestErr3 := http.Get(api3)
  23852. if requestErr3 != nil {
  23853. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23854. return
  23855. }
  23856. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  23857. if ioErr3 != nil {
  23858. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  23859. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23860. return
  23861. }
  23862. var respJSON3 map[string]interface{}
  23863. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  23864. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23865. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23866. return
  23867. }
  23868. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  23869. if status == "0" {
  23870. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  23871. c.ServeSuccessJSON(map[string]interface{}{
  23872. "failed_code": -10,
  23873. "msg": err_msg,
  23874. })
  23875. return
  23876. }
  23877. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23878. userJSONBytes3, _ := json.Marshal(respJSON3)
  23879. //if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  23880. // utils.ErrorLog("解析失败:%v", err)
  23881. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23882. // return
  23883. //}
  23884. if err := json.Unmarshal(userJSONBytes3, &ahres); err != nil {
  23885. utils.ErrorLog("解析失败:%v", err)
  23886. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23887. return
  23888. }
  23889. res.InfRefmsgid = ahres.InfRefmsgid
  23890. timestamp := int64(ahres.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  23891. // 创建对应的Time类型
  23892. t := time.UnixMilli(timestamp)
  23893. // 格式化成指定的日期字符串
  23894. str := t.Format("2006-01-02 15:04:05")
  23895. res.Output.Setlinfo.SetlTime = str
  23896. res.Output.Setlinfo.AcctMulaidPay = ahres.Output.Setlinfo.AcctMulaidPay
  23897. res.Output.Setlinfo.AcctPay = ahres.Output.Setlinfo.AcctPay
  23898. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  23899. res.Output.Setlinfo.ActPayDedc = ahres.Output.Setlinfo.ActPayDedc
  23900. //res.Output.Setlinfo.Age = ahres.Output.Setlinfo.Age
  23901. res.Output.Setlinfo.Balc = ahres.Output.Setlinfo.Balc
  23902. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  23903. //res.Output.Setlinfo.Certno = ahres.Output.Setlinfo.Certno
  23904. res.Output.Setlinfo.ClrOptins = ahres.Output.Setlinfo.ClrOptins
  23905. //
  23906. //res.Output.Setlinfo.ClrType = ahres.Output.Setlinfo.ClrOptins
  23907. //res.Output.Setlinfo.ClrWay = ahres.Output.Setlinfo.ClrOptins
  23908. //res.Output.Setlinfo.CvlservFlag = ahres.Output.Setlinfo.ClrOptins
  23909. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  23910. res.Output.Setlinfo.FulamtOwnpayAmt = ahres.Output.Setlinfo.FulamtOwnpayAmt
  23911. res.Output.Setlinfo.FundPaySumamt = ahres.Output.Setlinfo.FundPaySumamt
  23912. //res.Output.Setlinfo.Gend = ahres.Output.Setlinfo.Gend
  23913. res.Output.Setlinfo.HifesPay = ahres.Output.Setlinfo.HifesPay
  23914. res.Output.Setlinfo.HifmiPay = ahres.Output.Setlinfo.HifmiPay
  23915. res.Output.Setlinfo.HifpPay = ahres.Output.Setlinfo.HifpPay
  23916. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  23917. res.Output.Setlinfo.HospPartAmt = ahres.Output.Setlinfo.HospPartAmt
  23918. res.Output.Setlinfo.InscpScpAmt = ahres.Output.Setlinfo.InscpScpAmt
  23919. //res.Output.Setlinfo.Insutype = ahres.Output.Setlinfo.Insutype
  23920. res.Output.Setlinfo.MafPay = ahres.Output.Setlinfo.MafPay
  23921. //res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  23922. res.Output.Setlinfo.HifobPay = ahres.Output.Setlinfo.HifobPay
  23923. res.Output.Setlinfo.MdtrtID = ahres.Output.Setlinfo.MdtrtID
  23924. //res.Output.Setlinfo.MedType = ahres.Output.Setlinfo.MedType
  23925. res.Output.Setlinfo.MedfeeSumamt = ahres.Output.Setlinfo.MedfeeSumamt
  23926. res.Output.Setlinfo.MedinsSetlID = ahres.Output.Setlinfo.MedinsSetlID
  23927. //res.Output.Setlinfo.Naty = ahres.Output.Setlinfo.Naty
  23928. res.Output.Setlinfo.OthPay = ahres.Output.Setlinfo.OthPay
  23929. res.Output.Setlinfo.OverlmtSelfpay = ahres.Output.Setlinfo.OverlmtSelfpay
  23930. res.Output.Setlinfo.PreselfpayAmt = ahres.Output.Setlinfo.PreselfpayAmt
  23931. res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  23932. res.Output.Setlinfo.SetlID = ahres.Output.Setlinfo.SetlID
  23933. //res.Output.Setldetail = ahres.Output.Setldetail
  23934. res.ErrMsg = ahres.ErrMsg
  23935. res.Cainfo = ahres.Cainfo
  23936. res.WarnMsg = ahres.WarnMsg
  23937. res.Infcode = ahres.Infcode
  23938. } else if miConfig.MdtrtareaAdmvs == "430800" {
  23939. 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, "")
  23940. var dat map[string]interface{}
  23941. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  23942. fmt.Println(dat)
  23943. } else {
  23944. fmt.Println(err)
  23945. }
  23946. saveLog(result, src_resquest, "2208", "退费")
  23947. userJSONBytes, _ := json.Marshal(dat)
  23948. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  23949. utils.ErrorLog("解析失败:%v", err)
  23950. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23951. return
  23952. }
  23953. } else if miConfig.MdtrtareaAdmvs == "441799" {
  23954. api3 := miConfig.Url + "gdyb/2208?psn_no=" + order.PsnNo +
  23955. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&operator=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  23956. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  23957. resp3, requestErr3 := http.Get(api3)
  23958. if requestErr3 != nil {
  23959. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23960. return
  23961. }
  23962. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  23963. if ioErr3 != nil {
  23964. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  23965. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23966. return
  23967. }
  23968. var respJSON3 map[string]interface{}
  23969. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  23970. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23971. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23972. return
  23973. }
  23974. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23975. userJSONBytes3, _ := json.Marshal(respJSON3)
  23976. fmt.Println("log")
  23977. fmt.Println(string(userJSONBytes3))
  23978. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  23979. utils.ErrorLog("解析失败:%v", err)
  23980. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23981. return
  23982. }
  23983. } else {
  23984. if miConfig.Code == "H15049901371" {
  23985. 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)
  23986. var dat map[string]interface{}
  23987. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  23988. fmt.Println(dat)
  23989. } else {
  23990. fmt.Println(err)
  23991. }
  23992. saveLog(result, src_resquest, "2208", "退费")
  23993. userJSONBytes, _ := json.Marshal(dat)
  23994. if err := json.Unmarshal(userJSONBytes, &resSixteen10265); err != nil {
  23995. utils.ErrorLog("解析失败:%v", err)
  23996. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23997. return
  23998. }
  23999. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  24000. res.Output = resSixteen10265.Output
  24001. res.ErrMsg = resSixteen10265.ErrMsg
  24002. res.Cainfo = resSixteen10265.Cainfo
  24003. res.WarnMsg = resSixteen10265.WarnMsg
  24004. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  24005. res.Infcode = infocode
  24006. } else {
  24007. 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)
  24008. var dat map[string]interface{}
  24009. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  24010. fmt.Println(dat)
  24011. } else {
  24012. fmt.Println(err)
  24013. }
  24014. saveLog(result, src_resquest, "2208", "退费")
  24015. userJSONBytes, _ := json.Marshal(dat)
  24016. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  24017. if err := json.Unmarshal(userJSONBytes, &gz); err != nil {
  24018. utils.ErrorLog("解析失败:%v", err)
  24019. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24020. return
  24021. }
  24022. res.Infcode = gz.Infcode
  24023. } else {
  24024. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  24025. utils.ErrorLog("解析失败:%v", err)
  24026. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24027. return
  24028. }
  24029. }
  24030. }
  24031. }
  24032. if res.Infcode == 0 {
  24033. var res2 ResultSix
  24034. var resSix10265 ResultSix10265
  24035. if miConfig.MdtrtareaAdmvs == "421300" {
  24036. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  24037. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  24038. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  24039. resp3, requestErr3 := http.Get(api3)
  24040. if requestErr3 != nil {
  24041. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24042. return
  24043. }
  24044. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  24045. if ioErr3 != nil {
  24046. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  24047. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24048. return
  24049. }
  24050. var respJSON3 map[string]interface{}
  24051. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  24052. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24053. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24054. return
  24055. }
  24056. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24057. userJSONBytes3, _ := json.Marshal(respJSON3)
  24058. fmt.Println("log")
  24059. fmt.Println(string(userJSONBytes3))
  24060. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  24061. utils.ErrorLog("解析失败:%v", err)
  24062. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24063. return
  24064. }
  24065. } else if miConfig.MdtrtareaAdmvs == "420200" {
  24066. api3 := "http://192.168.0.197:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  24067. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  24068. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  24069. resp3, requestErr3 := http.Get(api3)
  24070. if requestErr3 != nil {
  24071. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24072. return
  24073. }
  24074. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  24075. if ioErr3 != nil {
  24076. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  24077. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24078. return
  24079. }
  24080. var respJSON3 map[string]interface{}
  24081. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  24082. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24083. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24084. return
  24085. }
  24086. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24087. userJSONBytes3, _ := json.Marshal(respJSON3)
  24088. fmt.Println("log")
  24089. fmt.Println(string(userJSONBytes3))
  24090. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  24091. utils.ErrorLog("解析失败:%v", err)
  24092. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24093. return
  24094. }
  24095. } else if miConfig.MdtrtareaAdmvs == "420902" {
  24096. api3 := miConfig.Url + "hbyb/2205?psn_no=" + order.PsnNo +
  24097. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  24098. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  24099. resp3, requestErr3 := http.Get(api3)
  24100. if requestErr3 != nil {
  24101. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24102. return
  24103. }
  24104. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  24105. if ioErr3 != nil {
  24106. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  24107. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24108. return
  24109. }
  24110. var respJSON3 map[string]interface{}
  24111. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  24112. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24113. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24114. return
  24115. }
  24116. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24117. userJSONBytes3, _ := json.Marshal(respJSON3)
  24118. fmt.Println("log")
  24119. fmt.Println(string(userJSONBytes3))
  24120. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  24121. utils.ErrorLog("解析失败:%v", err)
  24122. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24123. return
  24124. }
  24125. } else if miConfig.MdtrtareaAdmvs == "421182" {
  24126. api3 := miConfig.Url + "hbyb/2205?psn_no=" + order.PsnNo +
  24127. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  24128. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  24129. resp3, requestErr3 := http.Get(api3)
  24130. if requestErr3 != nil {
  24131. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24132. return
  24133. }
  24134. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  24135. if ioErr3 != nil {
  24136. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  24137. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24138. return
  24139. }
  24140. var respJSON3 map[string]interface{}
  24141. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  24142. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24143. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24144. return
  24145. }
  24146. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24147. userJSONBytes3, _ := json.Marshal(respJSON3)
  24148. fmt.Println("log")
  24149. fmt.Println(string(userJSONBytes3))
  24150. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  24151. utils.ErrorLog("解析失败:%v", err)
  24152. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24153. return
  24154. }
  24155. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  24156. var api3 string
  24157. if miConfig.MdtrtareaAdmvs == "320921" {
  24158. api3 = "http://192.168.2.3:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  24159. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  24160. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  24161. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  24162. } else {
  24163. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  24164. api3 = "http://192.168.5.251:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  24165. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  24166. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  24167. }
  24168. resp3, requestErr3 := http.Get(api3)
  24169. if requestErr3 != nil {
  24170. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24171. return
  24172. }
  24173. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  24174. if ioErr3 != nil {
  24175. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  24176. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24177. return
  24178. }
  24179. var respJSON3 map[string]interface{}
  24180. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  24181. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24182. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24183. return
  24184. }
  24185. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24186. userJSONBytes3, _ := json.Marshal(respJSON3)
  24187. fmt.Println("log")
  24188. fmt.Println(string(userJSONBytes3))
  24189. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  24190. utils.ErrorLog("解析失败:%v", err)
  24191. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24192. return
  24193. }
  24194. res2.InfRefmsgid = resSix10265.InfRefmsgid
  24195. res2.Output = resSix10265.Output
  24196. res2.ErrMsg = resSix10265.ErrMsg
  24197. res2.Cainfo = resSix10265.Cainfo
  24198. res2.WarnMsg = resSix10265.WarnMsg
  24199. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  24200. res2.Infcode = infocode
  24201. } else if miConfig.MdtrtareaAdmvs == "150499" {
  24202. var api3 string
  24203. api3 = "http://172.16.13.254:9532/" + "nmyb/2205?psn_no=" + order.PsnNo +
  24204. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  24205. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  24206. resp3, requestErr3 := http.Get(api3)
  24207. if requestErr3 != nil {
  24208. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24209. return
  24210. }
  24211. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  24212. if ioErr3 != nil {
  24213. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  24214. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24215. return
  24216. }
  24217. var respJSON3 map[string]interface{}
  24218. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  24219. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24220. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24221. return
  24222. }
  24223. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24224. userJSONBytes3, _ := json.Marshal(respJSON3)
  24225. fmt.Println("log")
  24226. fmt.Println(string(userJSONBytes3))
  24227. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  24228. utils.ErrorLog("解析失败:%v", err)
  24229. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24230. return
  24231. }
  24232. res2.InfRefmsgid = resSix10265.InfRefmsgid
  24233. res2.Output = resSix10265.Output
  24234. res2.ErrMsg = resSix10265.ErrMsg
  24235. res2.Cainfo = resSix10265.Cainfo
  24236. res2.WarnMsg = resSix10265.WarnMsg
  24237. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  24238. res2.Infcode = infocode
  24239. } else if miConfig.MdtrtareaAdmvs == "350500" {
  24240. 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)
  24241. var dat map[string]interface{}
  24242. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  24243. fmt.Println(dat)
  24244. } else {
  24245. fmt.Println(err)
  24246. }
  24247. saveLog(result2, src_request, "2205", "撤销明细")
  24248. userJSONBytes, _ := json.Marshal(dat)
  24249. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  24250. utils.ErrorLog("解析失败:%v", err)
  24251. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24252. return
  24253. }
  24254. } else if miConfig.MdtrtareaAdmvs == "360302" {
  24255. 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, "")
  24256. var dat map[string]interface{}
  24257. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  24258. fmt.Println(dat)
  24259. } else {
  24260. fmt.Println(err)
  24261. }
  24262. saveLog(result2, src_request, "2205", "撤销明细")
  24263. userJSONBytes, _ := json.Marshal(dat)
  24264. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  24265. utils.ErrorLog("解析失败:%v", err)
  24266. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24267. return
  24268. }
  24269. } else if miConfig.MdtrtareaAdmvs == "341203" {
  24270. var api3 string
  24271. api3 = miConfig.SecretKey + "ahyb/2205?psn_no=" + order.PsnNo +
  24272. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  24273. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  24274. resp3, requestErr3 := http.Get(api3)
  24275. if requestErr3 != nil {
  24276. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24277. return
  24278. }
  24279. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  24280. if ioErr3 != nil {
  24281. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  24282. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24283. return
  24284. }
  24285. var respJSON3 map[string]interface{}
  24286. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  24287. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24288. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24289. return
  24290. }
  24291. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  24292. if status == "0" {
  24293. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  24294. c.ServeSuccessJSON(map[string]interface{}{
  24295. "failed_code": -10,
  24296. "msg": err_msg,
  24297. })
  24298. return
  24299. }
  24300. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24301. userJSONBytes3, _ := json.Marshal(respJSON3)
  24302. fmt.Println("log")
  24303. fmt.Println(string(userJSONBytes3))
  24304. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  24305. utils.ErrorLog("解析失败:%v", err)
  24306. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24307. return
  24308. }
  24309. } else if miConfig.MdtrtareaAdmvs == "430800" {
  24310. 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, "")
  24311. var dat map[string]interface{}
  24312. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  24313. fmt.Println(dat)
  24314. } else {
  24315. fmt.Println(err)
  24316. }
  24317. saveLog(result2, src_request, "2205", "撤销明细")
  24318. userJSONBytes, _ := json.Marshal(dat)
  24319. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  24320. utils.ErrorLog("解析失败:%v", err)
  24321. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24322. return
  24323. }
  24324. } else if miConfig.MdtrtareaAdmvs == "441799" {
  24325. api3 := miConfig.Url + "gdyb/six?psn_no=" + order.PsnNo +
  24326. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  24327. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  24328. resp3, requestErr3 := http.Get(api3)
  24329. if requestErr3 != nil {
  24330. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24331. return
  24332. }
  24333. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  24334. if ioErr3 != nil {
  24335. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  24336. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24337. return
  24338. }
  24339. var respJSON3 map[string]interface{}
  24340. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  24341. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24342. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24343. return
  24344. }
  24345. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24346. userJSONBytes3, _ := json.Marshal(respJSON3)
  24347. fmt.Println("log")
  24348. fmt.Println(string(userJSONBytes3))
  24349. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  24350. utils.ErrorLog("解析失败:%v", err)
  24351. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24352. return
  24353. }
  24354. } else {
  24355. if miConfig.Code == "H15049901371" {
  24356. 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)
  24357. var dat map[string]interface{}
  24358. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  24359. fmt.Println(dat)
  24360. } else {
  24361. fmt.Println(err)
  24362. }
  24363. saveLog(result2, src_request, "2205", "撤销明细")
  24364. userJSONBytes, _ := json.Marshal(dat)
  24365. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  24366. utils.ErrorLog("解析失败:%v", err)
  24367. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24368. return
  24369. }
  24370. res2.InfRefmsgid = resSix10265.InfRefmsgid
  24371. res2.Output = resSix10265.Output
  24372. res2.ErrMsg = resSix10265.ErrMsg
  24373. res2.Cainfo = resSix10265.Cainfo
  24374. res2.WarnMsg = resSix10265.WarnMsg
  24375. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  24376. res2.Infcode = infocode
  24377. } else {
  24378. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  24379. res2.Infcode = 0
  24380. } else {
  24381. 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)
  24382. var dat map[string]interface{}
  24383. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  24384. fmt.Println(dat)
  24385. } else {
  24386. fmt.Println(err)
  24387. }
  24388. saveLog(result2, src_request, "2205", "撤销明细")
  24389. userJSONBytes, _ := json.Marshal(dat)
  24390. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  24391. utils.ErrorLog("解析失败:%v", err)
  24392. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24393. return
  24394. }
  24395. }
  24396. }
  24397. }
  24398. if res2.Infcode == -1 {
  24399. c.ServeSuccessJSON(map[string]interface{}{
  24400. "failed_code": -10,
  24401. "msg": res2.ErrMsg,
  24402. })
  24403. return
  24404. }
  24405. if res2.Infcode == 0 {
  24406. err := service.UpdataOrderStatus(order_id, order.Number, adminUser.CurrentOrgId, src_resquest, result)
  24407. if err == nil {
  24408. //当押金不为零时产生退费记录
  24409. if order.Decimal != 0 {
  24410. tmp := strconv.FormatInt(order.ID, 10)
  24411. err = service.MoneyIncrease(adminUser.CurrentOrgId, order.PatientId, tmp, order.Decimal)
  24412. if err != nil {
  24413. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24414. return
  24415. }
  24416. }
  24417. c.ServeSuccessJSON(map[string]interface{}{
  24418. "msg": "退费成功",
  24419. })
  24420. } else {
  24421. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24422. return
  24423. }
  24424. } else {
  24425. c.ServeSuccessJSON(map[string]interface{}{
  24426. "failed_code": -10,
  24427. "msg": res2.ErrMsg,
  24428. })
  24429. }
  24430. } else {
  24431. c.ServeSuccessJSON(map[string]interface{}{
  24432. "failed_code": -10,
  24433. "msg": res.ErrMsg,
  24434. })
  24435. }
  24436. }
  24437. }
  24438. func (c *HisApiController) RefundNumber() {
  24439. record_time := c.GetString("record_time")
  24440. //patient_id, _ := c.GetInt64("patient_id")
  24441. admin_user_id, _ := c.GetInt64("admin_user_id")
  24442. his_patient_id, _ := c.GetInt64("id")
  24443. timeLayout := "2006-01-02"
  24444. loc, _ := time.LoadLocation("Local")
  24445. adminUser := c.GetAdminUserInfo()
  24446. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  24447. fmt.Println(err)
  24448. if err != nil {
  24449. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  24450. return
  24451. }
  24452. recordDateTime := theTime.Unix()
  24453. //his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  24454. his, _ := service.GetHisPatientRecord(adminUser.CurrentOrgId, his_patient_id)
  24455. //patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  24456. //order, _ := service.GetHisOrderByID(order_id)
  24457. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  24458. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  24459. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  24460. count, _ := service.GetOrderCountByNumber(adminUser.CurrentOrgId, his.PatientId, recordDateTime, his.Number)
  24461. if count > 0 {
  24462. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeOrderParamWrong)
  24463. return
  24464. }
  24465. if config.IsOpen == 1 { //对接了医保,走医保流程
  24466. var res2 ResultSix
  24467. var res3 GZResultSix
  24468. var resSix10265 ResultSix10265
  24469. if miConfig.MdtrtareaAdmvs == "421300" {
  24470. api3 := "http://192.168.124.4:9532/" + "hbyb/2202?psn_no=" + his.PsnNo +
  24471. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  24472. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  24473. resp3, requestErr3 := http.Get(api3)
  24474. if requestErr3 != nil {
  24475. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24476. return
  24477. }
  24478. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  24479. if ioErr3 != nil {
  24480. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  24481. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24482. return
  24483. }
  24484. var respJSON3 map[string]interface{}
  24485. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  24486. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24487. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24488. return
  24489. }
  24490. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24491. userJSONBytes3, _ := json.Marshal(respJSON3)
  24492. fmt.Println("log")
  24493. fmt.Println(string(userJSONBytes3))
  24494. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  24495. utils.ErrorLog("解析失败:%v", err)
  24496. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24497. return
  24498. }
  24499. } else if miConfig.MdtrtareaAdmvs == "420200" {
  24500. api3 := "http://192.168.0.197:9532/" + "hbyb/2202?psn_no=" + his.PsnNo +
  24501. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  24502. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  24503. resp3, requestErr3 := http.Get(api3)
  24504. if requestErr3 != nil {
  24505. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24506. return
  24507. }
  24508. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  24509. if ioErr3 != nil {
  24510. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  24511. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24512. return
  24513. }
  24514. var respJSON3 map[string]interface{}
  24515. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  24516. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24517. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24518. return
  24519. }
  24520. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24521. userJSONBytes3, _ := json.Marshal(respJSON3)
  24522. fmt.Println("log")
  24523. fmt.Println(string(userJSONBytes3))
  24524. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  24525. utils.ErrorLog("解析失败:%v", err)
  24526. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24527. return
  24528. }
  24529. } else if miConfig.MdtrtareaAdmvs == "420902" {
  24530. api3 := miConfig.Url + "hbyb/2202?psn_no=" + his.PsnNo +
  24531. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  24532. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  24533. resp3, requestErr3 := http.Get(api3)
  24534. if requestErr3 != nil {
  24535. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24536. return
  24537. }
  24538. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  24539. if ioErr3 != nil {
  24540. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  24541. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24542. return
  24543. }
  24544. var respJSON3 map[string]interface{}
  24545. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  24546. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24547. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24548. return
  24549. }
  24550. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24551. userJSONBytes3, _ := json.Marshal(respJSON3)
  24552. fmt.Println("log")
  24553. fmt.Println(string(userJSONBytes3))
  24554. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  24555. utils.ErrorLog("解析失败:%v", err)
  24556. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24557. return
  24558. }
  24559. } else if miConfig.MdtrtareaAdmvs == "421182" {
  24560. api3 := miConfig.Url + "hbyb/2202?psn_no=" + his.PsnNo +
  24561. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  24562. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  24563. resp3, requestErr3 := http.Get(api3)
  24564. if requestErr3 != nil {
  24565. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24566. return
  24567. }
  24568. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  24569. if ioErr3 != nil {
  24570. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  24571. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24572. return
  24573. }
  24574. var respJSON3 map[string]interface{}
  24575. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  24576. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24577. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24578. return
  24579. }
  24580. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24581. userJSONBytes3, _ := json.Marshal(respJSON3)
  24582. fmt.Println("log")
  24583. fmt.Println(string(userJSONBytes3))
  24584. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  24585. utils.ErrorLog("解析失败:%v", err)
  24586. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24587. return
  24588. }
  24589. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  24590. var api3 string
  24591. if miConfig.MdtrtareaAdmvs == "320921" {
  24592. api3 = "http://192.168.2.3:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  24593. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  24594. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  24595. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  24596. } else {
  24597. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  24598. api3 = "http://192.168.5.251:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  24599. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  24600. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  24601. }
  24602. resp3, requestErr3 := http.Get(api3)
  24603. if requestErr3 != nil {
  24604. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24605. return
  24606. }
  24607. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  24608. if ioErr3 != nil {
  24609. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  24610. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24611. return
  24612. }
  24613. var respJSON3 map[string]interface{}
  24614. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  24615. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24616. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24617. return
  24618. }
  24619. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24620. userJSONBytes3, _ := json.Marshal(respJSON3)
  24621. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  24622. utils.ErrorLog("解析失败:%v", err)
  24623. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24624. return
  24625. }
  24626. res2.InfRefmsgid = resSix10265.InfRefmsgid
  24627. res2.Output = resSix10265.Output
  24628. res2.ErrMsg = resSix10265.ErrMsg
  24629. res2.Cainfo = resSix10265.Cainfo
  24630. res2.WarnMsg = resSix10265.WarnMsg
  24631. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  24632. res2.Infcode = infocode
  24633. } else if miConfig.MdtrtareaAdmvs == "150499" {
  24634. var api3 string
  24635. api3 = "http://172.16.13.254:9532/" + "nmyb/2202?psn_no=" + his.PsnNo +
  24636. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  24637. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  24638. resp3, requestErr3 := http.Get(api3)
  24639. if requestErr3 != nil {
  24640. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24641. return
  24642. }
  24643. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  24644. if ioErr3 != nil {
  24645. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  24646. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24647. return
  24648. }
  24649. var respJSON3 map[string]interface{}
  24650. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  24651. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24652. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24653. return
  24654. }
  24655. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24656. userJSONBytes3, _ := json.Marshal(respJSON3)
  24657. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  24658. utils.ErrorLog("解析失败:%v", err)
  24659. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24660. return
  24661. }
  24662. res2.InfRefmsgid = resSix10265.InfRefmsgid
  24663. res2.Output = resSix10265.Output
  24664. res2.ErrMsg = resSix10265.ErrMsg
  24665. res2.Cainfo = resSix10265.Cainfo
  24666. res2.WarnMsg = resSix10265.WarnMsg
  24667. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  24668. res2.Infcode = infocode
  24669. } else if miConfig.MdtrtareaAdmvs == "350500" {
  24670. 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)
  24671. var dat map[string]interface{}
  24672. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  24673. fmt.Println(dat)
  24674. } else {
  24675. fmt.Println(err)
  24676. }
  24677. saveLog(result, request, "2202", "退号")
  24678. userJSONBytes, _ := json.Marshal(dat)
  24679. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  24680. utils.ErrorLog("解析失败:%v", err)
  24681. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24682. return
  24683. }
  24684. } else if miConfig.MdtrtareaAdmvs == "360302" {
  24685. 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, "")
  24686. var dat map[string]interface{}
  24687. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  24688. fmt.Println(dat)
  24689. } else {
  24690. fmt.Println(err)
  24691. }
  24692. saveLog(result, request, "2202", "退号")
  24693. userJSONBytes, _ := json.Marshal(dat)
  24694. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  24695. utils.ErrorLog("解析失败:%v", err)
  24696. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24697. return
  24698. }
  24699. } else if miConfig.MdtrtareaAdmvs == "341203" {
  24700. var api3 string
  24701. api3 = miConfig.SecretKey + "ahyb/2202?psn_no=" + his.PsnNo +
  24702. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  24703. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  24704. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  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. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  24723. if status == "0" {
  24724. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  24725. c.ServeSuccessJSON(map[string]interface{}{
  24726. "failed_code": -10,
  24727. "msg": err_msg,
  24728. })
  24729. return
  24730. }
  24731. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24732. userJSONBytes3, _ := json.Marshal(respJSON3)
  24733. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  24734. utils.ErrorLog("解析失败:%v", err)
  24735. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24736. return
  24737. }
  24738. utils.ErrorLog("接口返回数据解析JSON失败: %v", res2.Infcode)
  24739. } else if miConfig.MdtrtareaAdmvs == "430800" {
  24740. 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, "")
  24741. var dat map[string]interface{}
  24742. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  24743. fmt.Println(dat)
  24744. } else {
  24745. fmt.Println(err)
  24746. }
  24747. saveLog(result, request, "2202", "退号")
  24748. userJSONBytes, _ := json.Marshal(dat)
  24749. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  24750. utils.ErrorLog("解析失败:%v", err)
  24751. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24752. return
  24753. }
  24754. } else if miConfig.MdtrtareaAdmvs == "441799" {
  24755. api3 := miConfig.Url + "gdyb/2202?psn_no=" + his.PsnNo +
  24756. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&operator=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  24757. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&admin_user_id=" + strconv.FormatInt(admin_user_id, 10)
  24758. resp3, requestErr3 := http.Get(api3)
  24759. if requestErr3 != nil {
  24760. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24761. return
  24762. }
  24763. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  24764. if ioErr3 != nil {
  24765. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  24766. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24767. return
  24768. }
  24769. var respJSON3 map[string]interface{}
  24770. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  24771. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24772. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24773. return
  24774. }
  24775. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24776. userJSONBytes3, _ := json.Marshal(respJSON3)
  24777. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  24778. utils.ErrorLog("解析失败:%v", err)
  24779. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24780. return
  24781. }
  24782. } else {
  24783. var api3 string
  24784. if miConfig.Code == "H15049901371" {
  24785. api3 = "http://127.0.0.1:9532/" + "gdyb/three?psn_no=" + his.PsnNo +
  24786. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  24787. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  24788. } else {
  24789. api3 = "http://127.0.0.1:9532/" + "gdyb/2202?psn_no=" + his.PsnNo +
  24790. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&operator=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  24791. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&admin_user_id=" + strconv.FormatInt(admin_user_id, 10)
  24792. }
  24793. resp3, requestErr3 := http.Get(api3)
  24794. if requestErr3 != nil {
  24795. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24796. return
  24797. }
  24798. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  24799. if ioErr3 != nil {
  24800. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  24801. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24802. return
  24803. }
  24804. var respJSON3 map[string]interface{}
  24805. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  24806. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24807. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24808. return
  24809. }
  24810. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24811. userJSONBytes3, _ := json.Marshal(respJSON3)
  24812. if miConfig.Code == "H15049901371" {
  24813. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  24814. utils.ErrorLog("解析失败:%v", err)
  24815. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24816. return
  24817. }
  24818. res2.InfRefmsgid = resSix10265.InfRefmsgid
  24819. res2.Output = resSix10265.Output
  24820. res2.ErrMsg = resSix10265.ErrMsg
  24821. res2.Cainfo = resSix10265.Cainfo
  24822. res2.WarnMsg = resSix10265.WarnMsg
  24823. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  24824. res2.Infcode = infocode
  24825. } else {
  24826. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  24827. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  24828. utils.ErrorLog("解析失败:%v", err)
  24829. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24830. return
  24831. }
  24832. res2.Infcode = res3.Infcode
  24833. } else {
  24834. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  24835. utils.ErrorLog("解析失败:%v", err)
  24836. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24837. return
  24838. }
  24839. }
  24840. }
  24841. }
  24842. if res2.Infcode == -1 {
  24843. utils.ErrorLog("解析失败:%v", res2.Infcode)
  24844. c.ServeSuccessJSON(map[string]interface{}{
  24845. "failed_code": -10,
  24846. "msg": res2.ErrMsg,
  24847. })
  24848. return
  24849. }
  24850. if res2.Infcode == 0 {
  24851. if err == nil {
  24852. c.ServeSuccessJSON(map[string]interface{}{
  24853. "msg": "退号成功",
  24854. })
  24855. service.UpdataRegStatusTwo(his_patient_id, recordDateTime, adminUser.CurrentOrgId)
  24856. } else {
  24857. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24858. return
  24859. }
  24860. }
  24861. } else {
  24862. //err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId)
  24863. //if err == nil {
  24864. // c.ServeSuccessJSON(map[string]interface{}{
  24865. // "msg": "退费成功",
  24866. // })
  24867. //} else {
  24868. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24869. // return
  24870. //}
  24871. }
  24872. }
  24873. func (c *HisApiController) RefundDetail() {
  24874. order_id, _ := c.GetInt64("order_id")
  24875. admin_user_id, _ := c.GetInt64("admin_user_id")
  24876. //his_patient_id, _ := c.GetInt64("his_patient_id")
  24877. number := c.GetString("number")
  24878. record_time := c.GetString("record_time")
  24879. patient_id, _ := c.GetInt64("patient_id")
  24880. //med_type, _ := c.GetInt64("med_type")
  24881. timeLayout := "2006-01-02"
  24882. loc, _ := time.LoadLocation("Local")
  24883. adminUser := c.GetAdminUserInfo()
  24884. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  24885. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  24886. fmt.Println(err)
  24887. if err != nil {
  24888. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  24889. return
  24890. }
  24891. recordDateTime := theTime.Unix()
  24892. //his, _ := service.GetNewVMHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  24893. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  24894. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  24895. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  24896. var order models.HisOrder
  24897. order, _ = service.GetHisOrderByID(order_id)
  24898. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  24899. if config.IsOpen == 1 { //对接了医保,走医保流程
  24900. var res2 ResultSix
  24901. if miConfig.MdtrtareaAdmvs == "421300" {
  24902. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  24903. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  24904. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  24905. resp3, requestErr3 := http.Get(api3)
  24906. if requestErr3 != nil {
  24907. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24908. return
  24909. }
  24910. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  24911. if ioErr3 != nil {
  24912. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  24913. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24914. return
  24915. }
  24916. var respJSON3 map[string]interface{}
  24917. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  24918. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24919. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24920. return
  24921. }
  24922. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24923. userJSONBytes3, _ := json.Marshal(respJSON3)
  24924. fmt.Println("log")
  24925. fmt.Println(string(userJSONBytes3))
  24926. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  24927. utils.ErrorLog("解析失败:%v", err)
  24928. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24929. return
  24930. }
  24931. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  24932. if err == nil {
  24933. c.ServeSuccessJSON(map[string]interface{}{
  24934. "msg": "撤销明细成功",
  24935. })
  24936. return
  24937. } else {
  24938. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24939. return
  24940. }
  24941. } else if miConfig.MdtrtareaAdmvs == "420200" {
  24942. api3 := "http://192.168.0.197:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  24943. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  24944. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  24945. resp3, requestErr3 := http.Get(api3)
  24946. if requestErr3 != nil {
  24947. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24948. return
  24949. }
  24950. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  24951. if ioErr3 != nil {
  24952. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  24953. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24954. return
  24955. }
  24956. var respJSON3 map[string]interface{}
  24957. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  24958. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24959. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24960. return
  24961. }
  24962. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24963. userJSONBytes3, _ := json.Marshal(respJSON3)
  24964. fmt.Println("log")
  24965. fmt.Println(string(userJSONBytes3))
  24966. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  24967. utils.ErrorLog("解析失败:%v", err)
  24968. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24969. return
  24970. }
  24971. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  24972. if err == nil {
  24973. c.ServeSuccessJSON(map[string]interface{}{
  24974. "msg": "撤销明细成功",
  24975. })
  24976. return
  24977. } else {
  24978. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24979. return
  24980. }
  24981. } else if miConfig.MdtrtareaAdmvs == "420902" {
  24982. api3 := miConfig.Url + "hbyb/2205?psn_no=" + order.PsnNo +
  24983. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  24984. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  24985. resp3, requestErr3 := http.Get(api3)
  24986. if requestErr3 != nil {
  24987. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24988. return
  24989. }
  24990. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  24991. if ioErr3 != nil {
  24992. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  24993. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24994. return
  24995. }
  24996. var respJSON3 map[string]interface{}
  24997. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  24998. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24999. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25000. return
  25001. }
  25002. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25003. userJSONBytes3, _ := json.Marshal(respJSON3)
  25004. fmt.Println("log")
  25005. fmt.Println(string(userJSONBytes3))
  25006. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  25007. utils.ErrorLog("解析失败:%v", err)
  25008. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25009. return
  25010. }
  25011. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  25012. if err == nil {
  25013. c.ServeSuccessJSON(map[string]interface{}{
  25014. "msg": "撤销明细成功",
  25015. })
  25016. return
  25017. } else {
  25018. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25019. return
  25020. }
  25021. } else if miConfig.MdtrtareaAdmvs == "421182" {
  25022. api3 := miConfig.Url + "hbyb/2205?psn_no=" + order.PsnNo +
  25023. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  25024. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  25025. resp3, requestErr3 := http.Get(api3)
  25026. if requestErr3 != nil {
  25027. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25028. return
  25029. }
  25030. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  25031. if ioErr3 != nil {
  25032. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  25033. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25034. return
  25035. }
  25036. var respJSON3 map[string]interface{}
  25037. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  25038. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25039. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25040. return
  25041. }
  25042. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25043. userJSONBytes3, _ := json.Marshal(respJSON3)
  25044. fmt.Println("log")
  25045. fmt.Println(string(userJSONBytes3))
  25046. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  25047. utils.ErrorLog("解析失败:%v", err)
  25048. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25049. return
  25050. }
  25051. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  25052. if err == nil {
  25053. c.ServeSuccessJSON(map[string]interface{}{
  25054. "msg": "撤销明细成功",
  25055. })
  25056. return
  25057. } else {
  25058. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25059. return
  25060. }
  25061. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  25062. var resSix10265 ResultSix10265
  25063. var api3 string
  25064. if miConfig.MdtrtareaAdmvs == "320921" {
  25065. api3 = "http://192.168.2.3:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  25066. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  25067. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  25068. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  25069. } else {
  25070. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  25071. api3 = "http://192.168.5.251:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  25072. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  25073. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  25074. }
  25075. resp3, requestErr3 := http.Get(api3)
  25076. utils.ErrorLog("接口: %v", requestErr3)
  25077. if requestErr3 != nil {
  25078. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25079. return
  25080. }
  25081. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  25082. if ioErr3 != nil {
  25083. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  25084. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25085. return
  25086. }
  25087. var respJSON3 map[string]interface{}
  25088. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  25089. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25090. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25091. return
  25092. }
  25093. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25094. userJSONBytes3, _ := json.Marshal(respJSON3)
  25095. fmt.Println("log")
  25096. fmt.Println(string(userJSONBytes3))
  25097. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  25098. utils.ErrorLog("解析失败:%v", err)
  25099. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25100. return
  25101. }
  25102. res2.InfRefmsgid = resSix10265.InfRefmsgid
  25103. res2.Output = resSix10265.Output
  25104. res2.ErrMsg = resSix10265.ErrMsg
  25105. res2.Cainfo = resSix10265.Cainfo
  25106. res2.WarnMsg = resSix10265.WarnMsg
  25107. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  25108. res2.Infcode = infocode
  25109. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  25110. if err == nil {
  25111. c.ServeSuccessJSON(map[string]interface{}{
  25112. "msg": "撤销明细成功",
  25113. })
  25114. return
  25115. } else {
  25116. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25117. return
  25118. }
  25119. } else if miConfig.MdtrtareaAdmvs == "341203" {
  25120. var api3 string
  25121. api3 = miConfig.SecretKey + "ahyb/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 + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  25124. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  25125. resp3, requestErr3 := http.Get(api3)
  25126. utils.ErrorLog("接口: %v", requestErr3)
  25127. if requestErr3 != nil {
  25128. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25129. return
  25130. }
  25131. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  25132. if ioErr3 != nil {
  25133. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  25134. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25135. return
  25136. }
  25137. var respJSON3 map[string]interface{}
  25138. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  25139. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25140. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25141. return
  25142. }
  25143. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  25144. if status == "0" {
  25145. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  25146. c.ServeSuccessJSON(map[string]interface{}{
  25147. "failed_code": -10,
  25148. "msg": err_msg,
  25149. })
  25150. return
  25151. }
  25152. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25153. userJSONBytes3, _ := json.Marshal(respJSON3)
  25154. fmt.Println("log")
  25155. fmt.Println(string(userJSONBytes3))
  25156. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  25157. utils.ErrorLog("解析失败:%v", err)
  25158. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25159. return
  25160. }
  25161. fmt.Println(res2.Infcode)
  25162. if res2.Infcode == -1 {
  25163. c.ServeSuccessJSON(map[string]interface{}{
  25164. "failed_code": -10,
  25165. "msg": res2.ErrMsg,
  25166. })
  25167. return
  25168. }
  25169. if res2.Infcode == 0 {
  25170. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  25171. if err == nil {
  25172. c.ServeSuccessJSON(map[string]interface{}{
  25173. "msg": "撤销明细成功",
  25174. })
  25175. return
  25176. } else {
  25177. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25178. return
  25179. }
  25180. } else {
  25181. c.ServeSuccessJSON(map[string]interface{}{
  25182. "failed_code": -10,
  25183. "msg": res2.ErrMsg,
  25184. })
  25185. }
  25186. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  25187. if err == nil {
  25188. c.ServeSuccessJSON(map[string]interface{}{
  25189. "msg": "撤销明细成功",
  25190. })
  25191. return
  25192. } else {
  25193. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25194. return
  25195. }
  25196. } else if miConfig.MdtrtareaAdmvs == "150499" {
  25197. var resSix10265 ResultSix10265
  25198. var api3 string
  25199. api3 = "http://172.16.13.254:9532/" + "nmyb/2205?psn_no=" + order.PsnNo +
  25200. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  25201. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  25202. resp3, requestErr3 := http.Get(api3)
  25203. if requestErr3 != nil {
  25204. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25205. return
  25206. }
  25207. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  25208. if ioErr3 != nil {
  25209. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  25210. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25211. return
  25212. }
  25213. var respJSON3 map[string]interface{}
  25214. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  25215. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25216. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25217. return
  25218. }
  25219. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25220. userJSONBytes3, _ := json.Marshal(respJSON3)
  25221. fmt.Println("log")
  25222. fmt.Println(string(userJSONBytes3))
  25223. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  25224. utils.ErrorLog("解析失败:%v", err)
  25225. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25226. return
  25227. }
  25228. res2.InfRefmsgid = resSix10265.InfRefmsgid
  25229. res2.Output = resSix10265.Output
  25230. res2.ErrMsg = resSix10265.ErrMsg
  25231. res2.Cainfo = resSix10265.Cainfo
  25232. res2.WarnMsg = resSix10265.WarnMsg
  25233. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  25234. res2.Infcode = infocode
  25235. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  25236. if err == nil {
  25237. c.ServeSuccessJSON(map[string]interface{}{
  25238. "msg": "撤销明细成功",
  25239. })
  25240. return
  25241. } else {
  25242. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25243. return
  25244. }
  25245. } else if miConfig.MdtrtareaAdmvs == "350500" {
  25246. result2, src_request, _ := service.FJyb2205(his.PsnNo, his.Number, "0000", miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  25247. var dat map[string]interface{}
  25248. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  25249. fmt.Println(dat)
  25250. } else {
  25251. fmt.Println(err)
  25252. }
  25253. saveLog(result2, src_request, "2205", "撤销明细")
  25254. userJSONBytes, _ := json.Marshal(dat)
  25255. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  25256. utils.ErrorLog("解析失败:%v", err)
  25257. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25258. return
  25259. }
  25260. if res2.Infcode == 0 {
  25261. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  25262. if err == nil {
  25263. c.ServeSuccessJSON(map[string]interface{}{
  25264. "msg": "撤销明细成功",
  25265. })
  25266. return
  25267. } else {
  25268. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25269. return
  25270. }
  25271. } else {
  25272. c.ServeSuccessJSON(map[string]interface{}{
  25273. "failed_code": -10,
  25274. "msg": res2.ErrMsg,
  25275. })
  25276. }
  25277. } else if miConfig.MdtrtareaAdmvs == "360302" {
  25278. 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, "")
  25279. var dat map[string]interface{}
  25280. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  25281. fmt.Println(dat)
  25282. } else {
  25283. fmt.Println(err)
  25284. }
  25285. saveLog(result2, src_request, "2205", "撤销明细")
  25286. userJSONBytes, _ := json.Marshal(dat)
  25287. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  25288. utils.ErrorLog("解析失败:%v", err)
  25289. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25290. return
  25291. }
  25292. if res2.Infcode == 0 {
  25293. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  25294. if err == nil {
  25295. c.ServeSuccessJSON(map[string]interface{}{
  25296. "msg": "撤销明细成功",
  25297. })
  25298. return
  25299. } else {
  25300. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25301. return
  25302. }
  25303. } else {
  25304. c.ServeSuccessJSON(map[string]interface{}{
  25305. "failed_code": -10,
  25306. "msg": res2.ErrMsg,
  25307. })
  25308. }
  25309. } else if miConfig.MdtrtareaAdmvs == "430800" {
  25310. 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, "")
  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. if res2.Infcode == 0 {
  25325. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  25326. if err == nil {
  25327. c.ServeSuccessJSON(map[string]interface{}{
  25328. "msg": "撤销明细成功",
  25329. })
  25330. return
  25331. } else {
  25332. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25333. return
  25334. }
  25335. } else {
  25336. c.ServeSuccessJSON(map[string]interface{}{
  25337. "failed_code": -10,
  25338. "msg": res2.ErrMsg,
  25339. })
  25340. }
  25341. } else if miConfig.MdtrtareaAdmvs == "441799" {
  25342. api2 := miConfig.Url + "gdyb/six?psn_no=" + his.PsnNo +
  25343. "&mdtrt_id=" + his.Number + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  25344. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  25345. resp2, requestErr2 := http.Get(api2)
  25346. if requestErr2 != nil {
  25347. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25348. return
  25349. }
  25350. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  25351. if ioErr2 != nil {
  25352. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  25353. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25354. return
  25355. }
  25356. var respJSON2 map[string]interface{}
  25357. if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  25358. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25359. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25360. return
  25361. }
  25362. respJSON2 = respJSON2["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25363. userJSONBytes3, _ := json.Marshal(respJSON2)
  25364. fmt.Println("log")
  25365. fmt.Println(string(userJSONBytes3))
  25366. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  25367. utils.ErrorLog("解析失败:%v", err)
  25368. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25369. return
  25370. }
  25371. if res2.Infcode == 0 {
  25372. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  25373. if err == nil {
  25374. c.ServeSuccessJSON(map[string]interface{}{
  25375. "msg": "撤销明细成功",
  25376. })
  25377. return
  25378. } else {
  25379. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25380. return
  25381. }
  25382. } else {
  25383. c.ServeSuccessJSON(map[string]interface{}{
  25384. "failed_code": -10,
  25385. "msg": res2.ErrMsg,
  25386. })
  25387. }
  25388. } else {
  25389. api2 := "http://127.0.0.1:9532/" + "gdyb/six?psn_no=" + his.PsnNo +
  25390. "&mdtrt_id=" + his.Number + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  25391. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&admin_user_id=" + strconv.FormatInt(admin_user_id, 10)
  25392. resp2, requestErr2 := http.Get(api2)
  25393. if requestErr2 != nil {
  25394. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25395. return
  25396. }
  25397. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  25398. if ioErr2 != nil {
  25399. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  25400. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25401. return
  25402. }
  25403. var respJSON2 map[string]interface{}
  25404. if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  25405. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25406. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25407. return
  25408. }
  25409. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  25410. if err == nil {
  25411. c.ServeSuccessJSON(map[string]interface{}{
  25412. "msg": "撤销明细成功",
  25413. })
  25414. return
  25415. } else {
  25416. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25417. return
  25418. }
  25419. }
  25420. } else {
  25421. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  25422. if err == nil {
  25423. c.ServeSuccessJSON(map[string]interface{}{
  25424. "msg": "退费成功",
  25425. })
  25426. } else {
  25427. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25428. return
  25429. }
  25430. }
  25431. }
  25432. // 对账
  25433. func (c *HisApiController) GetCheckAccount() {
  25434. start_time := c.GetString("start_time")
  25435. end_time := c.GetString("end_time")
  25436. insutype := c.GetString("insutype")
  25437. clr_type := c.GetString("clr_type")
  25438. clr_org := c.GetString("clr_optins")
  25439. admin_user_id, _ := c.GetInt64("admin_user_id")
  25440. adminUser := c.GetAdminUserInfo()
  25441. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  25442. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  25443. if len(clr_org) == 0 {
  25444. clr_org = miConfig.InsuplcAdmdvs
  25445. }
  25446. timeLayout := "2006-01-02"
  25447. loc, _ := time.LoadLocation("Local")
  25448. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  25449. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  25450. orders, _ := service.GetOrderByTime(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type, miConfig.MdtrtareaAdmvs)
  25451. orders_two, _ := service.GetOrderByTimeFive(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type, miConfig.MdtrtareaAdmvs)
  25452. fixmedins_setl_cnt := int64(len(orders))
  25453. var medfee_sumamt float64
  25454. var acct_pay float64
  25455. var fund_pay_sumamt float64
  25456. for _, item := range orders {
  25457. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  25458. acct_pay = acct_pay + item.AcctPay
  25459. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  25460. }
  25461. var user_name string
  25462. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  25463. if role.ID == 0 {
  25464. user_name = "xxx"
  25465. } else {
  25466. user_name = role.UserName
  25467. }
  25468. var res ResultEight
  25469. var res10188 ResultEightFor10188
  25470. if config.IsOpen == 1 {
  25471. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  25472. api := "http://192.168.2.3:9532/" + "jsyb/3201?" +
  25473. "insutype=" + insutype +
  25474. "&clr_type=" + clr_type +
  25475. "&setl_optins=" + clr_org +
  25476. "&stmt_begndate=" + start_time +
  25477. "&stm_enddate=" + end_time +
  25478. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  25479. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  25480. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  25481. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt+int64(len(orders_two)*2), 10) +
  25482. "&fixmedins_code=" + miConfig.Code +
  25483. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  25484. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  25485. "&secret_key=" + miConfig.SecretKey +
  25486. "&org_name=" + miConfig.OrgName +
  25487. "&doctor=" + user_name +
  25488. "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  25489. fmt.Println(api)
  25490. resp, requestErr := http.Get(api)
  25491. if requestErr != nil {
  25492. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25493. return
  25494. }
  25495. body, ioErr := ioutil.ReadAll(resp.Body)
  25496. fmt.Println(body)
  25497. if ioErr != nil {
  25498. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25499. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25500. return
  25501. }
  25502. var respJSON map[string]interface{}
  25503. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  25504. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25505. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25506. return
  25507. }
  25508. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25509. userJSONBytes, _ := json.Marshal(respJSON)
  25510. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  25511. utils.ErrorLog("解析失败:%v", err)
  25512. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25513. return
  25514. }
  25515. res.InfRefmsgid = res10188.InfRefmsgid
  25516. res.Output = res10188.Output
  25517. res.ErrMsg = res10188.ErrMsg
  25518. res.Cainfo = res10188.Cainfo
  25519. res.WarnMsg = res10188.WarnMsg
  25520. infocode, _ := strconv.ParseInt(res10188.Infcode, 10, 64)
  25521. res.Infcode = infocode
  25522. } else if miConfig.MdtrtareaAdmvs == "150499" {
  25523. if clr_type != "9903" {
  25524. clr_type = "99" // 就诊 ID(来自2201接口返回)
  25525. }
  25526. api := "http://172.16.13.254:9532/" + "nmyb/3201?" +
  25527. "insutype=" + insutype +
  25528. "&clr_type=" + clr_type +
  25529. "&setl_optins=" + clr_org +
  25530. "&stmt_begndate=" + start_time +
  25531. "&stm_enddate=" + end_time +
  25532. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  25533. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  25534. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  25535. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt+int64(len(orders_two)*2), 10) +
  25536. "&fixmedins_code=" + miConfig.Code +
  25537. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  25538. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  25539. "&secret_key=" + miConfig.SecretKey +
  25540. "&org_name=" + miConfig.OrgName +
  25541. "&doctor=" + user_name
  25542. resp, requestErr := http.Get(api)
  25543. if requestErr != nil {
  25544. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25545. return
  25546. }
  25547. body, ioErr := ioutil.ReadAll(resp.Body)
  25548. if ioErr != nil {
  25549. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25550. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25551. return
  25552. }
  25553. var respJSON map[string]interface{}
  25554. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  25555. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25556. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25557. return
  25558. }
  25559. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25560. result, _ := json.Marshal(respJSON)
  25561. fmt.Println("log")
  25562. fmt.Println(string(result))
  25563. if err := json.Unmarshal([]byte(result), &res10188); err != nil {
  25564. utils.ErrorLog("解析失败:%v", err)
  25565. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25566. return
  25567. }
  25568. res.InfRefmsgid = res10188.InfRefmsgid
  25569. res.Output = res10188.Output
  25570. res.ErrMsg = res10188.ErrMsg
  25571. res.Cainfo = res10188.Cainfo
  25572. res.WarnMsg = res10188.WarnMsg
  25573. infocode, _ := strconv.ParseInt(res10188.Infcode, 10, 64)
  25574. res.Infcode = infocode
  25575. } else if miConfig.MdtrtareaAdmvs == "350500" {
  25576. var baseParams models.BaseParams
  25577. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  25578. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  25579. baseParams.SecretKey = miConfig.SecretKey
  25580. baseParams.OrgName = miConfig.OrgName
  25581. baseParams.FixmedinsCode = miConfig.Code
  25582. baseParams.EncKey = miConfig.EncKey
  25583. baseParams.AppSecret = miConfig.AppSecret
  25584. baseParams.SignKey = miConfig.SignKey
  25585. baseParams.AppID = miConfig.Code
  25586. baseParams.Doctor = role.UserName
  25587. baseParams.RequestUrl = miConfig.Url
  25588. businessParams := models.BusinessParams{
  25589. Insutype: insutype,
  25590. ClrType: clr_type,
  25591. SetlOptins: clr_org,
  25592. StmtBegndate: start_time,
  25593. StmtEnddate: end_time,
  25594. MedfeeSumamt: medfee_sumamt,
  25595. FundPaySumamt: fund_pay_sumamt,
  25596. AcctPay: acct_pay,
  25597. FixmedinsSetlCnt: fixmedins_setl_cnt,
  25598. }
  25599. result, requestLog, err_msg := service.FJyb3201(baseParams, businessParams, fmt.Sprintf("%.4f", medfee_sumamt), fmt.Sprintf("%.4f", fund_pay_sumamt),fmt.Sprintf("%.4f", acct_pay))
  25600. fmt.Println(requestLog)
  25601. fmt.Println(result)
  25602. fmt.Println(err_msg)
  25603. var dat map[string]interface{}
  25604. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  25605. fmt.Println(dat)
  25606. } else {
  25607. fmt.Println(err)
  25608. }
  25609. userJSONBytes, _ := json.Marshal(dat)
  25610. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  25611. utils.ErrorLog("解析失败:%v", err)
  25612. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25613. return
  25614. }
  25615. } else if miConfig.MdtrtareaAdmvs == "430800" {
  25616. var baseParams models.BaseParams
  25617. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  25618. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  25619. baseParams.SecretKey = miConfig.SecretKey
  25620. baseParams.OrgName = miConfig.OrgName
  25621. baseParams.FixmedinsCode = miConfig.Code
  25622. baseParams.EncKey = miConfig.EncKey
  25623. baseParams.AppSecret = miConfig.AppSecret
  25624. baseParams.SignKey = miConfig.SignKey
  25625. baseParams.AppID = miConfig.Code
  25626. baseParams.Doctor = role.UserName
  25627. baseParams.RequestUrl = miConfig.Url
  25628. baseParams.AccessKey = miConfig.AccessKey
  25629. businessParams := models.BusinessParams{
  25630. Insutype: insutype,
  25631. ClrType: clr_type,
  25632. SetlOptins: "430822",
  25633. StmtBegndate: start_time,
  25634. StmtEnddate: end_time,
  25635. MedfeeSumamt: medfee_sumamt,
  25636. FundPaySumamt: fund_pay_sumamt,
  25637. AcctPay: acct_pay,
  25638. FixmedinsSetlCnt: fixmedins_setl_cnt,
  25639. }
  25640. 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)
  25641. fmt.Println(requestLog)
  25642. fmt.Println(result)
  25643. var dat map[string]interface{}
  25644. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  25645. fmt.Println(dat)
  25646. } else {
  25647. fmt.Println(err)
  25648. }
  25649. userJSONBytes, _ := json.Marshal(dat)
  25650. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  25651. utils.ErrorLog("解析失败:%v", err)
  25652. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25653. return
  25654. }
  25655. } else if miConfig.MdtrtareaAdmvs == "350500" {
  25656. var baseParams models.BaseParams
  25657. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  25658. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  25659. baseParams.SecretKey = miConfig.SecretKey
  25660. baseParams.OrgName = miConfig.OrgName
  25661. baseParams.FixmedinsCode = miConfig.Code
  25662. baseParams.EncKey = miConfig.EncKey
  25663. baseParams.AppSecret = miConfig.AppSecret
  25664. baseParams.SignKey = miConfig.SignKey
  25665. baseParams.AppID = miConfig.Code
  25666. baseParams.Doctor = role.UserName
  25667. baseParams.RequestUrl = miConfig.Url
  25668. businessParams := models.BusinessParams{
  25669. Insutype: insutype,
  25670. ClrType: clr_type,
  25671. SetlOptins: clr_org,
  25672. StmtBegndate: start_time,
  25673. StmtEnddate: end_time,
  25674. MedfeeSumamt: medfee_sumamt,
  25675. FundPaySumamt: fund_pay_sumamt,
  25676. AcctPay: acct_pay,
  25677. FixmedinsSetlCnt: fixmedins_setl_cnt,
  25678. }
  25679. result, requestLog, err_msg := service.FJyb3201(baseParams, businessParams, fmt.Sprintf("%.4f", medfee_sumamt), fmt.Sprintf("%.4f", fund_pay_sumamt),fmt.Sprintf("%.4f", acct_pay))
  25680. fmt.Println(requestLog)
  25681. fmt.Println(result)
  25682. fmt.Println(err_msg)
  25683. var dat map[string]interface{}
  25684. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  25685. fmt.Println(dat)
  25686. } else {
  25687. fmt.Println(err)
  25688. }
  25689. userJSONBytes, _ := json.Marshal(dat)
  25690. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  25691. utils.ErrorLog("解析失败:%v", err)
  25692. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25693. return
  25694. }
  25695. } else if miConfig.MdtrtareaAdmvs == "441799" {
  25696. if len(clr_type) == 0 {
  25697. clr_type = "11"
  25698. }
  25699. api := miConfig.Url + "gdyb/ten?" +
  25700. "insutype=" + insutype +
  25701. "&clr_type=" + clr_type +
  25702. "&setl_optins=" + clr_org +
  25703. "&stmt_begndate=" + start_time +
  25704. "&stm_enddate=" + end_time +
  25705. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  25706. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  25707. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  25708. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  25709. "&fixmedins_code=" + miConfig.Code +
  25710. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  25711. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  25712. "&secret_key=" + miConfig.SecretKey +
  25713. "&org_name=" + miConfig.OrgName +
  25714. "&doctor=" + user_name
  25715. fmt.Println(api)
  25716. resp, requestErr := http.Get(api)
  25717. if requestErr != nil {
  25718. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25719. return
  25720. }
  25721. body, ioErr := ioutil.ReadAll(resp.Body)
  25722. fmt.Println(body)
  25723. if ioErr != nil {
  25724. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25725. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25726. return
  25727. }
  25728. var respJSON map[string]interface{}
  25729. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  25730. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25731. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25732. return
  25733. }
  25734. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25735. userJSONBytes, _ := json.Marshal(respJSON)
  25736. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  25737. utils.ErrorLog("解析失败:%v", err)
  25738. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25739. return
  25740. }
  25741. } else if miConfig.MdtrtareaAdmvs == "360302" {
  25742. var baseParams models.BaseParams
  25743. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  25744. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  25745. baseParams.SecretKey = miConfig.SecretKey
  25746. baseParams.OrgName = miConfig.OrgName
  25747. baseParams.FixmedinsCode = miConfig.Code
  25748. baseParams.EncKey = miConfig.EncKey
  25749. baseParams.AppSecret = miConfig.AppSecret
  25750. baseParams.SignKey = miConfig.SignKey
  25751. baseParams.AppID = miConfig.Code
  25752. baseParams.Doctor = role.UserName
  25753. baseParams.RequestUrl = miConfig.Url
  25754. if clr_type == "9903" {
  25755. clr_type = "9901"
  25756. }
  25757. businessParams := models.BusinessParams{
  25758. Insutype: insutype,
  25759. ClrType: clr_type,
  25760. SetlOptins: "360302",
  25761. StmtBegndate: start_time,
  25762. StmtEnddate: end_time,
  25763. MedfeeSumamt: 0,
  25764. FundPaySumamt: 0,
  25765. AcctPay: 0,
  25766. FixmedinsSetlCnt: fixmedins_setl_cnt,
  25767. }
  25768. 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))
  25769. fmt.Println(requestLog)
  25770. fmt.Println(result)
  25771. var dat map[string]interface{}
  25772. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  25773. fmt.Println(dat)
  25774. } else {
  25775. fmt.Println(err)
  25776. }
  25777. userJSONBytes, _ := json.Marshal(dat)
  25778. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  25779. utils.ErrorLog("解析失败:%v", err)
  25780. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25781. return
  25782. }
  25783. } else if miConfig.MdtrtareaAdmvs == "341203" {
  25784. var api string
  25785. api = miConfig.SecretKey + "ahyb/3201?insutype=" + insutype +
  25786. "&clr_type=" + clr_type +
  25787. "&setl_optins=" + clr_org +
  25788. "&stmt_begndate=" + start_time +
  25789. "&stm_enddate=" + end_time +
  25790. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  25791. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  25792. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  25793. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt+int64(len(orders_two)*2), 10) +
  25794. "&fixmedins_code=" + miConfig.Code +
  25795. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  25796. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  25797. "&secret_key=" + miConfig.SecretKey +
  25798. "&org_name=" + miConfig.OrgName +
  25799. "&doctor=" + user_name + "&url=" + miConfig.Url
  25800. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  25801. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  25802. resp, requestErr := http.Get(api)
  25803. if requestErr != nil {
  25804. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25805. return
  25806. }
  25807. body, ioErr := ioutil.ReadAll(resp.Body)
  25808. if ioErr != nil {
  25809. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25810. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25811. return
  25812. }
  25813. var respJSON map[string]interface{}
  25814. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  25815. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25816. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25817. return
  25818. }
  25819. status := respJSON["data"].(map[string]interface{})["status"].(string)
  25820. if status == "0" {
  25821. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  25822. c.ServeSuccessJSON(map[string]interface{}{
  25823. "failed_code": -10,
  25824. "msg": err_msg,
  25825. })
  25826. return
  25827. }
  25828. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25829. userJSONBytes, _ := json.Marshal(respJSON)
  25830. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  25831. utils.ErrorLog("解析失败:%v", err)
  25832. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25833. return
  25834. }
  25835. } else {
  25836. if len(clr_type) == 0 {
  25837. clr_type = "11"
  25838. }
  25839. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  25840. "insutype=" + insutype +
  25841. "&clr_type=" + clr_type +
  25842. "&setl_optins=" + clr_org +
  25843. "&stmt_begndate=" + start_time +
  25844. "&stm_enddate=" + end_time +
  25845. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  25846. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  25847. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  25848. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  25849. "&fixmedins_code=" + miConfig.Code +
  25850. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  25851. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  25852. "&secret_key=" + miConfig.SecretKey +
  25853. "&org_name=" + miConfig.OrgName +
  25854. "&doctor=" + user_name + "&admin_user_id=" + strconv.FormatInt(admin_user_id, 10)
  25855. fmt.Println(api)
  25856. resp, requestErr := http.Get(api)
  25857. if requestErr != nil {
  25858. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25859. return
  25860. }
  25861. body, ioErr := ioutil.ReadAll(resp.Body)
  25862. fmt.Println(body)
  25863. if ioErr != nil {
  25864. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25865. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25866. return
  25867. }
  25868. var respJSON map[string]interface{}
  25869. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  25870. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25871. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25872. return
  25873. }
  25874. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25875. userJSONBytes, _ := json.Marshal(respJSON)
  25876. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  25877. utils.ErrorLog("解析失败:%v", err)
  25878. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25879. return
  25880. }
  25881. }
  25882. if res.Infcode == 0 {
  25883. if res.Output.Stmtinfo.StmtRslt == "0" {
  25884. micc := &models.MedicalInsuranceCostCompare{
  25885. StartTime: startime.Unix(),
  25886. EndTime: endtime.Unix(),
  25887. Insutype: insutype,
  25888. CheckType: 1,
  25889. Num: fixmedins_setl_cnt,
  25890. Mtime: time.Now().Unix(),
  25891. Status: 1,
  25892. UserOrgId: adminUser.CurrentOrgId,
  25893. CostTotal: medfee_sumamt,
  25894. FuncTotal: fund_pay_sumamt,
  25895. PsnPay: acct_pay,
  25896. Creator: admin_user_id,
  25897. Ctime: time.Now().Unix(),
  25898. ClrType: clr_type,
  25899. }
  25900. err := service.CreateMedicalInsuranceCostCompareRecord(micc)
  25901. if err == nil {
  25902. c.ServeSuccessJSON(map[string]interface{}{
  25903. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  25904. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  25905. })
  25906. } else {
  25907. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25908. }
  25909. } else {
  25910. c.ServeSuccessJSON(map[string]interface{}{
  25911. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  25912. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  25913. })
  25914. }
  25915. } else {
  25916. c.ServeSuccessJSON(map[string]interface{}{
  25917. "failed_code": -10,
  25918. "msg": res.ErrMsg,
  25919. })
  25920. }
  25921. }
  25922. }
  25923. func (c *HisApiController) Check310() {
  25924. adminUser := c.GetAdminUserInfo()
  25925. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  25926. var user_name string
  25927. user_name = "高慧裕"
  25928. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  25929. "insutype=" + "310" +
  25930. "&clr_type=" + "" +
  25931. "&setl_optins=" + "441202" +
  25932. "&stmt_begndate=" + "2022-03-01" +
  25933. "&stm_enddate=" + "2022-03-31" +
  25934. "&medfee_sumamt=" + "194930.12" +
  25935. "&fund_pay_sumamt=" + "188741.46" +
  25936. "&acct_pay=" + "0" +
  25937. "&fixmedins_setl_cnt=" + "452" +
  25938. "&fixmedins_code=" + miConfig.Code +
  25939. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  25940. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  25941. "&secret_key=" + miConfig.SecretKey +
  25942. "&org_name=" + miConfig.OrgName +
  25943. "&doctor=" + user_name
  25944. fmt.Println(api)
  25945. resp, requestErr := http.Get(api)
  25946. if requestErr != nil {
  25947. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25948. return
  25949. }
  25950. body, ioErr := ioutil.ReadAll(resp.Body)
  25951. fmt.Println(body)
  25952. if ioErr != nil {
  25953. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25954. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25955. return
  25956. }
  25957. var respJSON map[string]interface{}
  25958. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  25959. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25960. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25961. return
  25962. }
  25963. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25964. userJSONBytes, _ := json.Marshal(respJSON)
  25965. var res ResultEight
  25966. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  25967. utils.ErrorLog("解析失败:%v", err)
  25968. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25969. return
  25970. }
  25971. }
  25972. func (c *HisApiController) Check390() {
  25973. adminUser := c.GetAdminUserInfo()
  25974. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  25975. var user_name string
  25976. user_name = "高慧裕"
  25977. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  25978. "insutype=" + "390" +
  25979. "&clr_type=" + "" +
  25980. "&setl_optins=" + "441202" +
  25981. "&stmt_begndate=" + "2022-03-01" +
  25982. "&stm_enddate=" + "2022-03-31" +
  25983. "&medfee_sumamt=" + "1068448.89" +
  25984. "&fund_pay_sumamt=" + "1014677.62" +
  25985. "&acct_pay=" + "0" +
  25986. "&fixmedins_setl_cnt=" + "1950" +
  25987. "&fixmedins_code=" + miConfig.Code +
  25988. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  25989. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  25990. "&secret_key=" + miConfig.SecretKey +
  25991. "&org_name=" + miConfig.OrgName +
  25992. "&doctor=" + user_name
  25993. fmt.Println(api)
  25994. resp, requestErr := http.Get(api)
  25995. if requestErr != nil {
  25996. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25997. return
  25998. }
  25999. body, ioErr := ioutil.ReadAll(resp.Body)
  26000. fmt.Println(body)
  26001. if ioErr != nil {
  26002. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26003. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26004. return
  26005. }
  26006. var respJSON map[string]interface{}
  26007. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  26008. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26009. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26010. return
  26011. }
  26012. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26013. userJSONBytes, _ := json.Marshal(respJSON)
  26014. var res ResultEight
  26015. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  26016. utils.ErrorLog("解析失败:%v", err)
  26017. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26018. return
  26019. }
  26020. }
  26021. // 对账明细
  26022. func (c *HisApiController) GetCheckDetailAccount() {
  26023. start_time := c.GetString("start_time")
  26024. end_time := c.GetString("end_time")
  26025. admin_user_id, _ := c.GetInt64("admin_user_id")
  26026. adminUser := c.GetAdminUserInfo()
  26027. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  26028. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  26029. timeLayout := "2006-01-02"
  26030. loc, _ := time.LoadLocation("Local")
  26031. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  26032. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  26033. orders, _ := service.GetOrderByTimeTwo(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  26034. rand.Seed(time.Now().UnixNano())
  26035. num := rand.Intn(30000)
  26036. Mkdir(miConfig.OrgName)
  26037. file := strconv.FormatInt(int64(num), 10)
  26038. file_name := file + ".txt"
  26039. zip_name := file + ".zip"
  26040. zip_path := miConfig.OrgName + "/" + zip_name
  26041. file_path := miConfig.OrgName + "/" + file_name
  26042. decimal.DivisionPrecision = 2
  26043. var medfee_sumamt float64
  26044. var psn_cash_pay float64
  26045. var fund_pay_sumamt float64
  26046. fixmedins_setl_cnt := int64(len(orders))
  26047. for _, item := range orders {
  26048. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  26049. psn_cash_pay = psn_cash_pay + item.PsnCashPay
  26050. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  26051. }
  26052. f, err := os.Create(miConfig.OrgName + "/" + file_name)
  26053. defer f.Close()
  26054. if err != nil {
  26055. fmt.Println(err.Error())
  26056. } else {
  26057. for _, item := range orders {
  26058. var refd_setl_flag string
  26059. if item.OrderStatus == 2 {
  26060. refd_setl_flag = "0"
  26061. var str string
  26062. str = item.SetlId + " " +
  26063. item.MdtrtId + " " +
  26064. item.PsnNo + " " +
  26065. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  26066. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  26067. fmt.Sprintf("%.4f", item.AcctPay) + " " + refd_setl_flag + "\r\n"
  26068. _, err = f.Write([]byte(str))
  26069. }
  26070. if item.OrderStatus == 3 {
  26071. var str string
  26072. str = item.SetlId + " " +
  26073. item.MdtrtId + " " +
  26074. item.PsnNo + " " +
  26075. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  26076. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  26077. fmt.Sprintf("%.4f", item.AcctPay) + " " + "1" + "\r\n"
  26078. _, err = f.Write([]byte(str))
  26079. var str2 string
  26080. str2 = item.SetlId + " " +
  26081. item.MdtrtId + " " +
  26082. item.PsnNo + " " +
  26083. fmt.Sprintf("%.4f", 0-item.MedfeeSumamt) + " " +
  26084. fmt.Sprintf("%.4f", 0-item.FundPaySumamt) + " " +
  26085. fmt.Sprintf("%.4f", 0-item.AcctPay) + " " + "1" + "\r\n"
  26086. _, err = f.Write([]byte(str2))
  26087. }
  26088. }
  26089. }
  26090. Zip(file_path, zip_path)
  26091. fmt.Println(ReadFile(zip_path))
  26092. fmt.Println(string(ReadFile(zip_path)))
  26093. if config.IsOpen == 1 {
  26094. var user_name string
  26095. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  26096. if role.ID == 0 {
  26097. user_name = "管理员"
  26098. } else {
  26099. user_name = role.UserName
  26100. }
  26101. baseParams := models.BaseParams{
  26102. SecretKey: miConfig.SecretKey,
  26103. FixmedinsCode: miConfig.Code,
  26104. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  26105. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  26106. OrgName: miConfig.OrgName,
  26107. Doctor: user_name,
  26108. }
  26109. result := service.Gdyb9101(baseParams, file_name, ReadFile(file_path))
  26110. var dat map[string]interface{}
  26111. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  26112. fmt.Println(dat)
  26113. } else {
  26114. fmt.Println(err)
  26115. }
  26116. userJSONBytes, _ := json.Marshal(dat)
  26117. var res ResultNine
  26118. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  26119. utils.ErrorLog("解析失败:%v", err)
  26120. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26121. return
  26122. }
  26123. if res.Infcode == 0 {
  26124. fileNo := res.Output.FileQuryNo
  26125. api := "http://127.0.0.1:9532/" + "gdyb/twelve?" +
  26126. "file_qury_no=" + fileNo +
  26127. "&setl_optins=" + "定点医保中心" +
  26128. "&stmt_begndate=" + start_time +
  26129. "&stm_enddate=" + end_time +
  26130. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  26131. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  26132. "&cash_payamt=" + fmt.Sprintf("%.4f", psn_cash_pay) +
  26133. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  26134. "&fixmedins_code=" + miConfig.Code +
  26135. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  26136. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  26137. "&secret_key=" + miConfig.SecretKey +
  26138. "&org_name=" + miConfig.OrgName +
  26139. "&doctor=" + user_name
  26140. resp, requestErr := http.Get(api)
  26141. if requestErr != nil {
  26142. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26143. return
  26144. }
  26145. body, ioErr := ioutil.ReadAll(resp.Body)
  26146. if ioErr != nil {
  26147. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26148. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26149. return
  26150. }
  26151. var respJSON map[string]interface{}
  26152. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  26153. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26154. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26155. return
  26156. }
  26157. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26158. userJSONBytes, _ := json.Marshal(respJSON)
  26159. var res ResultTen
  26160. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  26161. utils.ErrorLog("解析失败:%v", err)
  26162. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26163. return
  26164. }
  26165. if res.Infcode == 0 {
  26166. service.Gdyb9102(baseParams, res.Output.Fileinfo.Filename, res.Output.Fileinfo.FileQuryNo)
  26167. micc := &models.MedicalInsuranceCostCompare{
  26168. StartTime: startime.Unix(),
  26169. EndTime: endtime.Unix(),
  26170. Insutype: "0",
  26171. CheckType: 2,
  26172. Num: fixmedins_setl_cnt,
  26173. Mtime: time.Now().Unix(),
  26174. Status: 1,
  26175. UserOrgId: adminUser.CurrentOrgId,
  26176. CostTotal: medfee_sumamt,
  26177. FuncTotal: fund_pay_sumamt,
  26178. PsnPay: psn_cash_pay,
  26179. Creator: admin_user_id,
  26180. Ctime: time.Now().Unix(),
  26181. }
  26182. service.CreateMedicalInsuranceCostCompareRecord(micc)
  26183. c.ServeSuccessJSON(map[string]interface{}{
  26184. "msg": "明细对账成功",
  26185. })
  26186. }
  26187. } else {
  26188. }
  26189. }
  26190. }
  26191. type CustomOrderInfo struct {
  26192. Name string
  26193. Spec string
  26194. Unit string
  26195. Count float64
  26196. Price float64
  26197. Total float64
  26198. }
  26199. func (c *HisApiController) GetBatchSettleAccounts() {
  26200. admin_user_id, _ := c.GetInt64("admin_user_id")
  26201. order_ids := c.GetString("order_ids")
  26202. order_ids_arr := strings.Split(order_ids, ",")
  26203. data3 := []map[string]interface{}{}
  26204. for _, item := range order_ids_arr {
  26205. id, _ := strconv.ParseInt(item, 10, 64)
  26206. order_id := id
  26207. adminUser := c.GetAdminUserInfo()
  26208. order, _ := service.GetHisOrderByID(order_id)
  26209. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  26210. orderInfos, _ := service.GetHisOrderInfoByNumber(order.Number)
  26211. orderInfos_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  26212. orderInfos = append(orderInfos, orderInfos_two...)
  26213. his_hospital, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  26214. //diagnosisConfig, _ := service.FindDiagnoseById(his.Diagnosis)
  26215. var diagnosis_ids []string
  26216. if his.ID > 0 {
  26217. diagnosis_ids = strings.Split(his.Diagnosis, ",")
  26218. } else {
  26219. diagnosis_ids = strings.Split(his_hospital.Diagnosis, ",")
  26220. }
  26221. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, order.PatientId)
  26222. var dia_config []*models.HisXtDiagnoseConfig
  26223. var name string
  26224. for _, item := range diagnosis_ids {
  26225. id, _ := strconv.ParseInt(item, 10, 64)
  26226. diagnosisConfig, _ := service.FindDiagnoseById(id)
  26227. dia_config = append(dia_config, &diagnosisConfig)
  26228. if len(name) == 0 {
  26229. name = diagnosisConfig.ClassName
  26230. }
  26231. //} else {
  26232. // name = name + "," + diagnosisConfig.ClassName
  26233. //}
  26234. }
  26235. var bedCostTotal float64 = 0 //床位总费
  26236. var bedCostSelfTotal float64 = 0 //床位自费
  26237. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  26238. var bedSelfTotal float64 = 0 //床位部分项目自费
  26239. var bedInscpTotal float64 = 0 //床位部分项目自费
  26240. var operationCostTotal float64 = 0 //手术费
  26241. var operationCostSelfTotal float64 = 0 //手术费
  26242. var operationCostPartSelfTotal float64 = 0 //手术费
  26243. var operationSelfTotal float64 = 0 //床位部分项目自费
  26244. var operationInscpTotal float64 = 0 //床位部分项目自费
  26245. var otherCostTotal float64 = 0 //其他费用
  26246. var otherCostSelfTotal float64 = 0 //其他费用
  26247. var otherCostPartSelfTotal float64 = 0 //其他费用
  26248. var otherSelfTotal float64 = 0 //床位部分项目自费
  26249. var otherInscpTotal float64 = 0 //床位部分项目自费
  26250. var materialCostTotal float64 = 0 //材料费
  26251. var materialCostSelfTotal float64 = 0 //材料费
  26252. var materialCostPartSelfTotal float64 = 0 //材料费
  26253. var materialSelfTotal float64 = 0 //床位部分项目自费
  26254. var materialInscpTotal float64 = 0 //床位部分项目自费
  26255. var westernMedicineCostTotal float64 = 0 //西药费
  26256. var westernMedicineCostSelfTotal float64 = 0 //西药费
  26257. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  26258. var westernMedicineSelfTotal float64 = 0 //床位部分项目自费
  26259. var westernMedicineInscpTotal float64 = 0 //床位部分项目自费
  26260. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  26261. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  26262. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  26263. var chineseTraditionalSelfTotal float64 = 0 //床位部分项目自费
  26264. var chineseTraditionalInscpTotal float64 = 0 //床位部分项目自费
  26265. var checkCostTotal float64 = 0 //检查费
  26266. var checkCostSelfTotal float64 = 0 //检查费
  26267. var checkCostPartSelfTotal float64 = 0 //检查费
  26268. var checkSelfTotal float64 = 0 //床位部分项目自费
  26269. var checkInscpTotal float64 = 0 //床位部分项目自费
  26270. var laboratoryCostTotal float64 = 0 //化验费
  26271. var laboratoryCostSelfTotal float64 = 0 //化验费
  26272. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  26273. var laboratorySelfTotal float64 = 0 //床位部分项目自费
  26274. var laboratoryInscpTotal float64 = 0 //床位部分项目自费
  26275. var treatCostTotal float64 = 0 //治疗费用
  26276. var treatCostSelfTotal float64 = 0 //治疗费用
  26277. var treatCostPartSelfTotal float64 = 0 //治疗费用
  26278. var treatSelfTotal float64 = 0 //床位部分项目自费
  26279. var treatInscpTotal float64 = 0 //床位部分项目自费
  26280. decimal.DivisionPrecision = 2
  26281. for _, item := range orderInfos {
  26282. if item.MedChrgitmType == "01" { //床位费
  26283. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  26284. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  26285. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  26286. bedSelfTotal, _ = decimal.NewFromFloat(bedSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  26287. bedInscpTotal, _ = decimal.NewFromFloat(bedInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  26288. }
  26289. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  26290. if item.MedChrgitmType == "03" { //检查费
  26291. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  26292. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  26293. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  26294. laboratorySelfTotal, _ = decimal.NewFromFloat(laboratorySelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  26295. laboratoryInscpTotal, _ = decimal.NewFromFloat(laboratoryInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  26296. }
  26297. } else {
  26298. if item.MedChrgitmType == "03" && adminUser.CurrentOrgId == 9504 { //手术费
  26299. fmt.Println("------------")
  26300. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  26301. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  26302. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  26303. }
  26304. if item.MedChrgitmType == "03" && adminUser.CurrentOrgId != 9504 { //手术费
  26305. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  26306. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  26307. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  26308. checkSelfTotal, _ = decimal.NewFromFloat(checkSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  26309. checkInscpTotal, _ = decimal.NewFromFloat(checkInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  26310. }
  26311. }
  26312. if item.MedChrgitmType == "04" { //化验费
  26313. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  26314. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  26315. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  26316. laboratorySelfTotal, _ = decimal.NewFromFloat(laboratorySelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  26317. laboratoryInscpTotal, _ = decimal.NewFromFloat(laboratoryInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  26318. }
  26319. if item.MedChrgitmType == "05" { //治疗费
  26320. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  26321. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  26322. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  26323. treatSelfTotal, _ = decimal.NewFromFloat(treatSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  26324. treatInscpTotal, _ = decimal.NewFromFloat(treatInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  26325. }
  26326. if item.MedChrgitmType == "06" && adminUser.CurrentOrgId == 9504 { //手术费
  26327. fmt.Println("------------")
  26328. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  26329. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  26330. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  26331. }
  26332. if item.MedChrgitmType == "06" && adminUser.CurrentOrgId != 9504 { //手术费
  26333. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  26334. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  26335. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  26336. }
  26337. //if item.MedChrgitmType == "06" { //手术费
  26338. // operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  26339. // operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  26340. // operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  26341. // operationSelfTotal, _ = decimal.NewFromFloat(operationSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  26342. // operationInscpTotal, _ = decimal.NewFromFloat(operationInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  26343. //
  26344. //}
  26345. if item.MedChrgitmType == "08" || item.MedChrgitmType == "1402" || item.MedChrgitmType == "1403" { //材料费
  26346. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  26347. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  26348. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  26349. materialSelfTotal, _ = decimal.NewFromFloat(materialSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  26350. materialInscpTotal, _ = decimal.NewFromFloat(materialInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  26351. }
  26352. if item.MedChrgitmType == "09" { //西药费
  26353. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  26354. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  26355. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  26356. westernMedicineSelfTotal, _ = decimal.NewFromFloat(westernMedicineSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  26357. westernMedicineInscpTotal, _ = decimal.NewFromFloat(westernMedicineInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  26358. }
  26359. if item.MedChrgitmType == "11" { //中成费
  26360. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  26361. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  26362. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  26363. chineseTraditionalSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  26364. chineseTraditionalInscpTotal, _ = decimal.NewFromFloat(chineseTraditionalInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  26365. }
  26366. if item.MedChrgitmType == "14" || item.MedChrgitmType == "0" || item.MedChrgitmType == "12" || item.MedChrgitmType == "02" { //其他费
  26367. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  26368. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  26369. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  26370. otherSelfTotal, _ = decimal.NewFromFloat(otherSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  26371. otherInscpTotal, _ = decimal.NewFromFloat(otherInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  26372. }
  26373. }
  26374. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  26375. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  26376. var user_name string
  26377. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  26378. if role.ID == 0 {
  26379. user_name = "管理员"
  26380. } else {
  26381. user_name = role.UserName
  26382. }
  26383. baseParams := models.BaseParams{
  26384. SecretKey: miConfig.SecretKey,
  26385. FixmedinsCode: miConfig.Code,
  26386. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  26387. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  26388. OrgName: miConfig.OrgName,
  26389. Doctor: user_name,
  26390. RequestUrl: miConfig.Url,
  26391. AccessKey: miConfig.AccessKey,
  26392. }
  26393. businessParams := models.BusinessParams{
  26394. PsnNo: order.PsnNo,
  26395. MdtrtId: order.MdtrtId,
  26396. SetlId: order.SetlId,
  26397. }
  26398. var res ResultEleven
  26399. var resEleven10265 ResultEleven10265
  26400. if config.IsOpen == 1 {
  26401. baseParams.InsuplcAdmdvs = his.InsuplcAdmdvs
  26402. result := service.Gdyb5203(baseParams, businessParams)
  26403. service.Gdyb5204(baseParams, businessParams)
  26404. //service.Gdyb5302(businessParams.PsnNo, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs, baseParams.SecretKey)
  26405. var dat map[string]interface{}
  26406. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  26407. fmt.Println(dat)
  26408. } else {
  26409. fmt.Println(err)
  26410. }
  26411. userJSONBytes, _ := json.Marshal(dat)
  26412. if miConfig.Code == "H15049901371" {
  26413. if err := json.Unmarshal(userJSONBytes, &resEleven10265); err != nil {
  26414. utils.ErrorLog("解析失败:%v", err)
  26415. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26416. return
  26417. }
  26418. res.InfRefmsgid = resEleven10265.InfRefmsgid
  26419. res.Output = resEleven10265.Output
  26420. res.ErrMsg = resEleven10265.ErrMsg
  26421. res.Cainfo = resEleven10265.Cainfo
  26422. res.WarnMsg = resEleven10265.WarnMsg
  26423. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  26424. res.Infcode = infocode
  26425. } else {
  26426. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  26427. utils.ErrorLog("解析失败:%v", err)
  26428. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26429. return
  26430. }
  26431. }
  26432. printor_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  26433. charge_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, order.Creator)
  26434. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, order.PatientId, order.SettleAccountsDate)
  26435. adminRole_two, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  26436. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, his_hospital.Doctor)
  26437. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  26438. var doctor_name string
  26439. if roles.ID == 0 {
  26440. doctor_name = "管理员"
  26441. } else {
  26442. doctor_name = roles.UserName
  26443. }
  26444. yiliao_leibie := ""
  26445. switch order.MedType {
  26446. case "11":
  26447. yiliao_leibie = "普通门诊"
  26448. break
  26449. case "12":
  26450. yiliao_leibie = "门诊挂号"
  26451. break
  26452. case "13":
  26453. yiliao_leibie = "急诊"
  26454. break
  26455. case "14":
  26456. yiliao_leibie = "门诊特殊病"
  26457. break
  26458. case "15":
  26459. yiliao_leibie = "门诊统筹"
  26460. break
  26461. case "16":
  26462. yiliao_leibie = "门诊慢性病"
  26463. break
  26464. case "21":
  26465. yiliao_leibie = "普通住院"
  26466. break
  26467. }
  26468. departments, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  26469. res.Output.Setlinfo.PsnCashPay = res.Output.Setlinfo.CashPayamt
  26470. if res.Infcode == 0 {
  26471. data2 := map[string]interface{}{
  26472. "diagnosis": name,
  26473. "order_infos": orderInfos,
  26474. "number": order.MdtrtId,
  26475. "date": order.SettleAccountsDate,
  26476. "charge_admin": charge_admin,
  26477. "printor_admin": printor_admin,
  26478. "info": res.Output.Setlinfo,
  26479. "order": order,
  26480. "bedCostTotal": bedCostTotal,
  26481. "bedCostSelfTotal": bedCostSelfTotal,
  26482. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  26483. "bedSelfTotal": bedSelfTotal,
  26484. "bedInscpTotal": bedInscpTotal,
  26485. "operationCostTotal": operationCostTotal,
  26486. "operationCostSelfTotal": operationCostSelfTotal,
  26487. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  26488. "operationSelfTotal": operationSelfTotal,
  26489. "operationInscpTotal": operationInscpTotal,
  26490. "otherCostTotal": otherCostTotal,
  26491. "otherCostSelfTotal": otherCostSelfTotal,
  26492. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  26493. "otherSelfTotal": otherSelfTotal,
  26494. "otherInscpTotal": otherInscpTotal,
  26495. "materialCostTotal": materialCostTotal,
  26496. "materialCostSelfTotal": materialCostSelfTotal,
  26497. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  26498. "materialSelfTotal": materialSelfTotal,
  26499. "materialInscpTotal": materialInscpTotal,
  26500. "westernMedicineCostTotal": westernMedicineCostTotal,
  26501. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  26502. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  26503. "westernMedicineSelfTotal": westernMedicineSelfTotal,
  26504. "westernMedicineInscpTotal": westernMedicineInscpTotal,
  26505. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  26506. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  26507. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  26508. "chineseTraditionalSelfTotal": chineseTraditionalSelfTotal,
  26509. "chineseTraditionalInscpTotal": chineseTraditionalInscpTotal,
  26510. "checkCostTotal": checkCostTotal,
  26511. "checkCostSelfTotal": checkCostSelfTotal,
  26512. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  26513. "checkSelfTotal": checkSelfTotal,
  26514. "checkInscpTotal": checkInscpTotal,
  26515. "laboratoryCostTotal": laboratoryCostTotal,
  26516. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  26517. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  26518. "laboratorySelfTotal": laboratorySelfTotal,
  26519. "laboratoryInscpTotal": laboratoryInscpTotal,
  26520. "treatCostTotal": treatCostTotal,
  26521. "treatCostSelfTotal": treatCostSelfTotal,
  26522. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  26523. "treatSelfTotal": treatSelfTotal,
  26524. "treatInscpTotal": treatInscpTotal,
  26525. "doctor_info": doctor_info,
  26526. "doctor_code": adminRole_two.DoctorCode,
  26527. "doctor_name": doctor_name,
  26528. "health_card_no": order.PsnNo,
  26529. "department": departments.Name,
  26530. "yiliao_leibie": yiliao_leibie,
  26531. "after_money": order.AccountPrice,
  26532. "patient": patient,
  26533. "org_name": miConfig.OrgName,
  26534. "org_code": miConfig.Code,
  26535. "order_number": order.Number,
  26536. "his_hospital": his_hospital,
  26537. "his": his,
  26538. "dia_config": dia_config,
  26539. "psn_cash_pay": order.PsnCashPay,
  26540. //"check_order_info": cus_slice,
  26541. }
  26542. data3 = append(data3, data2)
  26543. }
  26544. }
  26545. }
  26546. c.ServeSuccessJSON(map[string]interface{}{
  26547. "infos": data3,
  26548. })
  26549. }
  26550. func (c *HisApiController) GetSettleAccounts() {
  26551. //id, _ := c.GetInt64("id")
  26552. //record_time := c.GetString("record_time")
  26553. order_id, _ := c.GetInt64("order_id")
  26554. admin_user_id, _ := c.GetInt64("admin_user_id")
  26555. //timeLayout := "2006-01-02"
  26556. //loc, _ := time.LoadLocation("Local")
  26557. //
  26558. //theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  26559. //if err != nil {
  26560. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  26561. // return
  26562. //}Hbyb5203
  26563. //recordDateTime := theTime.Unix()
  26564. adminUser := c.GetAdminUserInfo()
  26565. order, _ := service.GetHisOrderByID(order_id)
  26566. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  26567. orderInfos, _ := service.GetHisOrderInfoByNumber(order.Number)
  26568. orderInfos_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  26569. orderInfos = append(orderInfos, orderInfos_two...)
  26570. his_hospital, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  26571. //diagnosisConfig, _ := service.FindDiagnoseById(his.Diagnosis)
  26572. var diagnosis_ids []string
  26573. if his.ID > 0 {
  26574. diagnosis_ids = strings.Split(his.Diagnosis, ",")
  26575. } else {
  26576. diagnosis_ids = strings.Split(his_hospital.Diagnosis, ",")
  26577. }
  26578. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, order.PatientId)
  26579. var dia_config []*models.HisXtDiagnoseConfig
  26580. var name string
  26581. for _, item := range diagnosis_ids {
  26582. id, _ := strconv.ParseInt(item, 10, 64)
  26583. diagnosisConfig, _ := service.FindDiagnoseById(id)
  26584. dia_config = append(dia_config, &diagnosisConfig)
  26585. if len(name) == 0 {
  26586. name = diagnosisConfig.ClassName
  26587. } else {
  26588. name = name + "," + diagnosisConfig.ClassName
  26589. }
  26590. }
  26591. if patient.UserOrgId == 10215 {
  26592. name = "慢性肾功能不全(血透治疗)"
  26593. }
  26594. var bedCostTotal float64 = 0 //床位总费
  26595. var bedCostSelfTotal float64 = 0 //床位自费
  26596. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  26597. var bedSelfTotal float64 = 0 //床位部分项目自费
  26598. var bedInscpTotal float64 = 0 //床位部分项目自费
  26599. var operationCostTotal float64 = 0 //手术费
  26600. var operationCostSelfTotal float64 = 0 //手术费
  26601. var operationCostPartSelfTotal float64 = 0 //手术费
  26602. var operationSelfTotal float64 = 0 //床位部分项目自费
  26603. var operationInscpTotal float64 = 0 //床位部分项目自费
  26604. var otherCostTotal float64 = 0 //其他费用
  26605. var otherCostSelfTotal float64 = 0 //其他费用
  26606. var otherCostPartSelfTotal float64 = 0 //其他费用
  26607. var otherSelfTotal float64 = 0 //床位部分项目自费
  26608. var otherInscpTotal float64 = 0 //床位部分项目自费
  26609. var materialCostTotal float64 = 0 //材料费
  26610. var materialCostSelfTotal float64 = 0 //材料费
  26611. var materialCostPartSelfTotal float64 = 0 //材料费
  26612. var materialSelfTotal float64 = 0 //床位部分项目自费
  26613. var materialInscpTotal float64 = 0 //床位部分项目自费
  26614. var westernMedicineCostTotal float64 = 0 //西药费
  26615. var westernMedicineCostSelfTotal float64 = 0 //西药费
  26616. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  26617. var westernMedicineSelfTotal float64 = 0 //床位部分项目自费
  26618. var westernMedicineInscpTotal float64 = 0 //床位部分项目自费
  26619. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  26620. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  26621. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  26622. var chineseTraditionalSelfTotal float64 = 0 //床位部分项目自费
  26623. var chineseTraditionalInscpTotal float64 = 0 //床位部分项目自费
  26624. var checkCostTotal float64 = 0 //检查费
  26625. var checkCostSelfTotal float64 = 0 //检查费
  26626. var checkCostPartSelfTotal float64 = 0 //检查费
  26627. var checkSelfTotal float64 = 0 //床位部分项目自费
  26628. var checkInscpTotal float64 = 0 //床位部分项目自费
  26629. var laboratoryCostTotal float64 = 0 //化验费
  26630. var laboratoryCostSelfTotal float64 = 0 //化验费
  26631. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  26632. var laboratorySelfTotal float64 = 0 //床位部分项目自费
  26633. var laboratoryInscpTotal float64 = 0 //床位部分项目自费
  26634. var treatCostTotal float64 = 0 //治疗费用
  26635. var treatCostSelfTotal float64 = 0 //治疗费用
  26636. var treatCostPartSelfTotal float64 = 0 //治疗费用
  26637. var treatSelfTotal float64 = 0 //床位部分项目自费
  26638. var treatInscpTotal float64 = 0 //床位部分项目自费
  26639. decimal.DivisionPrecision = 2
  26640. for _, item := range orderInfos {
  26641. if item.MedChrgitmType == "01" { //床位费
  26642. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  26643. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  26644. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  26645. bedSelfTotal, _ = decimal.NewFromFloat(bedSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  26646. bedInscpTotal, _ = decimal.NewFromFloat(bedInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  26647. }
  26648. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  26649. if item.MedChrgitmType == "03" { //检查费
  26650. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  26651. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  26652. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  26653. laboratorySelfTotal, _ = decimal.NewFromFloat(laboratorySelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  26654. laboratoryInscpTotal, _ = decimal.NewFromFloat(laboratoryInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  26655. }
  26656. } else {
  26657. if item.MedChrgitmType == "03" && adminUser.CurrentOrgId == 9504 { //手术费
  26658. fmt.Println("------------")
  26659. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  26660. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  26661. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  26662. }
  26663. if item.MedChrgitmType == "03" && adminUser.CurrentOrgId != 9504 { //手术费
  26664. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  26665. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  26666. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  26667. checkSelfTotal, _ = decimal.NewFromFloat(checkSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  26668. checkInscpTotal, _ = decimal.NewFromFloat(checkInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  26669. }
  26670. }
  26671. if item.MedChrgitmType == "04" { //化验费
  26672. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  26673. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  26674. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  26675. laboratorySelfTotal, _ = decimal.NewFromFloat(laboratorySelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  26676. laboratoryInscpTotal, _ = decimal.NewFromFloat(laboratoryInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  26677. }
  26678. if item.MedChrgitmType == "05" { //治疗费
  26679. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  26680. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  26681. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  26682. treatSelfTotal, _ = decimal.NewFromFloat(treatSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  26683. treatInscpTotal, _ = decimal.NewFromFloat(treatInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  26684. }
  26685. if item.MedChrgitmType == "06" && adminUser.CurrentOrgId == 9504 { //手术费
  26686. fmt.Println("------------")
  26687. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  26688. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  26689. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  26690. treatSelfTotal, _ = decimal.NewFromFloat(treatSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  26691. treatInscpTotal, _ = decimal.NewFromFloat(treatInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  26692. }
  26693. if item.MedChrgitmType == "06" && adminUser.CurrentOrgId != 9504 { //手术费
  26694. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  26695. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  26696. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  26697. operationSelfTotal, _ = decimal.NewFromFloat(operationSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  26698. operationInscpTotal, _ = decimal.NewFromFloat(operationInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  26699. }
  26700. if item.MedChrgitmType == "08" || item.MedChrgitmType == "1402" || item.MedChrgitmType == "1403" { //材料费
  26701. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  26702. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  26703. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  26704. materialSelfTotal, _ = decimal.NewFromFloat(materialSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  26705. materialInscpTotal, _ = decimal.NewFromFloat(materialInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  26706. }
  26707. if item.MedChrgitmType == "09" { //西药费
  26708. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  26709. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  26710. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  26711. westernMedicineSelfTotal, _ = decimal.NewFromFloat(westernMedicineSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  26712. westernMedicineInscpTotal, _ = decimal.NewFromFloat(westernMedicineInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  26713. }
  26714. if item.MedChrgitmType == "11" { //中成费
  26715. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  26716. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  26717. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  26718. chineseTraditionalSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  26719. chineseTraditionalInscpTotal, _ = decimal.NewFromFloat(chineseTraditionalInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  26720. }
  26721. if item.MedChrgitmType == "14" || item.MedChrgitmType == "0" || item.MedChrgitmType == "12" || item.MedChrgitmType == "02" { //其他费
  26722. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  26723. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  26724. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  26725. otherSelfTotal, _ = decimal.NewFromFloat(otherSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  26726. otherInscpTotal, _ = decimal.NewFromFloat(otherInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  26727. }
  26728. }
  26729. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  26730. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  26731. var user_name string
  26732. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  26733. if role.ID == 0 {
  26734. user_name = "管理员"
  26735. } else {
  26736. user_name = role.UserName
  26737. }
  26738. baseParams := models.BaseParams{
  26739. SecretKey: miConfig.SecretKey,
  26740. FixmedinsCode: miConfig.Code,
  26741. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  26742. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  26743. OrgName: miConfig.OrgName,
  26744. Doctor: user_name,
  26745. RequestUrl: miConfig.Url,
  26746. AccessKey: miConfig.AccessKey,
  26747. }
  26748. businessParams := models.BusinessParams{
  26749. PsnNo: order.PsnNo,
  26750. MdtrtId: order.MdtrtId,
  26751. SetlId: order.SetlId,
  26752. }
  26753. var res ResultEleven
  26754. var resah ResultElevenah
  26755. var resEleven10265 ResultEleven10265
  26756. if config.IsOpen == 1 {
  26757. if miConfig.MdtrtareaAdmvs == "421300" {
  26758. api := "http://192.168.124.4:9532/" + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  26759. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  26760. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  26761. resp, requestErr := http.Get(api)
  26762. if requestErr != nil {
  26763. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26764. return
  26765. }
  26766. body, ioErr := ioutil.ReadAll(resp.Body)
  26767. if ioErr != nil {
  26768. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26769. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26770. return
  26771. }
  26772. var respJSON map[string]interface{}
  26773. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  26774. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26775. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26776. return
  26777. }
  26778. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26779. result, _ := json.Marshal(respJSON)
  26780. fmt.Println("log")
  26781. fmt.Println(string(result))
  26782. if err := json.Unmarshal([]byte(result), &res); err != nil {
  26783. utils.ErrorLog("解析失败:%v", err)
  26784. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26785. return
  26786. }
  26787. } else if miConfig.MdtrtareaAdmvs == "420200" {
  26788. api := "http://192.168.0.197:9532/" + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  26789. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  26790. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  26791. resp, requestErr := http.Get(api)
  26792. if requestErr != nil {
  26793. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26794. return
  26795. }
  26796. body, ioErr := ioutil.ReadAll(resp.Body)
  26797. if ioErr != nil {
  26798. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26799. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26800. return
  26801. }
  26802. var respJSON map[string]interface{}
  26803. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  26804. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26805. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26806. return
  26807. }
  26808. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26809. result, _ := json.Marshal(respJSON)
  26810. fmt.Println("log")
  26811. fmt.Println(string(result))
  26812. if err := json.Unmarshal([]byte(result), &res); err != nil {
  26813. utils.ErrorLog("解析失败:%v", err)
  26814. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26815. return
  26816. }
  26817. } else if miConfig.MdtrtareaAdmvs == "420902" {
  26818. api := miConfig.Url + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  26819. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  26820. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  26821. resp, requestErr := http.Get(api)
  26822. if requestErr != nil {
  26823. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26824. return
  26825. }
  26826. body, ioErr := ioutil.ReadAll(resp.Body)
  26827. if ioErr != nil {
  26828. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26829. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26830. return
  26831. }
  26832. var respJSON map[string]interface{}
  26833. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  26834. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26835. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26836. return
  26837. }
  26838. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26839. result, _ := json.Marshal(respJSON)
  26840. fmt.Println("log")
  26841. fmt.Println(string(result))
  26842. if err := json.Unmarshal([]byte(result), &res); err != nil {
  26843. utils.ErrorLog("解析失败:%v", err)
  26844. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26845. return
  26846. }
  26847. }else if miConfig.MdtrtareaAdmvs == "421182" {
  26848. api := miConfig.Url + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  26849. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  26850. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&med_type=" + order.MedType
  26851. resp, requestErr := http.Get(api)
  26852. if requestErr != nil {
  26853. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26854. return
  26855. }
  26856. body, ioErr := ioutil.ReadAll(resp.Body)
  26857. if ioErr != nil {
  26858. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26859. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26860. return
  26861. }
  26862. var respJSON map[string]interface{}
  26863. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  26864. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26865. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26866. return
  26867. }
  26868. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26869. result, _ := json.Marshal(respJSON)
  26870. fmt.Println("log")
  26871. fmt.Println(string(result))
  26872. if err := json.Unmarshal([]byte(result), &res); err != nil {
  26873. utils.ErrorLog("解析失败:%v", err)
  26874. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26875. return
  26876. }
  26877. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  26878. var api string
  26879. if miConfig.MdtrtareaAdmvs == "320921" {
  26880. api = "http://192.168.2.3:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  26881. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  26882. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  26883. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  26884. } else {
  26885. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  26886. api = "http://192.168.5.251:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  26887. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  26888. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  26889. }
  26890. resp, requestErr := http.Get(api)
  26891. if requestErr != nil {
  26892. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26893. return
  26894. }
  26895. body, ioErr := ioutil.ReadAll(resp.Body)
  26896. if ioErr != nil {
  26897. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26898. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26899. return
  26900. }
  26901. var respJSON map[string]interface{}
  26902. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  26903. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26904. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26905. return
  26906. }
  26907. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26908. result, _ := json.Marshal(respJSON)
  26909. fmt.Println("log")
  26910. fmt.Println(string(result))
  26911. if err := json.Unmarshal([]byte(result), &resEleven10265); err != nil {
  26912. utils.ErrorLog("解析失败:%v", err)
  26913. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26914. return
  26915. }
  26916. res.InfRefmsgid = resEleven10265.InfRefmsgid
  26917. res.Output = resEleven10265.Output
  26918. res.ErrMsg = resEleven10265.ErrMsg
  26919. res.Cainfo = resEleven10265.Cainfo
  26920. res.WarnMsg = resEleven10265.WarnMsg
  26921. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  26922. res.Infcode = infocode
  26923. } else if miConfig.MdtrtareaAdmvs == "350500" {
  26924. result, requestLog, _ := service.FJyb5203(baseParams, businessParams, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  26925. saveLog(result, requestLog, "5203", "结算单")
  26926. var dat map[string]interface{}
  26927. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  26928. fmt.Println(dat)
  26929. } else {
  26930. fmt.Println(err)
  26931. }
  26932. userJSONBytes, _ := json.Marshal(dat)
  26933. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  26934. utils.ErrorLog("解析失败:%v", err)
  26935. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26936. return
  26937. }
  26938. } else if miConfig.MdtrtareaAdmvs == "360302" {
  26939. baseParams.InsuplcAdmdvs = his_hospital.InsuplcAdmdvs
  26940. result3, requestLog3 := service.Jxyb5201(baseParams, businessParams)
  26941. fmt.Println(result3)
  26942. fmt.Println(requestLog3)
  26943. result2, requestLog2 := service.Jxyb5202(baseParams, businessParams)
  26944. fmt.Println(result2)
  26945. fmt.Println(requestLog2)
  26946. result, requestLog := service.Jxyb5203(baseParams, businessParams)
  26947. saveLog(result, requestLog, "5203", "结算单")
  26948. var dat map[string]interface{}
  26949. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  26950. fmt.Println(dat)
  26951. } else {
  26952. fmt.Println(err)
  26953. }
  26954. userJSONBytes, _ := json.Marshal(dat)
  26955. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  26956. utils.ErrorLog("解析失败:%v", err)
  26957. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26958. return
  26959. }
  26960. } else if miConfig.MdtrtareaAdmvs == "341203" {
  26961. var api string
  26962. api = miConfig.SecretKey + "ahyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  26963. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  26964. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  26965. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  26966. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  26967. resp, requestErr := http.Get(api)
  26968. if requestErr != nil {
  26969. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26970. return
  26971. }
  26972. body, ioErr := ioutil.ReadAll(resp.Body)
  26973. if ioErr != nil {
  26974. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26975. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26976. return
  26977. }
  26978. var respJSON map[string]interface{}
  26979. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  26980. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26981. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26982. return
  26983. }
  26984. status := respJSON["data"].(map[string]interface{})["status"].(string)
  26985. if status == "0" {
  26986. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  26987. c.ServeSuccessJSON(map[string]interface{}{
  26988. "failed_code": -10,
  26989. "msg": err_msg,
  26990. })
  26991. return
  26992. }
  26993. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26994. result, _ := json.Marshal(respJSON)
  26995. fmt.Println("log")
  26996. fmt.Println(string(result))
  26997. if err := json.Unmarshal([]byte(result), &resah); err != nil {
  26998. utils.ErrorLog("解析失败:%v", err)
  26999. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27000. return
  27001. }
  27002. res.InfRefmsgid = resah.InfRefmsgid
  27003. timestamp := int64(resah.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  27004. // 创建对应的Time类型
  27005. t := time.UnixMilli(timestamp)
  27006. // 格式化成指定的日期字符串
  27007. str := t.Format("2006-01-02 15:04:05")
  27008. timestamp2 := int64(resah.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  27009. // 创建对应的Time类型
  27010. t3 := time.UnixMilli(timestamp2)
  27011. // 格式化成指定的日期字符串
  27012. str2 := t3.Format("2006-01-02 15:04:05")
  27013. timestamp3 := int64(resah.Output.Setlinfo.Begndate) // 输入要转换的时间戳(这里仅作示例)
  27014. // 创建对应的Time类型
  27015. t4 := time.UnixMilli(timestamp3)
  27016. // 格式化成指定的日期字符串
  27017. str3 := t4.Format("2006-01-02 15:04:05")
  27018. timestamp4 := int64(resah.Output.Setlinfo.Enddate) // 输入要转换的时间戳(这里仅作示例)
  27019. // 创建对应的Time类型
  27020. t5 := time.UnixMilli(timestamp4)
  27021. // 格式化成指定的日期字符串
  27022. str5 := t5.Format("2006-01-02 15:04:05")
  27023. res.Output.Setlinfo.Brdy = str2
  27024. res.Output.Setlinfo.SetlTime = str
  27025. res.Output.Setlinfo.Begndate = str3
  27026. res.Output.Setlinfo.Enddate = str5
  27027. res.Output.Setlinfo.Year = resah.Output.Setlinfo.Year
  27028. res.Output.Setlinfo.PsnPay = resah.Output.Setlinfo.PsnPay
  27029. res.Output.Setlinfo.OpterID = resah.Output.Setlinfo.OpterID
  27030. res.Output.Setlinfo.FlxempeFlag = resah.Output.Setlinfo.FlxempeFlag
  27031. res.Output.Setlinfo.Gend = resah.Output.Setlinfo.Gend
  27032. res.Output.Setlinfo.MdtrtID = resah.Output.Setlinfo.MdtrtID
  27033. res.Output.Setlinfo.AcctMulaidPay = resah.Output.Setlinfo.AcctMulaidPay
  27034. res.Output.Setlinfo.AcctPay = resah.Output.Setlinfo.AcctPay
  27035. res.Output.Setlinfo.CvlservPay = resah.Output.Setlinfo.CvlservPay
  27036. res.Output.Setlinfo.ActPayDedc = resah.Output.Setlinfo.ActPayDedc
  27037. res.Output.Setlinfo.Age = resah.Output.Setlinfo.Age
  27038. res.Output.Setlinfo.Balc = resah.Output.Setlinfo.Balc
  27039. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  27040. res.Output.Setlinfo.Certno = resah.Output.Setlinfo.Certno
  27041. res.Output.Setlinfo.ClrOptins = resah.Output.Setlinfo.ClrOptins
  27042. res.Output.Setlinfo.ClrType = resah.Output.Setlinfo.ClrOptins
  27043. res.Output.Setlinfo.ClrWay = resah.Output.Setlinfo.ClrOptins
  27044. res.Output.Setlinfo.CvlservFlag = resah.Output.Setlinfo.ClrOptins
  27045. res.Output.Setlinfo.CvlservPay = resah.Output.Setlinfo.CvlservPay
  27046. res.Output.Setlinfo.FulamtOwnpayAmt = resah.Output.Setlinfo.FulamtOwnpayAmt
  27047. res.Output.Setlinfo.FundPaySumamt = resah.Output.Setlinfo.FundPaySumamt
  27048. res.Output.Setlinfo.Gend = resah.Output.Setlinfo.Gend
  27049. res.Output.Setlinfo.HifesPay = resah.Output.Setlinfo.HifesPay
  27050. res.Output.Setlinfo.HifmiPay = resah.Output.Setlinfo.HifmiPay
  27051. res.Output.Setlinfo.HifpPay = resah.Output.Setlinfo.HifpPay
  27052. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  27053. //res.Output.Setlinfo.HospPartAmt = resah.Output.Setlinfo.HospPartAmt
  27054. res.Output.Setlinfo.InscpScpAmt = resah.Output.Setlinfo.InscpScpAmt
  27055. res.Output.Setlinfo.Insutype = resah.Output.Setlinfo.Insutype
  27056. res.Output.Setlinfo.MafPay = resah.Output.Setlinfo.MafPay
  27057. //res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  27058. res.Output.Setlinfo.HifobPay = resah.Output.Setlinfo.HifobPay
  27059. res.Output.Setlinfo.MdtrtID = resah.Output.Setlinfo.MdtrtID
  27060. res.Output.Setlinfo.MedType = resah.Output.Setlinfo.MedType
  27061. res.Output.Setlinfo.MedfeeSumamt = resah.Output.Setlinfo.MedfeeSumamt
  27062. res.Output.Setlinfo.MedinsSetlID = resah.Output.Setlinfo.MedinsSetlID
  27063. res.Output.Setlinfo.Naty = resah.Output.Setlinfo.Naty
  27064. res.Output.Setlinfo.OthPay = resah.Output.Setlinfo.OthPay
  27065. res.Output.Setlinfo.OverlmtSelfpay = resah.Output.Setlinfo.OverlmtSelfpay
  27066. res.Output.Setlinfo.PoolPropSelfpay = resah.Output.Setlinfo.PoolPropSelfpay
  27067. res.Output.Setlinfo.PreselfpayAmt = resah.Output.Setlinfo.PreselfpayAmt
  27068. res.Output.Setlinfo.PsnCashPay = resah.Output.Setlinfo.PsnCashPay
  27069. res.Output.Setlinfo.PsnCertType = resah.Output.Setlinfo.ClrOptins
  27070. res.Output.Setlinfo.PsnName = resah.Output.Setlinfo.PsnName
  27071. res.Output.Setlinfo.PsnNo = resah.Output.Setlinfo.PsnNo
  27072. //res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  27073. res.Output.Setlinfo.PsnType = resah.Output.Setlinfo.PsnType
  27074. res.Output.Setlinfo.SetlID = resah.Output.Setlinfo.SetlID
  27075. //res.Output.Setldetail = resah.Output.Setldetail
  27076. res.ErrMsg = resah.ErrMsg
  27077. res.Cainfo = resah.Cainfo
  27078. res.WarnMsg = resah.WarnMsg
  27079. } else if miConfig.MdtrtareaAdmvs == "430800" {
  27080. result, requestLog := service.Hnyb5203(baseParams, businessParams)
  27081. saveLog(result, requestLog, "5203", "结算单")
  27082. var dat map[string]interface{}
  27083. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  27084. fmt.Println(dat)
  27085. } else {
  27086. fmt.Println(err)
  27087. }
  27088. userJSONBytes, _ := json.Marshal(dat)
  27089. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27090. utils.ErrorLog("解析失败:%v", err)
  27091. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27092. return
  27093. }
  27094. } else if miConfig.MdtrtareaAdmvs == "150499" {
  27095. api := "http://172.16.13.254:9532/" + "nmyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  27096. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  27097. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  27098. resp, requestErr := http.Get(api)
  27099. if requestErr != nil {
  27100. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27101. return
  27102. }
  27103. body, ioErr := ioutil.ReadAll(resp.Body)
  27104. if ioErr != nil {
  27105. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27106. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27107. return
  27108. }
  27109. var respJSON map[string]interface{}
  27110. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27111. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27112. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27113. return
  27114. }
  27115. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27116. result, _ := json.Marshal(respJSON)
  27117. fmt.Println("log")
  27118. fmt.Println(string(result))
  27119. if err := json.Unmarshal([]byte(result), &resEleven10265); err != nil {
  27120. utils.ErrorLog("解析失败:%v", err)
  27121. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27122. return
  27123. }
  27124. res.InfRefmsgid = resEleven10265.InfRefmsgid
  27125. res.Output = resEleven10265.Output
  27126. res.ErrMsg = resEleven10265.ErrMsg
  27127. res.Cainfo = resEleven10265.Cainfo
  27128. res.WarnMsg = resEleven10265.WarnMsg
  27129. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  27130. res.Infcode = infocode
  27131. } else if miConfig.MdtrtareaAdmvs == "441799" {
  27132. api := miConfig.Url + "gdyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  27133. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  27134. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  27135. resp, requestErr := http.Get(api)
  27136. if requestErr != nil {
  27137. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27138. return
  27139. }
  27140. body, ioErr := ioutil.ReadAll(resp.Body)
  27141. if ioErr != nil {
  27142. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27143. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27144. return
  27145. }
  27146. var respJSON map[string]interface{}
  27147. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27148. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27149. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27150. return
  27151. }
  27152. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27153. result, _ := json.Marshal(respJSON)
  27154. if err := json.Unmarshal([]byte(result), &res); err != nil {
  27155. utils.ErrorLog("解析失败:%v", err)
  27156. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27157. return
  27158. }
  27159. } else if miConfig.MdtrtareaAdmvs == "450721" {
  27160. service.Gxyb9001(baseParams.OrgName, baseParams.Doctor, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, admin_user_id, order.SetlId, order.MdtrtId, order.PsnNo, order.MedinsSetlId)
  27161. //return
  27162. } else {
  27163. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  27164. if len(his.InsuplcAdmdvs) == 0 {
  27165. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  27166. } else {
  27167. baseParams.InsuplcAdmdvs = his.InsuplcAdmdvs
  27168. }
  27169. result := service.Gdyb5203(baseParams, businessParams)
  27170. //service.Gdyb5204(baseParams, businessParams)
  27171. //service.Gdyb5302(businessParams.PsnNo, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs, baseParams.SecretKey)
  27172. var dat map[string]interface{}
  27173. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  27174. fmt.Println(dat)
  27175. } else {
  27176. fmt.Println(err)
  27177. }
  27178. userJSONBytes, _ := json.Marshal(dat)
  27179. if miConfig.Code == "H15049901371" {
  27180. if err := json.Unmarshal(userJSONBytes, &resEleven10265); err != nil {
  27181. utils.ErrorLog("解析失败:%v", err)
  27182. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27183. return
  27184. }
  27185. res.InfRefmsgid = resEleven10265.InfRefmsgid
  27186. res.Output = resEleven10265.Output
  27187. res.ErrMsg = resEleven10265.ErrMsg
  27188. res.Cainfo = resEleven10265.Cainfo
  27189. res.WarnMsg = resEleven10265.WarnMsg
  27190. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  27191. res.Infcode = infocode
  27192. } else {
  27193. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27194. utils.ErrorLog("解析失败:%v", err)
  27195. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27196. return
  27197. }
  27198. }
  27199. }
  27200. printor_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  27201. charge_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, order.Creator)
  27202. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, order.PatientId, order.SettleAccountsDate)
  27203. adminRole_two, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  27204. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, his_hospital.Doctor)
  27205. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  27206. var doctor_name string
  27207. if roles.ID == 0 {
  27208. doctor_name = "管理员"
  27209. } else {
  27210. doctor_name = roles.UserName
  27211. }
  27212. yiliao_leibie := ""
  27213. switch order.MedType {
  27214. case "11":
  27215. yiliao_leibie = "普通门诊"
  27216. break
  27217. case "12":
  27218. yiliao_leibie = "门诊挂号"
  27219. break
  27220. case "13":
  27221. yiliao_leibie = "急诊"
  27222. break
  27223. case "14":
  27224. yiliao_leibie = "门诊特殊病"
  27225. break
  27226. case "15":
  27227. yiliao_leibie = "门诊统筹"
  27228. break
  27229. case "16":
  27230. yiliao_leibie = "门诊慢性病"
  27231. break
  27232. case "21":
  27233. yiliao_leibie = "普通住院"
  27234. break
  27235. }
  27236. //var rf []CustomFundPay
  27237. //json.Unmarshal([]byte(order.SetlDetail), &rf)
  27238. departments, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  27239. res.Output.Setlinfo.PsnCashPay = order.PsnCashPay
  27240. if res.Infcode == 0 {
  27241. if adminUser.CurrentOrgId == 10215 || adminUser.CurrentOrgId == 10387 || adminUser.CurrentOrgId == 9919 || adminUser.CurrentOrgId == 10088 || adminUser.CurrentOrgId == 10150 || adminUser.CurrentOrgId == 10510 {
  27242. c.ServeSuccessJSON(map[string]interface{}{
  27243. "diagnosis": name,
  27244. "order_infos": orderInfos,
  27245. "number": order.MdtrtId,
  27246. "date": order.SettleAccountsDate,
  27247. "charge_admin": charge_admin,
  27248. "printor_admin": printor_admin,
  27249. "info": res.Output.Setlinfo,
  27250. "order": order,
  27251. "bedCostTotal": bedCostTotal,
  27252. "bedCostSelfTotal": bedCostSelfTotal,
  27253. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  27254. "bedSelfTotal": bedSelfTotal,
  27255. "bedInscpTotal": bedInscpTotal,
  27256. "operationCostTotal": operationCostTotal,
  27257. "operationCostSelfTotal": operationCostSelfTotal,
  27258. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  27259. "operationSelfTotal": operationSelfTotal,
  27260. "operationInscpTotal": operationInscpTotal,
  27261. "otherCostTotal": otherCostTotal,
  27262. "otherCostSelfTotal": otherCostSelfTotal,
  27263. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  27264. "otherSelfTotal": otherSelfTotal,
  27265. "otherInscpTotal": otherInscpTotal,
  27266. "materialCostTotal": materialCostTotal,
  27267. "materialCostSelfTotal": materialCostSelfTotal,
  27268. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  27269. "materialSelfTotal": materialSelfTotal,
  27270. "materialInscpTotal": materialInscpTotal,
  27271. "westernMedicineCostTotal": westernMedicineCostTotal,
  27272. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  27273. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  27274. "westernMedicineSelfTotal": westernMedicineSelfTotal,
  27275. "westernMedicineInscpTotal": westernMedicineInscpTotal,
  27276. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  27277. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  27278. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  27279. "chineseTraditionalSelfTotal": chineseTraditionalSelfTotal,
  27280. "chineseTraditionalInscpTotal": chineseTraditionalInscpTotal,
  27281. "checkCostTotal": checkCostTotal,
  27282. "checkCostSelfTotal": checkCostSelfTotal,
  27283. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  27284. "checkSelfTotal": checkSelfTotal,
  27285. "checkInscpTotal": checkInscpTotal,
  27286. "laboratoryCostTotal": laboratoryCostTotal,
  27287. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  27288. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  27289. "laboratorySelfTotal": laboratorySelfTotal,
  27290. "laboratoryInscpTotal": laboratoryInscpTotal,
  27291. "treatCostTotal": treatCostTotal,
  27292. "treatCostSelfTotal": treatCostSelfTotal,
  27293. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  27294. "treatSelfTotal": treatSelfTotal,
  27295. "treatInscpTotal": treatInscpTotal,
  27296. "doctor_info": doctor_info,
  27297. "doctor_code": adminRole_two.DoctorCode,
  27298. "doctor_name": doctor_name,
  27299. "health_card_no": order.PsnNo,
  27300. "department": departments.Name,
  27301. "yiliao_leibie": yiliao_leibie,
  27302. "after_money": order.AccountPrice,
  27303. "patient": patient,
  27304. "org_name": miConfig.OrgName,
  27305. "org_code": miConfig.Code,
  27306. "order_number": order.Number,
  27307. "his_hospital": his_hospital,
  27308. "his": his,
  27309. "dia_config": dia_config,
  27310. "psn_cash_pay": order.PsnCashPay,
  27311. //"funds": rf,
  27312. //"check_order_info": cus_slice,
  27313. })
  27314. } else {
  27315. c.ServeSuccessJSON(map[string]interface{}{
  27316. "diagnosis": name,
  27317. "order_infos": orderInfos,
  27318. "number": order.MdtrtId,
  27319. "date": order.SettleAccountsDate,
  27320. "charge_admin": charge_admin,
  27321. "printor_admin": printor_admin,
  27322. "info": order,
  27323. "order": order,
  27324. "bedCostTotal": bedCostTotal,
  27325. "bedCostSelfTotal": bedCostSelfTotal,
  27326. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  27327. "bedSelfTotal": bedSelfTotal,
  27328. "bedInscpTotal": bedInscpTotal,
  27329. "operationCostTotal": operationCostTotal,
  27330. "operationCostSelfTotal": operationCostSelfTotal,
  27331. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  27332. "operationSelfTotal": operationSelfTotal,
  27333. "operationInscpTotal": operationInscpTotal,
  27334. "otherCostTotal": otherCostTotal,
  27335. "otherCostSelfTotal": otherCostSelfTotal,
  27336. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  27337. "otherSelfTotal": otherSelfTotal,
  27338. "otherInscpTotal": otherInscpTotal,
  27339. "materialCostTotal": materialCostTotal,
  27340. "materialCostSelfTotal": materialCostSelfTotal,
  27341. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  27342. "materialSelfTotal": materialSelfTotal,
  27343. "materialInscpTotal": materialInscpTotal,
  27344. "westernMedicineCostTotal": westernMedicineCostTotal,
  27345. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  27346. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  27347. "westernMedicineSelfTotal": westernMedicineSelfTotal,
  27348. "westernMedicineInscpTotal": westernMedicineInscpTotal,
  27349. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  27350. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  27351. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  27352. "chineseTraditionalSelfTotal": chineseTraditionalSelfTotal,
  27353. "chineseTraditionalInscpTotal": chineseTraditionalInscpTotal,
  27354. "checkCostTotal": checkCostTotal,
  27355. "checkCostSelfTotal": checkCostSelfTotal,
  27356. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  27357. "checkSelfTotal": checkSelfTotal,
  27358. "checkInscpTotal": checkInscpTotal,
  27359. "laboratoryCostTotal": laboratoryCostTotal,
  27360. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  27361. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  27362. "laboratorySelfTotal": laboratorySelfTotal,
  27363. "laboratoryInscpTotal": laboratoryInscpTotal,
  27364. "treatCostTotal": treatCostTotal,
  27365. "treatCostSelfTotal": treatCostSelfTotal,
  27366. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  27367. "treatSelfTotal": treatSelfTotal,
  27368. "treatInscpTotal": treatInscpTotal,
  27369. "doctor_info": doctor_info,
  27370. "doctor_code": adminRole_two.DoctorCode,
  27371. "doctor_name": doctor_name,
  27372. "health_card_no": order.PsnNo,
  27373. "department": departments.Name,
  27374. "yiliao_leibie": yiliao_leibie,
  27375. "after_money": order.AccountPrice,
  27376. "patient": patient,
  27377. "org_name": miConfig.OrgName,
  27378. "org_code": miConfig.Code,
  27379. "order_number": order.Number,
  27380. "his_hospital": his_hospital,
  27381. "his": his,
  27382. "dia_config": dia_config,
  27383. "psn_cash_pay": order.PsnCashPay,
  27384. //"funds": rf,
  27385. //"check_order_info": cus_slice,
  27386. })
  27387. }
  27388. }
  27389. }
  27390. }
  27391. //func (c *HisApiController) CheckTreatment() {
  27392. // patient_id, _ := c.GetInt64("patient_id")
  27393. // id_card_no := c.GetString("id_card_no")
  27394. // insutype := c.GetString("insutype")
  27395. // med_type := c.GetString("med_type")
  27396. // admin_user_id, _ := c.GetInt64("admin_user_id")
  27397. //
  27398. // adminUser := c.GetAdminUserInfo()
  27399. // patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  27400. //
  27401. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  27402. // config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  27403. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  27404. //
  27405. // if miConfig.MdtrtareaAdmvs == "421300" {
  27406. // var res ResultTwo
  27407. // api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  27408. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  27409. // "&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)
  27410. // resp, requestErr := http.Get(api)
  27411. // if requestErr != nil {
  27412. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27413. // return
  27414. // }
  27415. //
  27416. // body, ioErr := ioutil.ReadAll(resp.Body)
  27417. // if ioErr != nil {
  27418. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27419. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27420. // return
  27421. // }
  27422. // var respJSON map[string]interface{}
  27423. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27424. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27425. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27426. // return
  27427. // }
  27428. //
  27429. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27430. // result, _ := json.Marshal(respJSON)
  27431. //
  27432. // if err := json.Unmarshal([]byte(result), &res); err != nil {
  27433. // utils.ErrorLog("解析失败:%v", err)
  27434. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27435. // return
  27436. // }
  27437. //
  27438. // if res.Infcode == 0 {
  27439. //
  27440. // api := "http://192.168.124.4:9532/" + "hbyb/2001?cert_no=" + "" +
  27441. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  27442. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&psn_no=" + res.Output.Baseinfo.PsnNo + "&insutype=" + insutype + "&med_type=" + med_type
  27443. // resp, requestErr := http.Get(api)
  27444. // if requestErr != nil {
  27445. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27446. // return
  27447. // }
  27448. //
  27449. // body, ioErr := ioutil.ReadAll(resp.Body)
  27450. // if ioErr != nil {
  27451. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27452. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27453. // return
  27454. // }
  27455. // var respJSON map[string]interface{}
  27456. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27457. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27458. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27459. // return
  27460. // }
  27461. // var res Result2001
  27462. //
  27463. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27464. // result2, _ := json.Marshal(respJSON)
  27465. //
  27466. // if err := json.Unmarshal([]byte(result2), &res); err != nil {
  27467. // utils.ErrorLog("解析失败:%v", err)
  27468. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27469. // return
  27470. // }
  27471. //
  27472. // if res.Infcode == 0 {
  27473. // c.ServeSuccessJSON(map[string]interface{}{
  27474. // "msg": res.Output.Trtinfo,
  27475. // })
  27476. // }
  27477. //
  27478. // } else {
  27479. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  27480. // return
  27481. // }
  27482. //
  27483. // } else {
  27484. //
  27485. // result := service.Gdyb1101A(id_card_no, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  27486. // var dat map[string]interface{}
  27487. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  27488. // fmt.Println(dat)
  27489. // } else {
  27490. // fmt.Println(err)
  27491. // }
  27492. // userJSONBytes, _ := json.Marshal(dat)
  27493. // var res ResultTwo
  27494. // var res10265 ResultTwo10265
  27495. // if miConfig.Code == "H15049901371" {
  27496. // if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  27497. // utils.ErrorLog("解析失败:%v", err)
  27498. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27499. // return
  27500. // }
  27501. // res.ErrMsg = res10265.ErrMsg
  27502. // infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  27503. // res.Infcode = infocode
  27504. // res.Output = res10265.Output
  27505. // res.InfRefmsgid = res10265.InfRefmsgid
  27506. // } else {
  27507. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27508. // utils.ErrorLog("解析失败:%v", err)
  27509. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27510. // return
  27511. // }
  27512. // }
  27513. //
  27514. // var user_name string
  27515. // role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, adminUser.AdminUser.Id)
  27516. // if role.ID == 0 {
  27517. // user_name = "xxx"
  27518. // } else {
  27519. // user_name = role.UserName
  27520. // }
  27521. //
  27522. // baseParams := models.BaseParams{
  27523. // SecretKey: miConfig.SecretKey,
  27524. // FixmedinsCode: miConfig.Code,
  27525. // InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  27526. // MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  27527. // OrgName: miConfig.OrgName,
  27528. // Doctor: user_name,
  27529. // }
  27530. //
  27531. // if config.IsOpen == 1 {
  27532. // if miConfig.Code == "H15049901371" {
  27533. // if med_type == "14" {
  27534. // if insutype == "390" {
  27535. // med_type = "9933"
  27536. // } else if insutype == "310" {
  27537. // med_type = "990502"
  27538. // }
  27539. // } else if med_type == "11" {
  27540. // med_type = "11"
  27541. // }
  27542. // }
  27543. // result := service.Gdyb2001(baseParams, res.Output.Baseinfo.PsnNo, insutype, med_type)
  27544. // var dat map[string]interface{}
  27545. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  27546. // fmt.Println(dat)
  27547. // } else {
  27548. // fmt.Println(err)
  27549. // }
  27550. // var res Result2001
  27551. // var res10265 Result2001Org10265
  27552. // if miConfig.Code == "H15049901371" {
  27553. // if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  27554. // utils.ErrorLog("解析失败:%v", err)
  27555. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27556. // return
  27557. // }
  27558. // res.ErrMsg = res10265.ErrMsg
  27559. // res.Output = res10265.Output
  27560. // res.InfRefmsgid = res10265.InfRefmsgid
  27561. // infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  27562. // res.Infcode = infocode
  27563. // } else {
  27564. // if err := json.Unmarshal([]byte(result), &res); err != nil {
  27565. // utils.ErrorLog("解析失败:%v", err)
  27566. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27567. // return
  27568. // }
  27569. // }
  27570. // if res.Infcode == 0 {
  27571. // c.ServeSuccessJSON(map[string]interface{}{
  27572. // "msg": res.Output.Trtinfo,
  27573. // })
  27574. // }
  27575. // }
  27576. // }
  27577. //}
  27578. //func (c *HisApiController) PutRecord() {
  27579. // id, _ := c.GetInt64("id")
  27580. // record_time := c.GetString("record_time")
  27581. // timeLayout := "2006-01-02"
  27582. // loc, _ := time.LoadLocation("Local")
  27583. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  27584. // if err != nil {
  27585. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  27586. // return
  27587. // }
  27588. // recordDateTime := theTime.Unix()
  27589. //
  27590. // adminInfo := c.GetAdminUserInfo()
  27591. // patient, _ := service.GetPatientByID(adminInfo.CurrentOrgId, id)
  27592. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  27593. //
  27594. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  27595. //
  27596. // fmt.Println(miConfig.SecretKey)
  27597. //
  27598. // if patient == nil {
  27599. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  27600. // return
  27601. // }
  27602. // if len(patient.IdCardNo) == 0 {
  27603. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  27604. // return
  27605. // }
  27606. // config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  27607. // if config.IsOpen == 1 {
  27608. // 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
  27609. // resp, requestErr := http.Get(api)
  27610. // if requestErr != nil {
  27611. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27612. // return
  27613. // }
  27614. // defer resp.Body.Close()
  27615. // body, ioErr := ioutil.ReadAll(resp.Body)
  27616. // if ioErr != nil {
  27617. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27618. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27619. // return
  27620. // }
  27621. // var respJSON map[string]interface{}
  27622. //
  27623. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27624. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27625. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27626. // return
  27627. // }
  27628. //
  27629. // userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27630. // userJSONBytes, _ := json.Marshal(userJSON)
  27631. // var res ResultTwo
  27632. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27633. // utils.ErrorLog("解析失败:%v", err)
  27634. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27635. // return
  27636. // }
  27637. // Iinfos, _ := json.Marshal(res.Output.Iinfo)
  27638. // Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  27639. // infoStr := string(Iinfos)
  27640. // idetinfoStr := string(Idetinfos)
  27641. //
  27642. // if res.Infcode == 0 {
  27643. // his := models.VMHisPatient{
  27644. // Status: 1,
  27645. // Ctime: time.Now().Unix(),
  27646. // Mtime: time.Now().Unix(),
  27647. // PsnNo: res.Output.Baseinfo.PsnNo,
  27648. // PsnCertType: res.Output.Baseinfo.PsnCertType,
  27649. // Certno: res.Output.Baseinfo.Certno,
  27650. // PsnName: res.Output.Baseinfo.PsnName,
  27651. // Gend: res.Output.Baseinfo.Gend,
  27652. // Naty: res.Output.Baseinfo.Naty,
  27653. // Brdy: res.Output.Baseinfo.Brdy,
  27654. // Age: res.Output.Baseinfo.Age,
  27655. // Iinfo: infoStr,
  27656. // Idetinfo: idetinfoStr,
  27657. // PatientId: patient.ID,
  27658. // RecordDate: theTime.Unix(),
  27659. // UserOrgId: adminInfo.CurrentOrgId,
  27660. // AdminUserId: adminInfo.AdminUser.Id,
  27661. // IsReturn: 1,
  27662. // }
  27663. //
  27664. // //doctor_id := strconv.FormatInt(patientPrescription.DoctorId, 10)
  27665. // //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")
  27666. // //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")
  27667. //
  27668. // //var dat map[string]interface{}
  27669. // //if err := json.Unmarshal([]byte(result), &dat); err == nil {
  27670. // // fmt.Println(dat)
  27671. // //} else {
  27672. // // fmt.Println(err)
  27673. // //}
  27674. //
  27675. // var dat2 map[string]interface{}
  27676. // if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  27677. // fmt.Println(dat2)
  27678. // } else {
  27679. // fmt.Println(err)
  27680. // }
  27681. //
  27682. // } else {
  27683. // adminUser := c.GetAdminUserInfo()
  27684. // errlog := &models.HisOrderError{
  27685. // UserOrgId: adminUser.CurrentOrgId,
  27686. // Ctime: time.Now().Unix(),
  27687. // Mtime: time.Now().Unix(),
  27688. // ErrMsg: res.ErrMsg,
  27689. // Status: 1,
  27690. // PatientId: id,
  27691. // RecordTime: recordDateTime,
  27692. // Stage: 1,
  27693. // }
  27694. // service.CreateErrMsgLog(errlog)
  27695. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  27696. // return
  27697. // }
  27698. // }
  27699. //
  27700. //}
  27701. //func (c *HisApiController) GetUploadDiag() {
  27702. // id, _ := c.GetInt64("id")
  27703. // record_time := c.GetString("record_time")
  27704. //
  27705. // diagnosis_id, _ := c.GetInt64("diagnosis")
  27706. // sick_type, _ := c.GetInt64("sick_type")
  27707. // reg_type, _ := c.GetInt64("reg_type")
  27708. //
  27709. // timeLayout := "2006-01-02"
  27710. // loc, _ := time.LoadLocation("Local")
  27711. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  27712. // if err != nil {
  27713. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  27714. // return
  27715. // }
  27716. //
  27717. // var patientPrescription models.HisPrescriptionInfo
  27718. // recordDateTime := theTime.Unix()
  27719. // adminInfo := c.GetAdminUserInfo()
  27720. // patientPrescription, _ = service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  27721. //
  27722. // if patientPrescription.ID == 0 {
  27723. // patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  27724. // }
  27725. //
  27726. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  27727. // diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  27728. // his, _ := service.GetVMHisPatientInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  27729. // sickConfig, _ := service.FindSickById(sick_type)
  27730. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  27731. //
  27732. // api2 := "http://127.0.0.1:9532/" + "gdyb/four?psn_no=" + his.PsnNo +
  27733. // "&mdtrt_id=" + his.Number + "&doctor=" + patientPrescription.Doctor + "&department=" + department.Name +
  27734. // "&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 +
  27735. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&sick_code=" + sickConfig.ContentCode + "&sick_name=" + sickConfig.ClassName
  27736. // resp2, requestErr2 := http.Get(api2)
  27737. // if requestErr2 != nil {
  27738. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27739. // return
  27740. // }
  27741. // body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  27742. // if ioErr2 != nil {
  27743. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  27744. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27745. // return
  27746. // }
  27747. // var respJSON2 map[string]interface{}
  27748. // if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  27749. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27750. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27751. // return
  27752. // }
  27753. // respJSON2 = respJSON2["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27754. // userJSONBytes2, _ := json.Marshal(respJSON2)
  27755. //
  27756. // var res2 ResultSix
  27757. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  27758. // utils.ErrorLog("解析失败:%v", err)
  27759. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27760. // return
  27761. // }
  27762. // if res2.Infcode != 0 {
  27763. // adminUser := c.GetAdminUserInfo()
  27764. // errlog := &models.HisOrderError{
  27765. // UserOrgId: adminUser.CurrentOrgId,
  27766. // Ctime: time.Now().Unix(),
  27767. // Mtime: time.Now().Unix(),
  27768. // ErrMsg: res2.ErrMsg,
  27769. // Status: 1,
  27770. // PatientId: id,
  27771. // RecordTime: recordDateTime,
  27772. // Stage: 3,
  27773. // }
  27774. // service.CreateErrMsgLog(errlog)
  27775. //
  27776. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterThreeException)
  27777. // return
  27778. // }
  27779. //
  27780. // c.ServeSuccessJSON(map[string]interface{}{
  27781. // "msg": "上传成功",
  27782. // })
  27783. //
  27784. //}
  27785. type QueryResult struct {
  27786. ID int64
  27787. Name string
  27788. Code string
  27789. List_type_code string
  27790. }
  27791. func (c *HisApiController) GetCheckCode() {
  27792. ids_str := c.GetString("ids")
  27793. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  27794. ids_arr := strings.Split(ids_str, ",")
  27795. var queryResult []QueryResult
  27796. ids := make([]int64, 0)
  27797. for _, item := range ids_arr {
  27798. id, _ := strconv.ParseInt(item, 10, 64)
  27799. ids = append(ids, id)
  27800. }
  27801. if record_type == 1 {
  27802. drugs, _ := service.GetBatchDrugList(ids)
  27803. for _, item := range drugs {
  27804. result := QueryResult{
  27805. ID: item.ID,
  27806. Name: item.DrugName,
  27807. Code: item.MedicalInsuranceNumber,
  27808. List_type_code: "101",
  27809. }
  27810. queryResult = append(queryResult, result)
  27811. }
  27812. } else if record_type == 2 {
  27813. goods, _ := service.GetBatchGoodInformationList(ids)
  27814. fmt.Println(goods)
  27815. for _, item := range goods {
  27816. result := QueryResult{
  27817. ID: item.ID,
  27818. Name: item.GoodName,
  27819. Code: item.SocialSecurityDirectoryCode,
  27820. List_type_code: "301",
  27821. }
  27822. queryResult = append(queryResult, result)
  27823. }
  27824. } else if record_type == 3 {
  27825. projects, _ := service.GetBathchMyPorjecgList(ids)
  27826. for _, item := range projects {
  27827. result := QueryResult{
  27828. ID: item.ID,
  27829. Name: item.ProjectName,
  27830. Code: item.MedicalCode,
  27831. List_type_code: "201",
  27832. }
  27833. queryResult = append(queryResult, result)
  27834. }
  27835. }
  27836. admin_user_id, _ := c.GetInt64("admin_user_id")
  27837. adminUser := c.GetAdminUserInfo()
  27838. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  27839. //config, _ := /**/service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  27840. var user_name string
  27841. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  27842. if role.ID == 0 {
  27843. user_name = "管理员"
  27844. } else {
  27845. user_name = role.UserName
  27846. }
  27847. baseParams := models.BaseParams{
  27848. SecretKey: miConfig.SecretKey,
  27849. FixmedinsCode: miConfig.Code,
  27850. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  27851. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  27852. OrgName: miConfig.OrgName,
  27853. Doctor: user_name,
  27854. }
  27855. var result string
  27856. if miConfig.MdtrtareaAdmvs == "430800" {
  27857. for _, item := range queryResult {
  27858. if record_type == 1 {
  27859. 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)
  27860. } else if record_type == 2 {
  27861. fmt.Println(item.Code)
  27862. 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)
  27863. } else if record_type == 3 {
  27864. 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)
  27865. }
  27866. var dat map[string]interface{}
  27867. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  27868. fmt.Println(dat)
  27869. } else {
  27870. fmt.Println(err)
  27871. }
  27872. userJSONBytes, _ := json.Marshal(dat)
  27873. var res ResultSix
  27874. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27875. utils.ErrorLog("解析失败:%v", err)
  27876. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27877. return
  27878. }
  27879. if res.Infcode == 0 {
  27880. if record_type == 1 {
  27881. service.UpdateBaseDrugById(item.ID)
  27882. } else if record_type == 2 {
  27883. service.UpdateGoodInformaitonByDetail(item.ID)
  27884. } else if record_type == 3 {
  27885. service.UpdateProjectById(item.ID)
  27886. }
  27887. c.ServeSuccessJSON(map[string]interface{}{
  27888. "failed_code": 0,
  27889. "msg": "目录对照成功",
  27890. })
  27891. } else {
  27892. c.ServeSuccessJSON(map[string]interface{}{
  27893. "failed_code": -10,
  27894. "msg": res.ErrMsg,
  27895. })
  27896. }
  27897. }
  27898. } else {
  27899. for _, item := range queryResult {
  27900. var result string
  27901. if record_type == 1 {
  27902. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2023-04-26", "", item.List_type_code, admin_user_id)
  27903. } else if record_type == 2 {
  27904. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2023-04-26", "", item.List_type_code, admin_user_id)
  27905. } else if record_type == 3 {
  27906. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2023-04-26", "", item.List_type_code, admin_user_id)
  27907. }
  27908. var dat map[string]interface{}
  27909. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  27910. fmt.Println(dat)
  27911. } else {
  27912. fmt.Println(err)
  27913. }
  27914. userJSONBytes, _ := json.Marshal(dat)
  27915. var res ResultSix
  27916. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27917. utils.ErrorLog("解析失败:%v", err)
  27918. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27919. return
  27920. }
  27921. if res.Infcode == 0 {
  27922. if record_type == 1 {
  27923. service.UpdateBaseDrugById(item.ID)
  27924. } else if record_type == 2 {
  27925. service.UpdateGoodInformaitonByDetail(item.ID)
  27926. } else if record_type == 3 {
  27927. service.UpdateProjectById(item.ID)
  27928. }
  27929. c.ServeSuccessJSON(map[string]interface{}{
  27930. "failed_code": 0,
  27931. "msg": "目录对照成功",
  27932. })
  27933. } else {
  27934. c.ServeSuccessJSON(map[string]interface{}{
  27935. "failed_code": -10,
  27936. "msg": res.ErrMsg,
  27937. })
  27938. }
  27939. }
  27940. }
  27941. }
  27942. func (c *HisApiController) UnCheckCode() {
  27943. ids_str := c.GetString("ids")
  27944. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  27945. admin_user_id, _ := c.GetInt64("admin_user_id")
  27946. ids_arr := strings.Split(ids_str, ",")
  27947. var queryResult []QueryResult
  27948. ids := make([]int64, 0)
  27949. for _, item := range ids_arr {
  27950. id, _ := strconv.ParseInt(item, 10, 64)
  27951. ids = append(ids, id)
  27952. }
  27953. if record_type == 1 {
  27954. drugs, _ := service.GetBatchDrugList(ids)
  27955. for _, item := range drugs {
  27956. result := QueryResult{
  27957. ID: item.ID,
  27958. Name: item.DrugName,
  27959. Code: item.MedicalInsuranceNumber,
  27960. List_type_code: "101",
  27961. }
  27962. queryResult = append(queryResult, result)
  27963. }
  27964. } else if record_type == 2 {
  27965. goods, _ := service.GetBatchGoodInformationList(ids)
  27966. for _, item := range goods {
  27967. result := QueryResult{
  27968. ID: item.ID,
  27969. Name: item.GoodName,
  27970. Code: item.SocialSecurityDirectoryCode,
  27971. List_type_code: "301",
  27972. }
  27973. queryResult = append(queryResult, result)
  27974. }
  27975. } else if record_type == 3 {
  27976. projects, _ := service.GetBathchMyPorjecgList(ids)
  27977. for _, item := range projects {
  27978. result := QueryResult{
  27979. ID: item.ID,
  27980. Name: item.ProjectName,
  27981. Code: item.MedicalCode,
  27982. List_type_code: "201",
  27983. }
  27984. queryResult = append(queryResult, result)
  27985. }
  27986. }
  27987. adminUser := c.GetAdminUserInfo()
  27988. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  27989. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  27990. var user_name string
  27991. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  27992. if role.ID == 0 {
  27993. user_name = "xxx"
  27994. } else {
  27995. user_name = role.UserName
  27996. }
  27997. baseParams := &models.BaseParams{
  27998. SecretKey: miConfig.SecretKey,
  27999. FixmedinsCode: miConfig.Code,
  28000. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  28001. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  28002. OrgName: miConfig.OrgName,
  28003. Doctor: user_name,
  28004. }
  28005. if config.IsOpen == 1 {
  28006. if miConfig.MdtrtareaAdmvs == "430800" {
  28007. for _, item := range queryResult {
  28008. var result string
  28009. if record_type == 1 {
  28010. 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)
  28011. } else if record_type == 2 {
  28012. fmt.Println(item.Code)
  28013. 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)
  28014. } else if record_type == 3 {
  28015. 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)
  28016. }
  28017. var dat map[string]interface{}
  28018. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  28019. fmt.Println(dat)
  28020. } else {
  28021. fmt.Println(err)
  28022. }
  28023. userJSONBytes, _ := json.Marshal(dat)
  28024. var res ResultSix
  28025. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28026. utils.ErrorLog("解析失败:%v", err)
  28027. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28028. return
  28029. }
  28030. if res.Infcode == 0 {
  28031. if record_type == 1 {
  28032. service.UpdateBaseDrugById(item.ID)
  28033. } else if record_type == 2 {
  28034. service.UpdateGoodInformaitonByDetail(item.ID)
  28035. } else if record_type == 3 {
  28036. service.UpdateProjectById(item.ID)
  28037. }
  28038. c.ServeSuccessJSON(map[string]interface{}{
  28039. "failed_code": 0,
  28040. "msg": "目录对照成功",
  28041. })
  28042. } else {
  28043. c.ServeSuccessJSON(map[string]interface{}{
  28044. "failed_code": -10,
  28045. "msg": res.ErrMsg,
  28046. })
  28047. }
  28048. }
  28049. } else {
  28050. for _, item := range queryResult {
  28051. var result string
  28052. if record_type == 1 {
  28053. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  28054. } else if record_type == 2 {
  28055. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  28056. } else if record_type == 3 {
  28057. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  28058. }
  28059. var dat2 map[string]interface{}
  28060. if err := json.Unmarshal([]byte(result), &dat2); err == nil {
  28061. fmt.Println(dat2)
  28062. } else {
  28063. fmt.Println(err)
  28064. }
  28065. userJSONBytes, _ := json.Marshal(dat2)
  28066. var res ResultSix
  28067. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28068. utils.ErrorLog("解析失败:%v", err)
  28069. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28070. return
  28071. }
  28072. if res.Infcode == 0 {
  28073. if record_type == 1 {
  28074. service.UpdateDrugByIdDetail(item.ID)
  28075. } else if record_type == 2 {
  28076. service.UpdateGoodInfoById(item.ID)
  28077. } else if record_type == 3 {
  28078. service.UpdateMyProjectById(item.ID)
  28079. }
  28080. c.ServeSuccessJSON(map[string]interface{}{
  28081. "failed_code": 0,
  28082. "msg": "撤销目录对照成功",
  28083. })
  28084. } else {
  28085. c.ServeSuccessJSON(map[string]interface{}{
  28086. "failed_code": -10,
  28087. "msg": res.ErrMsg,
  28088. })
  28089. }
  28090. }
  28091. }
  28092. }
  28093. }
  28094. func (c *HisApiController) GetPatientInfo() {
  28095. id_card_no := c.GetString("id_card_no")
  28096. admin_user_id, _ := c.GetInt64("admin_user_id")
  28097. patient, _ := service.GetPatientByIDCard(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  28098. if patient.ID == 0 {
  28099. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  28100. return
  28101. }
  28102. role, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  28103. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  28104. config, _ := service.GetMedicalInsuranceConfig(c.GetAdminUserInfo().CurrentOrgId)
  28105. var res ResultTwo
  28106. var res10265 ResultTwo10265
  28107. if config.IsOpen == 1 {
  28108. if miConfig.MdtrtareaAdmvs == "150499" {
  28109. //请求内网数据
  28110. api := "http://172.16.13.254:9532/" + "nmyb/1101?cert_no=" + patient.IdCardNo +
  28111. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  28112. "&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
  28113. resp, requestErr := http.Get(api)
  28114. if requestErr != nil {
  28115. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28116. return
  28117. }
  28118. body, ioErr := ioutil.ReadAll(resp.Body)
  28119. if ioErr != nil {
  28120. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28121. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28122. return
  28123. }
  28124. var respJSON map[string]interface{}
  28125. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  28126. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28127. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28128. return
  28129. }
  28130. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28131. result_byte, _ := json.Marshal(respJSON)
  28132. result := string(result_byte)
  28133. var dat map[string]interface{}
  28134. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  28135. fmt.Println(dat)
  28136. } else {
  28137. fmt.Println(err)
  28138. }
  28139. userJSONBytes, _ := json.Marshal(dat)
  28140. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  28141. utils.ErrorLog("解析失败:%v", err)
  28142. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28143. return
  28144. }
  28145. Infcode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  28146. res.Infcode = Infcode
  28147. res.ErrMsg = res10265.ErrMsg
  28148. res.Output = res10265.Output
  28149. res.InfRefmsgid = res10265.InfRefmsgid
  28150. res.RespondTime = res10265.RespondTime
  28151. res.WarnInfo = res10265.WarnInfo
  28152. } else {
  28153. result := service.Gdyb1101A(id_card_no, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  28154. var dat map[string]interface{}
  28155. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  28156. fmt.Println(dat)
  28157. } else {
  28158. fmt.Println(err)
  28159. }
  28160. userJSONBytes, _ := json.Marshal(dat)
  28161. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28162. utils.ErrorLog("解析失败:%v", err)
  28163. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28164. return
  28165. }
  28166. }
  28167. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28168. // utils.ErrorLog("解析失败:%v", err)
  28169. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28170. // return
  28171. //}
  28172. for index, item := range res.Output.Iinfo {
  28173. if item.PsnInsuStas == "2" {
  28174. fmt.Println("--------")
  28175. res.Output.Iinfo[index].Insutype = "300"
  28176. res.Output.Iinfo[index].PsnInsuStas = "1"
  28177. }
  28178. }
  28179. fmt.Println(res.Output.Iinfo)
  28180. if res.Infcode != 0 {
  28181. c.ServeSuccessJSON(map[string]interface{}{
  28182. "failed_code": -10,
  28183. "msg": res.ErrMsg,
  28184. })
  28185. } else {
  28186. c.ServeSuccessJSON(map[string]interface{}{
  28187. "failed_code": 0,
  28188. "info": res,
  28189. })
  28190. }
  28191. }
  28192. }
  28193. func (c *HisApiController) PsnPutOnRecord() {
  28194. record_type, _ := c.GetInt64("type")
  28195. patient_id, _ := c.GetInt64("patient_id")
  28196. admin_user_id, _ := c.GetInt64("admin_user_id")
  28197. start_time := c.GetString("start_time")
  28198. end_time := c.GetString("end_time")
  28199. adminUser := c.GetAdminUserInfo()
  28200. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  28201. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  28202. var patients []*models.Patients
  28203. if record_type == 1 { //全部备案
  28204. patient, _ := service.GetAllPatient(adminUser.CurrentOrgId)
  28205. patients = append(patients, patient...)
  28206. } else { //单个备案
  28207. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  28208. patients = append(patients, patient)
  28209. }
  28210. var user_name string
  28211. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  28212. if role.ID == 0 {
  28213. user_name = "xxx"
  28214. } else {
  28215. user_name = role.UserName
  28216. }
  28217. if config.IsOpen == 1 {
  28218. for _, item := range patients {
  28219. 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
  28220. resp, requestErr := http.Get(api)
  28221. if requestErr != nil {
  28222. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28223. return
  28224. }
  28225. defer resp.Body.Close()
  28226. body, ioErr := ioutil.ReadAll(resp.Body)
  28227. if ioErr != nil {
  28228. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28229. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28230. return
  28231. }
  28232. var respJSON map[string]interface{}
  28233. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  28234. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28235. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28236. return
  28237. }
  28238. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28239. userJSONBytes, _ := json.Marshal(userJSON)
  28240. var res ResultTwo
  28241. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28242. utils.ErrorLog("解析失败:%v", err)
  28243. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28244. return
  28245. }
  28246. if res.Infcode == 0 {
  28247. 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)
  28248. var dat map[string]interface{}
  28249. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  28250. fmt.Println(dat)
  28251. } else {
  28252. fmt.Println(err)
  28253. }
  28254. userJSONBytes, _ := json.Marshal(dat)
  28255. var res2 ResultThirteen
  28256. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  28257. utils.ErrorLog("解析失败:%v", err)
  28258. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28259. return
  28260. }
  28261. if res2.Infcode == 0 {
  28262. psnResult := &models.GdybPsnRecord{
  28263. UserOrgId: adminUser.CurrentOrgId,
  28264. PatientId: item.ID,
  28265. PsnNo: res.Output.Baseinfo.PsnNo,
  28266. Ctime: time.Now().Unix(),
  28267. Mtime: time.Now().Unix(),
  28268. Status: 1,
  28269. IsCancel: 1,
  28270. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  28271. }
  28272. service.CreatePsnRecord(psnResult)
  28273. } else {
  28274. c.ServeSuccessJSON(map[string]interface{}{
  28275. "failed_code": -10,
  28276. "msg": res2.ErrMsg,
  28277. })
  28278. return
  28279. }
  28280. }
  28281. }
  28282. }
  28283. }
  28284. func (c *HisApiController) PsnUnPutOnRecord() {
  28285. id, _ := c.GetInt64("id")
  28286. //record_type, _ := c.GetInt64("type")
  28287. admin_user_id, _ := c.GetInt64("admin_user_id")
  28288. adminUser := c.GetAdminUserInfo()
  28289. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  28290. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  28291. var user_name string
  28292. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  28293. if role.ID == 0 {
  28294. user_name = "xxx"
  28295. } else {
  28296. user_name = role.UserName
  28297. }
  28298. psn_record, _ := service.GetPsnRecordById(id)
  28299. if psn_record.ID == 0 {
  28300. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  28301. return
  28302. }
  28303. if config.IsOpen == 1 {
  28304. result := service.Gdyb2506(psn_record.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  28305. var dat map[string]interface{}
  28306. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  28307. fmt.Println(dat)
  28308. } else {
  28309. fmt.Println(err)
  28310. }
  28311. userJSONBytes, _ := json.Marshal(dat)
  28312. var res ResultFourteen
  28313. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28314. utils.ErrorLog("解析失败:%v", err)
  28315. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28316. return
  28317. }
  28318. if res.Infcode == 0 {
  28319. psn_record.IsCancel = 2
  28320. service.CreatePsnRecord(&psn_record)
  28321. } else {
  28322. c.ServeSuccessJSON(map[string]interface{}{
  28323. "failed_code": -10,
  28324. "msg": res.ErrMsg,
  28325. })
  28326. return
  28327. }
  28328. }
  28329. }
  28330. func (c *HisApiController) PsnPutNCDSOnRecord() {
  28331. patient_id, _ := c.GetInt64("patient_id")
  28332. insutype_two := c.GetString("insutype")
  28333. psn_no := c.GetString("psn_no")
  28334. doctor_id, _ := c.GetInt64("doctor_id")
  28335. sick_id, _ := c.GetInt64("sick_id")
  28336. department_id, _ := c.GetInt64("department_id")
  28337. start_time := c.GetString("start_time")
  28338. end_time := c.GetString("end_time")
  28339. check_time := c.GetString("check_time")
  28340. hospital_code := c.GetString("hospital_code")
  28341. hospital_name := c.GetString("hospital_name")
  28342. adminUser := c.GetAdminUserInfo()
  28343. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  28344. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  28345. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  28346. sick, _ := service.FindSickById(sick_id)
  28347. doctor, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  28348. if len(hospital_code) == 0 {
  28349. hospital_code = miConfig.Code
  28350. }
  28351. if len(hospital_name) == 0 {
  28352. hospital_name = miConfig.OrgName
  28353. }
  28354. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  28355. var res ResultTwo
  28356. var res10265 ResultTwo10265
  28357. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  28358. psn_info, _ := service.GetPsnByPatientId(patient.ID)
  28359. api := "http://192.168.2.3:9532/" + "hbyb/1101?cert_no=" + "" +
  28360. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  28361. "&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
  28362. resp, requestErr := http.Get(api)
  28363. if requestErr != nil {
  28364. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28365. return
  28366. }
  28367. body, ioErr := ioutil.ReadAll(resp.Body)
  28368. if ioErr != nil {
  28369. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28370. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28371. return
  28372. }
  28373. var respJSON map[string]interface{}
  28374. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  28375. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28376. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28377. return
  28378. }
  28379. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28380. result, _ := json.Marshal(respJSON)
  28381. fmt.Println("log")
  28382. fmt.Println(string(result))
  28383. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  28384. utils.ErrorLog("解析失败:%v", err)
  28385. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28386. return
  28387. }
  28388. res.ErrMsg = res10265.ErrMsg
  28389. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  28390. res.Infcode = infocode
  28391. res.Output = res10265.Output
  28392. res.InfRefmsgid = res10265.InfRefmsgid
  28393. } else {
  28394. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  28395. if miConfig.Code == "H15049901371" {
  28396. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  28397. utils.ErrorLog("解析失败:%v", err)
  28398. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28399. return
  28400. }
  28401. res.ErrMsg = res10265.ErrMsg
  28402. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  28403. res.Infcode = infocode
  28404. res.Output = res10265.Output
  28405. res.InfRefmsgid = res10265.InfRefmsgid
  28406. } else {
  28407. if err := json.Unmarshal([]byte(result), &res); err != nil {
  28408. utils.ErrorLog("解析失败:%v", err)
  28409. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28410. return
  28411. }
  28412. }
  28413. }
  28414. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  28415. infoStr := string(Iinfos)
  28416. var rf []*ResultFive
  28417. json.Unmarshal([]byte(infoStr), &rf)
  28418. var insuplc_admdvs string
  28419. var insutype string
  28420. var is390 int = 0
  28421. var is310 int = 0
  28422. var insutypes []*ResultFive
  28423. for _, item := range rf {
  28424. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  28425. insutypes = append(insutypes, item)
  28426. }
  28427. }
  28428. if len(insutypes) == 1 {
  28429. insutype = insutypes[0].Insutype
  28430. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  28431. } else {
  28432. for _, i := range insutypes {
  28433. if i.Insutype == "390" {
  28434. is390 = 1
  28435. }
  28436. if i.Insutype == "310" {
  28437. is310 = 1
  28438. }
  28439. }
  28440. }
  28441. if is390 == 1 {
  28442. insutype = "390"
  28443. }
  28444. if is310 == 1 {
  28445. insutype = "310"
  28446. }
  28447. if len(insutypes) == 2 {
  28448. insutype = insutype_two
  28449. }
  28450. if len(insutypes) == 0 {
  28451. insutype = "310"
  28452. }
  28453. insutype = insutype_two
  28454. fmt.Println(insutype)
  28455. for _, item := range rf {
  28456. fmt.Println(item.Insutype)
  28457. fmt.Println(insutype)
  28458. if item.Insutype == insutype {
  28459. fmt.Println(item.Insutype)
  28460. fmt.Println(insutype)
  28461. insuplc_admdvs = item.InsuplcAdmdvs
  28462. }
  28463. }
  28464. fmt.Println(insuplc_admdvs)
  28465. var res2 ResultThirteen
  28466. var res10265_2 ResultThirteen10265
  28467. if config.IsOpen == 1 {
  28468. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  28469. } else {
  28470. if miConfig.MdtrtareaAdmvs == "150499" {
  28471. //
  28472. //api := "http://172.16.13.254:9532/" + "nmyb/2503?psn_no=" + psn_no + "&insutype=" + insutype + "sick_name" + sick.ClassName + "&sick_code=" + sick.CountryCode +
  28473. // "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  28474. // "&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
  28475. //resp, requestErr := http.Get(api)
  28476. //if requestErr != nil {
  28477. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28478. // return
  28479. //}
  28480. //
  28481. //body, ioErr := ioutil.ReadAll(resp.Body)
  28482. //if ioErr != nil {
  28483. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28484. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28485. // return
  28486. //}
  28487. //var respJSON map[string]interface{}
  28488. //if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  28489. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28490. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28491. // return
  28492. //}
  28493. //
  28494. //respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28495. //result, _ := json.Marshal(respJSON)
  28496. //if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  28497. // utils.ErrorLog("解析失败:%v", err)
  28498. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28499. // return
  28500. //}
  28501. //infocode = resThree.Infcode
  28502. //result, _ := json.Marshal(respJSON)
  28503. //if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  28504. // utils.ErrorLog("解析失败:%v", err)
  28505. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28506. // return
  28507. //}
  28508. //
  28509. //resThree.ErrMsg = resThree10265.ErrMsg
  28510. //
  28511. //resThree.Output = resThree10265.Output
  28512. //
  28513. //resThree.InfRefmsgid = resThree10265.InfRefmsgid
  28514. //
  28515. //infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  28516. //
  28517. } else {
  28518. 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)
  28519. var dat map[string]interface{}
  28520. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  28521. fmt.Println(dat)
  28522. } else {
  28523. fmt.Println(err)
  28524. }
  28525. userJSONBytes, _ := json.Marshal(dat)
  28526. if miConfig.Code == "H15049901371" {
  28527. if err := json.Unmarshal(userJSONBytes, &res10265_2); err != nil {
  28528. utils.ErrorLog("解析失败:%v", err)
  28529. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28530. return
  28531. }
  28532. res2.ErrMsg = res10265_2.ErrMsg
  28533. infocode, _ := strconv.ParseInt(res10265_2.Infcode, 10, 64)
  28534. res2.Infcode = infocode
  28535. res2.Output = res10265_2.Output
  28536. res2.InfRefmsgid = res10265_2.InfRefmsgid
  28537. } else {
  28538. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  28539. utils.ErrorLog("解析失败:%v", err)
  28540. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28541. return
  28542. }
  28543. }
  28544. }
  28545. }
  28546. if res2.Infcode == 0 {
  28547. psnResult := &models.GdybPsnNcdsRecord{
  28548. UserOrgId: adminUser.CurrentOrgId,
  28549. PatientId: patient.ID,
  28550. PsnNo: psn_no,
  28551. DoctorId: doctor.AdminUserId,
  28552. DepartmentId: department_id,
  28553. SickType: sick_id,
  28554. Insutype: insutype,
  28555. Ctime: time.Now().Unix(),
  28556. Mtime: time.Now().Unix(),
  28557. Status: 1,
  28558. IsCancel: 1,
  28559. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  28560. }
  28561. service.CreatePsnNCDSRecord(psnResult)
  28562. c.ServeSuccessJSON(map[string]interface{}{
  28563. "failed_code": 0,
  28564. "msg": "备案成功",
  28565. "result": psnResult,
  28566. })
  28567. } else {
  28568. c.ServeSuccessJSON(map[string]interface{}{
  28569. "failed_code": -10,
  28570. "msg": res2.ErrMsg,
  28571. })
  28572. return
  28573. }
  28574. }
  28575. }
  28576. func (c *HisApiController) PsnPutUnNCDSOnRecord() {
  28577. id, _ := c.GetInt64("id")
  28578. admin_user_id, _ := c.GetInt64("admin_user_id")
  28579. adminUser := c.GetAdminUserInfo()
  28580. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  28581. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  28582. //config, _ := service.Ge(adminUser.CurrentOrgId)
  28583. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  28584. //role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  28585. //var user_name string
  28586. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  28587. //if role.ID == 0 {
  28588. // user_name = "xxx"
  28589. //} else {
  28590. // user_name = role.UserName
  28591. //}
  28592. psn_record, _ := service.GetPsnNCDSRecordById(id)
  28593. if psn_record.ID == 0 {
  28594. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  28595. return
  28596. }
  28597. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  28598. var res ResultTwo
  28599. var res10265 ResultTwo10265
  28600. if miConfig.Code == "H15049901371" {
  28601. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  28602. utils.ErrorLog("解析失败:%v", err)
  28603. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28604. return
  28605. }
  28606. res.ErrMsg = res10265.ErrMsg
  28607. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  28608. res.Infcode = infocode
  28609. res.Output = res10265.Output
  28610. res.InfRefmsgid = res10265.InfRefmsgid
  28611. } else {
  28612. if err := json.Unmarshal([]byte(result), &res); err != nil {
  28613. utils.ErrorLog("解析失败:%v", err)
  28614. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28615. return
  28616. }
  28617. }
  28618. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  28619. infoStr := string(Iinfos)
  28620. var rf []*ResultFive
  28621. json.Unmarshal([]byte(infoStr), &rf)
  28622. var insuplc_admdvs string
  28623. var insutype string
  28624. var is390 int = 0
  28625. var is310 int = 0
  28626. var insutypes []*ResultFive
  28627. for _, item := range rf {
  28628. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  28629. insutypes = append(insutypes, item)
  28630. }
  28631. }
  28632. if len(insutypes) == 1 {
  28633. insutype = insutypes[0].Insutype
  28634. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  28635. } else {
  28636. for _, i := range insutypes {
  28637. if i.Insutype == "390" {
  28638. is390 = 1
  28639. }
  28640. if i.Insutype == "310" {
  28641. is310 = 1
  28642. }
  28643. }
  28644. }
  28645. if is390 == 1 {
  28646. insutype = "390"
  28647. }
  28648. if is310 == 1 {
  28649. insutype = "310"
  28650. }
  28651. if len(insutypes) == 0 {
  28652. insutype = "310"
  28653. }
  28654. insutype = psn_record.Insutype
  28655. for _, item := range rf {
  28656. if item.Insutype == insutype {
  28657. insuplc_admdvs = item.InsuplcAdmdvs
  28658. }
  28659. }
  28660. if config.IsOpen == 1 {
  28661. result := service.Gdyb2504(psn_record.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, insuplc_admdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  28662. var dat map[string]interface{}
  28663. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  28664. fmt.Println(dat)
  28665. } else {
  28666. fmt.Println(err)
  28667. }
  28668. userJSONBytes, _ := json.Marshal(dat)
  28669. var res ResultFourteen
  28670. var res10265 ResultFourteen10265
  28671. if miConfig.Code == "H15049901371" {
  28672. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  28673. utils.ErrorLog("解析失败:%v", err)
  28674. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28675. return
  28676. }
  28677. res.ErrMsg = res10265.ErrMsg
  28678. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  28679. res.Infcode = infocode
  28680. res.Output = res10265.Output
  28681. res.InfRefmsgid = res10265.InfRefmsgid
  28682. } else {
  28683. if err := json.Unmarshal([]byte(result), &res); err != nil {
  28684. utils.ErrorLog("解析失败:%v", err)
  28685. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28686. return
  28687. }
  28688. }
  28689. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28690. // utils.ErrorLog("解析失败:%v", err)
  28691. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28692. // return
  28693. //}
  28694. if res.Infcode == 0 {
  28695. psn_record.IsCancel = 2
  28696. service.CreatePsnNCDSRecord(&psn_record)
  28697. c.ServeSuccessJSON(map[string]interface{}{
  28698. "failed_code": 0,
  28699. "msg": "撤销备案成功",
  28700. })
  28701. } else {
  28702. c.ServeSuccessJSON(map[string]interface{}{
  28703. "failed_code": -10,
  28704. "msg": res.ErrMsg,
  28705. })
  28706. return
  28707. }
  28708. }
  28709. }
  28710. func (c *HisApiController) TestTest() {
  28711. patient, _ := service.GetHisPatientInfo(4, 456, 1619712000)
  28712. fmt.Println(patient.Iinfo)
  28713. }
  28714. type CustomData struct {
  28715. MsgId string
  28716. PsnNo string
  28717. Info string
  28718. }
  28719. func (c *HisApiController) ReversalData() {
  28720. var customData []*CustomData
  28721. custom := &CustomData{
  28722. MsgId: "H44022900158202103301714472004",
  28723. PsnNo: "44020000001101329945",
  28724. Info: "2207",
  28725. }
  28726. customData = append(customData, custom)
  28727. custom1 := &CustomData{
  28728. MsgId: "H4402290015820210330172057803",
  28729. PsnNo: "44020000001101161813",
  28730. Info: "2207",
  28731. }
  28732. customData = append(customData, custom1)
  28733. custom2 := &CustomData{
  28734. MsgId: "H44022900158202103301705198813",
  28735. PsnNo: "44190000133097375417",
  28736. Info: "2207",
  28737. }
  28738. customData = append(customData, custom2)
  28739. custom3 := &CustomData{
  28740. MsgId: "H44022900158202103301715524756",
  28741. PsnNo: "44020000001100187221",
  28742. Info: "2207",
  28743. }
  28744. customData = append(customData, custom3)
  28745. custom4 := &CustomData{
  28746. MsgId: "H44022900158202103301730376224",
  28747. PsnNo: "44020000001101959155",
  28748. Info: "2207",
  28749. }
  28750. customData = append(customData, custom4)
  28751. custom5 := &CustomData{
  28752. MsgId: "H44022900158202103301748008725",
  28753. PsnNo: "44020000001104246641",
  28754. Info: "2207",
  28755. }
  28756. customData = append(customData, custom5)
  28757. custom6 := &CustomData{
  28758. MsgId: "H44022900158202103301718096755",
  28759. PsnNo: "44020000001102211860",
  28760. Info: "2207",
  28761. }
  28762. customData = append(customData, custom6)
  28763. custom7 := &CustomData{
  28764. MsgId: "H44022900158202103301736551640",
  28765. PsnNo: "44020000001102687718",
  28766. Info: "2207",
  28767. }
  28768. customData = append(customData, custom7)
  28769. custom8 := &CustomData{
  28770. MsgId: "H44022900158202103301743097676",
  28771. PsnNo: "44020000001102127785",
  28772. Info: "2207",
  28773. }
  28774. customData = append(customData, custom8)
  28775. custom9 := &CustomData{
  28776. MsgId: "H44022900158202103301712304203",
  28777. PsnNo: "44020000001101518097",
  28778. Info: "2207",
  28779. }
  28780. customData = append(customData, custom9)
  28781. custom10 := &CustomData{
  28782. MsgId: "H44022900158202103301738448785",
  28783. PsnNo: "44020000001100500813",
  28784. Info: "2207",
  28785. }
  28786. customData = append(customData, custom10)
  28787. custom11 := &CustomData{
  28788. MsgId: "H44022900158202103301732455843",
  28789. PsnNo: "44020000001102690557",
  28790. Info: "2207",
  28791. }
  28792. customData = append(customData, custom11)
  28793. custom12 := &CustomData{
  28794. MsgId: "H44022900158202103301745421708",
  28795. PsnNo: "44020000001102211928",
  28796. Info: "2207",
  28797. }
  28798. customData = append(customData, custom12)
  28799. custom1212 := &CustomData{
  28800. MsgId: "H440229001582021033017351627",
  28801. PsnNo: "44020000001102481733",
  28802. Info: "2207",
  28803. }
  28804. customData = append(customData, custom1212)
  28805. custom13 := &CustomData{
  28806. MsgId: "H44022900158202103301740327951",
  28807. PsnNo: "44020000001103174866",
  28808. Info: "2207",
  28809. }
  28810. customData = append(customData, custom13)
  28811. custom14 := &CustomData{
  28812. MsgId: "H4402290015820210330174922668",
  28813. PsnNo: "44020000001102927272",
  28814. Info: "2207",
  28815. }
  28816. customData = append(customData, custom14)
  28817. custom15 := &CustomData{
  28818. MsgId: "H44022900158202103301752362273",
  28819. PsnNo: "44020000001102942890",
  28820. Info: "2207",
  28821. }
  28822. customData = append(customData, custom15)
  28823. custom16 := &CustomData{
  28824. MsgId: "H44022900158202103301751082917",
  28825. PsnNo: "44020000001101662162",
  28826. Info: "2207",
  28827. }
  28828. customData = append(customData, custom16)
  28829. custom17 := &CustomData{
  28830. MsgId: "H44022900158202103301754147728",
  28831. PsnNo: "44020000000229014511",
  28832. Info: "2207",
  28833. }
  28834. customData = append(customData, custom17)
  28835. adminUser := c.GetAdminUserInfo()
  28836. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  28837. for _, item := range customData {
  28838. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  28839. fmt.Println(result)
  28840. }
  28841. }
  28842. func (c *HisApiController) GetAllopatry() {
  28843. year := c.GetString("year")
  28844. month := c.GetString("month")
  28845. admin_user_id, _ := c.GetInt64("admin_user_id")
  28846. adminUser := c.GetAdminUserInfo()
  28847. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  28848. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  28849. result, _ := service.Gdyb9001Two(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  28850. var dat map[string]interface{}
  28851. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  28852. fmt.Println(dat)
  28853. } else {
  28854. fmt.Println(err)
  28855. }
  28856. userJSONBytes, _ := json.Marshal(dat)
  28857. var res models.Result9001
  28858. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28859. utils.ErrorLog("解析失败:%v", err)
  28860. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28861. return
  28862. }
  28863. fmt.Println(res.Output.Signinoutb)
  28864. fmt.Println(res.Output.Signinoutb.SignNo)
  28865. fmt.Println(string(userJSONBytes))
  28866. result3, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo, 0)
  28867. var dat3 map[string]interface{}
  28868. if err := json.Unmarshal([]byte(result3), &dat3); err == nil {
  28869. fmt.Println(dat3)
  28870. } else {
  28871. fmt.Println(err)
  28872. }
  28873. userJSONBytes3, _ := json.Marshal(dat3)
  28874. var res3 models.Result3260
  28875. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  28876. utils.ErrorLog("解析失败:%v", err)
  28877. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28878. return
  28879. }
  28880. var curpage int
  28881. var pagesize int = 100
  28882. var start int = 1
  28883. //var stop int
  28884. //pagecount := 10
  28885. pagecount := int(math.Ceil(float64(res3.Output.Totalrow) / float64(pagesize)))
  28886. var res22 []models.Result3260
  28887. for curpage = 1; curpage <= pagecount; curpage++ {
  28888. if curpage == 1 {
  28889. start = 0
  28890. } else {
  28891. start = (curpage-1)*pagesize + 1
  28892. }
  28893. fmt.Println(start)
  28894. //stop = curpage * pagesize
  28895. //if stop > int(res3.Output.Totalrow) {
  28896. // stop =int(res3.Output.Totalrow)
  28897. //}
  28898. result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo, start)
  28899. var dat2 map[string]interface{}
  28900. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  28901. fmt.Println(dat)
  28902. } else {
  28903. fmt.Println(err)
  28904. }
  28905. userJSONBytes2, _ := json.Marshal(dat2)
  28906. var res2 models.Result3260
  28907. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  28908. utils.ErrorLog("解析失败:%v", err)
  28909. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28910. return
  28911. }
  28912. if res2.Infcode == 0 {
  28913. res22 = append(res22, res2)
  28914. //service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res2, res.Output.Signinoutb.SignNo)
  28915. //var dat2 map[string]interface{}
  28916. //if err := json.Unmarshal([]byte(result3), &dat2); err == nil {
  28917. // fmt.Println(dat)
  28918. //} else {
  28919. // fmt.Println(err)
  28920. //}
  28921. //c.ServeSuccessJSON(map[string]interface{}{
  28922. // "list": res2.Output.Data,
  28923. //})
  28924. //continue
  28925. }
  28926. }
  28927. service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res22, res.Output.Signinoutb.SignNo)
  28928. //service.Gdyb3263(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res22, res.Output.Signinoutb.SignNo)
  28929. //result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo, 101)
  28930. //var dat2 map[string]interface{}
  28931. //if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  28932. // fmt.Println(dat)
  28933. //} else {
  28934. // fmt.Println(err)
  28935. //}
  28936. //userJSONBytes2, _ := json.Marshal(dat2)
  28937. //var res2 models.Result3260
  28938. //if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  28939. // utils.ErrorLog("解析失败:%v", err)
  28940. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28941. // return
  28942. //}
  28943. //if res2.Infcode == 0 {
  28944. // service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res2, res.Output.Signinoutb.SignNo)
  28945. // var dat2 map[string]interface{}
  28946. // if err := json.Unmarshal([]byte(result3), &dat2); err == nil {
  28947. // fmt.Println(dat)
  28948. // } else {
  28949. // fmt.Println(err)
  28950. // }
  28951. // c.ServeSuccessJSON(map[string]interface{}{
  28952. // "list": res2.Output.Data,
  28953. // })
  28954. //}
  28955. }
  28956. func (c *HisApiController) ComfirmAllopatry() {
  28957. year := c.GetString("year")
  28958. month := c.GetString("month")
  28959. admin_user_id, _ := c.GetInt64("admin_user_id")
  28960. adminUser := c.GetAdminUserInfo()
  28961. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  28962. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  28963. result, _ := service.Gdyb9001Two(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  28964. var dat map[string]interface{}
  28965. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  28966. fmt.Println(dat)
  28967. } else {
  28968. fmt.Println(err)
  28969. }
  28970. userJSONBytes, _ := json.Marshal(dat)
  28971. var res models.Result9001
  28972. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28973. utils.ErrorLog("解析失败:%v", err)
  28974. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28975. return
  28976. }
  28977. result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo, 0)
  28978. var dat2 map[string]interface{}
  28979. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  28980. fmt.Println(dat)
  28981. } else {
  28982. fmt.Println(err)
  28983. }
  28984. userJSONBytes2, _ := json.Marshal(dat2)
  28985. var res2 models.Result3260
  28986. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  28987. utils.ErrorLog("解析失败:%v", err)
  28988. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28989. return
  28990. }
  28991. //if res2.Infcode == 0 {
  28992. // result, _, msgId := service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res2, res.Output.Signinoutb.SignNo)
  28993. // var dat map[string]interface{}
  28994. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  28995. // fmt.Println(dat)
  28996. // } else {
  28997. // fmt.Println(err)
  28998. // }
  28999. // userJSONBytes, _ := json.Marshal(dat)
  29000. // var res3 models.Result3261
  29001. // if err := json.Unmarshal(userJSONBytes, &res3); err != nil {
  29002. // utils.ErrorLog("解析失败:%v", err)
  29003. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29004. // return
  29005. // }
  29006. //
  29007. // if res3.Infcode == 0 {
  29008. // record := &models.HisYidiClearRecord{
  29009. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  29010. // Ctime: time.Now().Unix(),
  29011. // Mtime: time.Now().Unix(),
  29012. // Status: 1,
  29013. // MsgId: msgId,
  29014. // }
  29015. // service.SaveClearRecord(record)
  29016. // c.ServeSuccessJSON(map[string]interface{}{
  29017. // "msg": "提取成功",
  29018. // })
  29019. // }
  29020. //}
  29021. }
  29022. func (c *HisApiController) RefundAllopatry() {
  29023. year := c.GetString("year")
  29024. month := c.GetString("month")
  29025. //id, _ := c.GetInt64("id")
  29026. admin_user_id, _ := c.GetInt64("admin_user_id")
  29027. adminUser := c.GetAdminUserInfo()
  29028. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  29029. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  29030. //record, _ := service.GetClearRecordById(id)
  29031. result2, _ := service.Gdyb9001Two(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  29032. var dat map[string]interface{}
  29033. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  29034. fmt.Println(dat)
  29035. } else {
  29036. fmt.Println(err)
  29037. }
  29038. userJSONBytes, _ := json.Marshal(dat)
  29039. var res models.Result9001
  29040. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29041. utils.ErrorLog("解析失败:%v", err)
  29042. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29043. return
  29044. }
  29045. result, _ := service.Gdyb3262(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, "", res.Output.Signinoutb.SignNo)
  29046. var dat2 map[string]interface{}
  29047. if err := json.Unmarshal([]byte(result), &dat2); err == nil {
  29048. fmt.Println(dat)
  29049. } else {
  29050. fmt.Println(err)
  29051. }
  29052. userJSONBytes2, _ := json.Marshal(dat2)
  29053. var empty ResultFourteen
  29054. if err := json.Unmarshal(userJSONBytes2, &empty); err != nil {
  29055. utils.ErrorLog("解析失败:%v", err)
  29056. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29057. return
  29058. }
  29059. if empty.Infcode == 0 {
  29060. c.ServeSuccessJSON(map[string]interface{}{
  29061. "msg": "撤销成功",
  29062. })
  29063. return
  29064. }
  29065. }
  29066. func (c *HisApiController) ReversalOtherData() {
  29067. var customData []*CustomData
  29068. custom := &CustomData{
  29069. MsgId: "H44022900158202103301714472004",
  29070. PsnNo: "44020000001101329945",
  29071. Info: "2208",
  29072. }
  29073. customData = append(customData, custom)
  29074. custom1 := &CustomData{
  29075. MsgId: "H4402290015820210330172057803",
  29076. PsnNo: "44020000001101161813",
  29077. Info: "2208",
  29078. }
  29079. customData = append(customData, custom1)
  29080. custom2 := &CustomData{
  29081. MsgId: "H44022900158202103301705198813",
  29082. PsnNo: "44190000133097375417",
  29083. Info: "2208",
  29084. }
  29085. customData = append(customData, custom2)
  29086. custom3 := &CustomData{
  29087. MsgId: "H44022900158202103301715524756",
  29088. PsnNo: "44020000001100187221",
  29089. Info: "2208",
  29090. }
  29091. customData = append(customData, custom3)
  29092. custom4 := &CustomData{
  29093. MsgId: "H44022900158202103301730376224",
  29094. PsnNo: "44020000001101959155",
  29095. Info: "2208",
  29096. }
  29097. customData = append(customData, custom4)
  29098. custom5 := &CustomData{
  29099. MsgId: "H44022900158202103301748008725",
  29100. PsnNo: "44020000001104246641",
  29101. Info: "2208",
  29102. }
  29103. customData = append(customData, custom5)
  29104. custom6 := &CustomData{
  29105. MsgId: "H44022900158202103301718096755",
  29106. PsnNo: "44020000001102211860",
  29107. Info: "2208",
  29108. }
  29109. customData = append(customData, custom6)
  29110. custom7 := &CustomData{
  29111. MsgId: "H44022900158202103301736551640",
  29112. PsnNo: "44020000001102687718",
  29113. Info: "2208",
  29114. }
  29115. customData = append(customData, custom7)
  29116. custom8 := &CustomData{
  29117. MsgId: "H44022900158202103301743097676",
  29118. PsnNo: "44020000001102127785",
  29119. Info: "2208",
  29120. }
  29121. customData = append(customData, custom8)
  29122. custom9 := &CustomData{
  29123. MsgId: "H44022900158202103301712304203",
  29124. PsnNo: "44020000001101518097",
  29125. Info: "2208",
  29126. }
  29127. customData = append(customData, custom9)
  29128. custom10 := &CustomData{
  29129. MsgId: "H44022900158202103301738448785",
  29130. PsnNo: "44020000001100500813",
  29131. Info: "2208",
  29132. }
  29133. customData = append(customData, custom10)
  29134. custom11 := &CustomData{
  29135. MsgId: "H44022900158202103301732455843",
  29136. PsnNo: "44020000001102690557",
  29137. Info: "2208",
  29138. }
  29139. customData = append(customData, custom11)
  29140. custom12 := &CustomData{
  29141. MsgId: "H44022900158202103301745421708",
  29142. PsnNo: "44020000001102211928",
  29143. Info: "2208",
  29144. }
  29145. customData = append(customData, custom12)
  29146. custom1212 := &CustomData{
  29147. MsgId: "H440229001582021033017351627",
  29148. PsnNo: "44020000001102481733",
  29149. Info: "2208",
  29150. }
  29151. customData = append(customData, custom1212)
  29152. custom13 := &CustomData{
  29153. MsgId: "H44022900158202103301740327951",
  29154. PsnNo: "44020000001103174866",
  29155. Info: "2208",
  29156. }
  29157. customData = append(customData, custom13)
  29158. custom14 := &CustomData{
  29159. MsgId: "H4402290015820210330174922668",
  29160. PsnNo: "44020000001102927272",
  29161. Info: "2208",
  29162. }
  29163. customData = append(customData, custom14)
  29164. custom15 := &CustomData{
  29165. MsgId: "H44022900158202103301752362273",
  29166. PsnNo: "44020000001102942890",
  29167. Info: "2208",
  29168. }
  29169. customData = append(customData, custom15)
  29170. custom16 := &CustomData{
  29171. MsgId: "H44022900158202103301751082917",
  29172. PsnNo: "44020000001101662162",
  29173. Info: "2208",
  29174. }
  29175. customData = append(customData, custom16)
  29176. custom17 := &CustomData{
  29177. MsgId: "H44022900158202103301754147728",
  29178. PsnNo: "44020000000229014511",
  29179. Info: "2208",
  29180. }
  29181. customData = append(customData, custom17)
  29182. adminUser := c.GetAdminUserInfo()
  29183. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  29184. for _, item := range customData {
  29185. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  29186. fmt.Println(result)
  29187. }
  29188. }
  29189. func PathExists(path string) (bool, error) {
  29190. _, err := os.Stat(path)
  29191. if err == nil {
  29192. return true, nil
  29193. }
  29194. if os.IsNotExist(err) {
  29195. return false, nil
  29196. }
  29197. return false, err
  29198. }
  29199. // 创建文件夹
  29200. func Mkdir(dir string) {
  29201. // 创建文件夹
  29202. exist, err := PathExists(dir)
  29203. if err != nil {
  29204. fmt.Println(err.Error())
  29205. } else {
  29206. if exist {
  29207. fmt.Println(dir + "文件夹已存在!")
  29208. } else {
  29209. // 文件夹名称,权限
  29210. err := os.Mkdir(dir, os.ModePerm)
  29211. if err != nil {
  29212. fmt.Println(dir+"文件夹创建失败:", err.Error())
  29213. } else {
  29214. fmt.Println(dir + "文件夹创建成功!")
  29215. }
  29216. }
  29217. }
  29218. }
  29219. // 压缩文件
  29220. func Zip(srcFile string, destZip string) error {
  29221. zipfile, err := os.Create(destZip)
  29222. if err != nil {
  29223. return err
  29224. }
  29225. defer zipfile.Close()
  29226. archive := zip.NewWriter(zipfile)
  29227. defer archive.Close()
  29228. filepath.Walk(srcFile, func(path string, info os.FileInfo, err error) error {
  29229. if err != nil {
  29230. return err
  29231. }
  29232. header, err := zip.FileInfoHeader(info)
  29233. if err != nil {
  29234. return err
  29235. }
  29236. header.Name = strings.TrimPrefix(path, filepath.Dir(srcFile)+"/")
  29237. // header.Name = path
  29238. if info.IsDir() {
  29239. header.Name += "/"
  29240. } else {
  29241. header.Method = zip.Deflate
  29242. }
  29243. writer, err := archive.CreateHeader(header)
  29244. if err != nil {
  29245. return err
  29246. }
  29247. if !info.IsDir() {
  29248. file, err := os.Open(path)
  29249. if err != nil {
  29250. return err
  29251. }
  29252. defer file.Close()
  29253. _, err = io.Copy(writer, file)
  29254. }
  29255. return err
  29256. })
  29257. return err
  29258. }
  29259. func ReadFile(filePath string) []byte {
  29260. f, err := os.Open(filePath)
  29261. if err != nil {
  29262. fmt.Println("read file fail", err)
  29263. return nil
  29264. }
  29265. defer f.Close()
  29266. fd, err := ioutil.ReadAll(f)
  29267. if err != nil {
  29268. fmt.Println("read to fd fail", err)
  29269. return nil
  29270. }
  29271. return fd
  29272. }
  29273. func saveLogq(result string, request string, infno string, desc string) {
  29274. dir := "日志"
  29275. utils.Mkdir(dir)
  29276. month := time.Unix(1557042972, 0).Format("1")
  29277. year := time.Now().Format("2006")
  29278. month = time.Now().Format("01")
  29279. day := time.Now().Format("02")
  29280. hour := time.Now().Format("15")
  29281. min := time.Now().Format("04")
  29282. sec := time.Now().Format("05")
  29283. result_time := year + "-" + month + "-" + day + " " + hour + ":" + min + ":" + sec
  29284. file := year + month + day + "_log"
  29285. file_name := file + ".txt"
  29286. file_path := "日志" + "/" + file_name
  29287. exist, _ := utils.PathExists(file_path)
  29288. if exist { //存在
  29289. fmt.Println("存在")
  29290. f, err := os.OpenFile(file_path, os.O_WRONLY, 0644)
  29291. if err != nil {
  29292. fmt.Println("read fail")
  29293. }
  29294. content := "\r\n" + "\r\n" + "\r\n" + result_time + " " + "【 " + desc + infno + "入参" + " 】:" + "\r\n" + request + "\r\n" + result_time + " " + "【 " + desc + infno + "出参" + " 】:" + "\r\n" + result
  29295. n, _ := f.Seek(0, 2)
  29296. _, err = f.WriteAt([]byte(content), n)
  29297. } else { //不存在
  29298. fmt.Println("文件不存在,创建文件")
  29299. f, err := os.Create("日志" + "/" + file_name)
  29300. defer f.Close()
  29301. if err != nil {
  29302. } else {
  29303. _, err = f.Write([]byte("记录日志"))
  29304. }
  29305. }
  29306. }
  29307. func saveLog(result string, request string, infno string, desc string) {
  29308. org_id, _ := beego.AppConfig.Int64("org_id")
  29309. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  29310. dir := miConfig.OrgName + "日志"
  29311. utils.Mkdir(dir)
  29312. month := time.Unix(1557042972, 0).Format("1")
  29313. year := time.Now().Format("2006")
  29314. month = time.Now().Format("01")
  29315. day := time.Now().Format("02")
  29316. hour := time.Now().Format("15")
  29317. min := time.Now().Format("04")
  29318. sec := time.Now().Format("05")
  29319. result_time := year + "-" + month + "-" + day + " " + hour + ":" + min + ":" + sec
  29320. file := strconv.FormatInt(org_id, 10) + "_" + year + month + day + "_log"
  29321. file_name := file + ".txt"
  29322. file_path := miConfig.OrgName + "日志" + "/" + file_name
  29323. exist, _ := utils.PathExists(file_path)
  29324. if exist { //存在
  29325. fmt.Println("存在")
  29326. f, err := os.OpenFile(file_path, os.O_WRONLY, 0644)
  29327. if err != nil {
  29328. fmt.Println("read fail")
  29329. }
  29330. content := "\r\n" + "\r\n" + "\r\n" + result_time + " " + "【 " + desc + infno + "入参" + " 】:" + "\r\n" + request + "\r\n" + result_time + " " + "【 " + desc + infno + "出参" + " 】:" + "\r\n" + result
  29331. n, _ := f.Seek(0, 2)
  29332. _, err = f.WriteAt([]byte(content), n)
  29333. } else { //不存在
  29334. fmt.Println("文件不存在,创建文件")
  29335. f, err := os.Create(miConfig.OrgName + "日志" + "/" + file_name)
  29336. defer f.Close()
  29337. if err != nil {
  29338. } else {
  29339. _, err = f.Write([]byte("记录日志"))
  29340. }
  29341. }
  29342. }
  29343. type Charset string
  29344. const (
  29345. UTF8 = Charset("UTF-8")
  29346. GB18030 = Charset("GB18030")
  29347. )
  29348. func ConvertToString(src string, srcCode string, tagCode string) string {
  29349. srcCoder := mahonia.NewDecoder(srcCode)
  29350. srcResult := srcCoder.ConvertString(src)
  29351. tagCoder := mahonia.NewDecoder(tagCode)
  29352. _, cdata, _ := tagCoder.Translate([]byte(srcResult), true)
  29353. result := string(cdata)
  29354. return result
  29355. }
  29356. func ReadEleCard(admin_user_id int64, org_id int64, c *HisApiController) string {
  29357. roles, _ := service.GetAdminUserInfoByID(org_id, admin_user_id)
  29358. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  29359. var token string
  29360. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  29361. var api string
  29362. if miConfig.MdtrtareaAdmvs == "320921" {
  29363. 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 +
  29364. "&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
  29365. fmt.Println(api)
  29366. } else {
  29367. 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 +
  29368. "&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
  29369. }
  29370. resp, requestErr := http.Get(api)
  29371. if requestErr != nil {
  29372. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29373. return ""
  29374. }
  29375. body, ioErr := ioutil.ReadAll(resp.Body)
  29376. if ioErr != nil {
  29377. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29378. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29379. return ""
  29380. }
  29381. var respJSON map[string]interface{}
  29382. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  29383. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29384. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29385. return ""
  29386. }
  29387. var status string
  29388. status = respJSON["data"].(map[string]interface{})["status"].(string)
  29389. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  29390. var res ResultTwo //1101结果
  29391. var res10265 ResultTwo10265 //1101结果
  29392. if status == "0" { //读卡成功
  29393. var card_info string //卡信息
  29394. var busi_card_info string
  29395. token = respJSON["data"].(map[string]interface{})["token"].(string)
  29396. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  29397. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  29398. fmt.Println(card_info)
  29399. fmt.Println(busi_card_info)
  29400. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  29401. result, _ := json.Marshal(respJSON)
  29402. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  29403. utils.ErrorLog("解析失败:%v", err)
  29404. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29405. return ""
  29406. }
  29407. res.ErrMsg = res10265.ErrMsg
  29408. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  29409. res.Infcode = infocode
  29410. res.Output = res10265.Output
  29411. res.InfRefmsgid = res10265.InfRefmsgid
  29412. if res.Infcode == 0 {
  29413. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  29414. if err == gorm.ErrRecordNotFound {
  29415. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  29416. return ""
  29417. } else if err != nil {
  29418. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  29419. return ""
  29420. } else {
  29421. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  29422. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  29423. infoStr := string(Iinfos)
  29424. idetinfoStr := string(Idetinfos)
  29425. psn := &models.HisPsn{
  29426. PsnNo: res.Output.Baseinfo.PsnNo,
  29427. PatientId: patient.ID,
  29428. Certno: res.Output.Baseinfo.Certno,
  29429. Gend: res.Output.Baseinfo.Gend,
  29430. Naty: res.Output.Baseinfo.Naty,
  29431. PsnCertType: res.Output.Baseinfo.PsnCertType,
  29432. PsnName: res.Output.Baseinfo.PsnName,
  29433. Idetinfo: idetinfoStr,
  29434. Insuinfo: infoStr,
  29435. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  29436. CardInfo: card_info,
  29437. VerifyNumber: token,
  29438. }
  29439. service.CreateHisPsn(psn)
  29440. return token
  29441. }
  29442. }
  29443. } else {
  29444. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  29445. return ""
  29446. }
  29447. } else { //读卡失败
  29448. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  29449. return ""
  29450. }
  29451. return token
  29452. }
  29453. func ReadEleCardforah(admin_user_id int64, org_id int64, c *HisApiController) string {
  29454. roles, _ := service.GetAdminUserInfoByID(org_id, admin_user_id)
  29455. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  29456. var token string
  29457. var api string
  29458. api = miConfig.SecretKey + "ahyb/readcardcharge?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  29459. "&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
  29460. fmt.Println(api)
  29461. resp, requestErr := http.Get(api)
  29462. if requestErr != nil {
  29463. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29464. return ""
  29465. }
  29466. body, ioErr := ioutil.ReadAll(resp.Body)
  29467. if ioErr != nil {
  29468. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29469. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29470. return ""
  29471. }
  29472. var respJSON map[string]interface{}
  29473. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  29474. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29475. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29476. return ""
  29477. }
  29478. var status string
  29479. status = respJSON["data"].(map[string]interface{})["status"].(string)
  29480. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  29481. var res ResultTwo //1101结果
  29482. if status == "1" { //读卡成功
  29483. var card_info string //卡信息
  29484. var busi_card_info string
  29485. token = respJSON["data"].(map[string]interface{})["token"].(string)
  29486. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  29487. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  29488. fmt.Println(card_info)
  29489. fmt.Println(busi_card_info)
  29490. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  29491. result, _ := json.Marshal(respJSON)
  29492. if err := json.Unmarshal([]byte(result), &res); err != nil {
  29493. utils.ErrorLog("解析失败:%v", err)
  29494. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29495. return ""
  29496. }
  29497. if res.Infcode == 0 {
  29498. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  29499. if err == gorm.ErrRecordNotFound {
  29500. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  29501. return ""
  29502. } else if err != nil {
  29503. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  29504. return ""
  29505. } else {
  29506. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  29507. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  29508. infoStr := string(Iinfos)
  29509. idetinfoStr := string(Idetinfos)
  29510. psn := &models.HisPsn{
  29511. PsnNo: res.Output.Baseinfo.PsnNo,
  29512. PatientId: patient.ID,
  29513. Certno: res.Output.Baseinfo.Certno,
  29514. Gend: res.Output.Baseinfo.Gend,
  29515. Naty: res.Output.Baseinfo.Naty,
  29516. PsnCertType: res.Output.Baseinfo.PsnCertType,
  29517. PsnName: res.Output.Baseinfo.PsnName,
  29518. Idetinfo: idetinfoStr,
  29519. Insuinfo: infoStr,
  29520. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  29521. CardInfo: card_info,
  29522. VerifyNumber: token,
  29523. }
  29524. service.CreateHisPsn(psn)
  29525. return token
  29526. }
  29527. }
  29528. } else {
  29529. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  29530. return ""
  29531. }
  29532. return token
  29533. }
  29534. func ReadEleFace(admin_user_id int64, org_id int64, c *HisApiController) string {
  29535. roles, _ := service.GetAdminUserInfoByID(org_id, admin_user_id)
  29536. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  29537. var token string
  29538. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  29539. var api string
  29540. if miConfig.MdtrtareaAdmvs == "320921" {
  29541. 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 +
  29542. "&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
  29543. fmt.Println(api)
  29544. } else {
  29545. 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 +
  29546. "&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
  29547. }
  29548. resp, requestErr := http.Get(api)
  29549. if requestErr != nil {
  29550. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29551. return ""
  29552. }
  29553. body, ioErr := ioutil.ReadAll(resp.Body)
  29554. if ioErr != nil {
  29555. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29556. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29557. return ""
  29558. }
  29559. var respJSON map[string]interface{}
  29560. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  29561. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29562. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29563. return ""
  29564. }
  29565. var status string
  29566. status = respJSON["data"].(map[string]interface{})["status"].(string)
  29567. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  29568. var res ResultTwo //1101结果
  29569. var res10265 ResultTwo10265 //1101结果
  29570. if status == "0" { //读卡成功
  29571. var card_info string //卡信息
  29572. var busi_card_info string
  29573. token = respJSON["data"].(map[string]interface{})["token"].(string)
  29574. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  29575. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  29576. fmt.Println(card_info)
  29577. fmt.Println(busi_card_info)
  29578. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  29579. result, _ := json.Marshal(respJSON)
  29580. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  29581. utils.ErrorLog("解析失败:%v", err)
  29582. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29583. return ""
  29584. }
  29585. res.ErrMsg = res10265.ErrMsg
  29586. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  29587. res.Infcode = infocode
  29588. res.Output = res10265.Output
  29589. res.InfRefmsgid = res10265.InfRefmsgid
  29590. if res.Infcode == 0 {
  29591. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  29592. if err == gorm.ErrRecordNotFound {
  29593. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  29594. return ""
  29595. } else if err != nil {
  29596. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  29597. return ""
  29598. } else {
  29599. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  29600. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  29601. infoStr := string(Iinfos)
  29602. idetinfoStr := string(Idetinfos)
  29603. psn := &models.HisPsn{
  29604. PsnNo: res.Output.Baseinfo.PsnNo,
  29605. PatientId: patient.ID,
  29606. Certno: res.Output.Baseinfo.Certno,
  29607. Gend: res.Output.Baseinfo.Gend,
  29608. Naty: res.Output.Baseinfo.Naty,
  29609. PsnCertType: res.Output.Baseinfo.PsnCertType,
  29610. PsnName: res.Output.Baseinfo.PsnName,
  29611. Idetinfo: idetinfoStr,
  29612. Insuinfo: infoStr,
  29613. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  29614. CardInfo: card_info,
  29615. VerifyNumber: token,
  29616. }
  29617. service.CreateHisPsn(psn)
  29618. return token
  29619. }
  29620. }
  29621. } else {
  29622. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  29623. return ""
  29624. }
  29625. } else { //读卡失败
  29626. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  29627. return ""
  29628. }
  29629. return token
  29630. }
  29631. func DeleteExtraSpaceTwo(s string) string {
  29632. //删除字符串中的多余空格,有多个空格时,仅保留一个空格
  29633. s1 := strings.Replace(s, " ", " ", -1) //替换tab为空格
  29634. regstr := "\\s{2,}" //两个及两个以上空格的正则表达式
  29635. reg, _ := regexp.Compile(regstr) //编译正则表达式
  29636. s2 := make([]byte, len(s1)) //定义字符数组切片
  29637. copy(s2, s1) //将字符串复制到切片
  29638. spc_index := reg.FindStringIndex(string(s2)) //在字符串中搜索
  29639. for len(spc_index) > 0 { //找到适配项
  29640. s2 = append(s2[:spc_index[0]+1], s2[spc_index[1]:]...) //删除多余空格
  29641. spc_index = reg.FindStringIndex(string(s2)) //继续在字符串中搜索
  29642. }
  29643. return string(s2)
  29644. }
  29645. func Remove0000(s string) string {
  29646. str := make([]rune, 0, len(s))
  29647. for _, v := range []rune(s) {
  29648. if v == 0 {
  29649. continue
  29650. }
  29651. str = append(str, v)
  29652. }
  29653. return string(str)
  29654. }
  29655. func (c *HisApiController) GetELeCertInfo(code string, operator_id string, operator_name string) (string, string) {
  29656. DllDef := syscall.MustLoadDLL("HeaSecReadInfo.dll")
  29657. readCard := DllDef.MustFindProc("EcQuery")
  29658. pCardInfo := make([]byte, 8192)
  29659. pBusiCardInfo := make([]byte, 8192)
  29660. data := make(map[string]interface{})
  29661. //pData := make(map[string]interface{})
  29662. inputData := make(map[string]interface{})
  29663. inputData["orgId"] = code
  29664. inputData["businessType"] = "01101"
  29665. inputData["operatorId"] = operator_id
  29666. inputData["operatorName"] = operator_name
  29667. inputData["officeId"] = "001"
  29668. inputData["officeName"] = "血透室"
  29669. //
  29670. data["data"] = inputData
  29671. data["transType"] = "ec.query"
  29672. data["orgId"] = code
  29673. bytesData, _ := json.Marshal(data)
  29674. pCardInfo = bytesData
  29675. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&pCardInfo[0])), (uintptr)(unsafe.Pointer(&pBusiCardInfo[0])))
  29676. fmt.Println(ret2)
  29677. //fmt.Println(DeleteExtraSpace(string(bytesData)))
  29678. //fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  29679. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(bytesData)), "gbk", "utf-8"))
  29680. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  29681. if ret2 != 0 {
  29682. return "", ""
  29683. }
  29684. return DeleteExtraSpace(string(bytesData)), DeleteExtraSpace(string(pBusiCardInfo))
  29685. }
  29686. func DeleteExtraSpace(s string) string {
  29687. //删除字符串中的多余空格,有多个空格时,仅保留一个空格
  29688. s1 := strings.Replace(s, " ", " ", -1) //替换tab为空格
  29689. regstr := "\\s{2,}" //两个及两个以上空格的正则表达式
  29690. reg, _ := regexp.Compile(regstr) //编译正则表达式
  29691. s2 := make([]byte, len(s1)) //定义字符数组切片
  29692. copy(s2, s1) //将字符串复制到切片
  29693. spc_index := reg.FindStringIndex(string(s2)) //在字符串中搜索
  29694. for len(spc_index) > 0 { //找到适配项
  29695. s2 = append(s2[:spc_index[0]+1], s2[spc_index[1]:]...) //删除多余空格
  29696. spc_index = reg.FindStringIndex(string(s2)) //继续在字符串中搜索
  29697. }
  29698. return string(s2)
  29699. }
  29700. // 对账
  29701. func (c *HisApiController) Post3202() {
  29702. start_time := c.GetString("start_time")
  29703. end_time := c.GetString("end_time")
  29704. //insutype := c.GetString("insutype")
  29705. clr_type := c.GetString("clr_type")
  29706. clr_org := c.GetString("clr_optins")
  29707. admin_user_id, _ := c.GetInt64("admin_user_id")
  29708. adminUser := c.GetAdminUserInfo()
  29709. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  29710. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  29711. if len(clr_org) == 0 {
  29712. clr_org = miConfig.MdtrtareaAdmvs
  29713. }
  29714. timeLayout := "2006-01-02"
  29715. loc, _ := time.LoadLocation("Local")
  29716. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  29717. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  29718. var orders []*models.HisOrder
  29719. if clr_org == "421300" {
  29720. orders, _ = service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  29721. } else {
  29722. orders, _ = service.GetOrderByTime11222(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  29723. }
  29724. //orders_two, _ := service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, "310", "", clr_type)
  29725. //fixmedins_setl_cnt := int64(len(orders))
  29726. var medfee_sumamt float64
  29727. var acct_pay float64
  29728. var fund_pay_sumamt float64
  29729. for _, item := range orders {
  29730. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  29731. acct_pay = acct_pay + item.AcctPay
  29732. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  29733. }
  29734. //var medfee_sumamt_two float64
  29735. //var acct_pay_two float64
  29736. //var fund_pay_sumamt_two float64
  29737. //for _, item := range orders_two {
  29738. // medfee_sumamt_two = medfee_sumamt_two + item.MedfeeSumamt
  29739. // acct_pay_two = acct_pay_two + item.AcctPay
  29740. // fund_pay_sumamt_two = fund_pay_sumamt_two + item.FundPaySumamt
  29741. //}
  29742. //var user_name string
  29743. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  29744. //if role.ID == 0 {
  29745. // user_name = "xxx"
  29746. //} else {
  29747. // user_name = role.UserName
  29748. //}
  29749. var res ResultSix
  29750. if config.IsOpen == 1 {
  29751. var bps []*models.BusinessParamsTwo
  29752. var bp models.BusinessParamsTwo
  29753. medfee_sumamt_str := fmt.Sprintf("%.2f", medfee_sumamt)
  29754. acct_pay_str := fmt.Sprintf("%.2f", acct_pay)
  29755. fund_pay_sumamt_str := fmt.Sprintf("%.2f", fund_pay_sumamt)
  29756. bp.MedfeeSumamt = medfee_sumamt_str
  29757. bp.AcctPay = acct_pay_str
  29758. bp.FundPaySumamt = fund_pay_sumamt_str
  29759. bp.Insutype = ""
  29760. bp.StmtBegndate = start_time
  29761. bp.ClrType = clr_type
  29762. bp.SetlOptins = clr_org
  29763. bp.StmtEnddate = end_time
  29764. bps = append(bps, &bp)
  29765. data := make(map[string]interface{})
  29766. data["bps"] = bps
  29767. data["org_name"] = miConfig.OrgName
  29768. data["doctor"] = role.UserName
  29769. data["fixmedins_code"] = miConfig.Code
  29770. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  29771. //data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  29772. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  29773. if miConfig.MdtrtareaAdmvs == "421300" {
  29774. client := &http.Client{}
  29775. bytesData, _ := json.Marshal(data)
  29776. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/3202", bytes.NewReader(bytesData))
  29777. resp, _ := client.Do(req)
  29778. defer resp.Body.Close()
  29779. body, ioErr := ioutil.ReadAll(resp.Body)
  29780. if ioErr != nil {
  29781. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29782. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29783. return
  29784. }
  29785. var respJSON map[string]interface{}
  29786. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29787. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29788. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29789. return
  29790. }
  29791. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29792. userJSONBytes, _ := json.Marshal(respJSON)
  29793. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29794. utils.ErrorLog("解析失败:%v", err)
  29795. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29796. return
  29797. }
  29798. }
  29799. if miConfig.MdtrtareaAdmvs == "420200" {
  29800. client := &http.Client{}
  29801. bytesData, _ := json.Marshal(data)
  29802. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/3202", bytes.NewReader(bytesData))
  29803. resp, _ := client.Do(req)
  29804. defer resp.Body.Close()
  29805. body, ioErr := ioutil.ReadAll(resp.Body)
  29806. if ioErr != nil {
  29807. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29808. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29809. return
  29810. }
  29811. var respJSON map[string]interface{}
  29812. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29813. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29814. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29815. return
  29816. }
  29817. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29818. userJSONBytes, _ := json.Marshal(respJSON)
  29819. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29820. utils.ErrorLog("解析失败:%v", err)
  29821. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29822. return
  29823. }
  29824. }
  29825. if miConfig.MdtrtareaAdmvs == "421182" {
  29826. client := &http.Client{}
  29827. bytesData, _ := json.Marshal(data)
  29828. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/3202", bytes.NewReader(bytesData))
  29829. resp, _ := client.Do(req)
  29830. defer resp.Body.Close()
  29831. body, ioErr := ioutil.ReadAll(resp.Body)
  29832. if ioErr != nil {
  29833. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29834. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29835. return
  29836. }
  29837. var respJSON map[string]interface{}
  29838. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29839. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29840. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29841. return
  29842. }
  29843. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29844. userJSONBytes, _ := json.Marshal(respJSON)
  29845. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29846. utils.ErrorLog("解析失败:%v", err)
  29847. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29848. return
  29849. }
  29850. }
  29851. if res.Infcode == 0 {
  29852. c.ServeSuccessJSON(map[string]interface{}{
  29853. "msg": "发起成功",
  29854. })
  29855. } else {
  29856. c.ServeSuccessJSON(map[string]interface{}{
  29857. "failed_code": -10,
  29858. "msg": res.ErrMsg,
  29859. })
  29860. }
  29861. }
  29862. }
  29863. func (c *HisApiController) Post3202b() {
  29864. start_time := c.GetString("start_time")
  29865. end_time := c.GetString("end_time")
  29866. //insutype := c.GetString("insutype")
  29867. clr_type := c.GetString("clr_type")
  29868. clr_org := c.GetString("clr_optins")
  29869. admin_user_id, _ := c.GetInt64("admin_user_id")
  29870. adminUser := c.GetAdminUserInfo()
  29871. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  29872. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  29873. if len(clr_org) == 0 {
  29874. clr_org = miConfig.MdtrtareaAdmvs
  29875. }
  29876. timeLayout := "2006-01-02"
  29877. loc, _ := time.LoadLocation("Local")
  29878. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  29879. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  29880. orders, _ := service.GetOrderByTimeFourfor11(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  29881. //orders_two, _ := service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, "310", "", clr_type)
  29882. //fixmedins_setl_cnt := int64(len(orders))
  29883. var medfee_sumamt float64
  29884. var acct_pay float64
  29885. var fund_pay_sumamt float64
  29886. for _, item := range orders {
  29887. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  29888. acct_pay = acct_pay + item.AcctPay
  29889. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  29890. }
  29891. //var medfee_sumamt_two float64
  29892. //var acct_pay_two float64
  29893. //var fund_pay_sumamt_two float64
  29894. //for _, item := range orders_two {
  29895. // medfee_sumamt_two = medfee_sumamt_two + item.MedfeeSumamt
  29896. // acct_pay_two = acct_pay_two + item.AcctPay
  29897. // fund_pay_sumamt_two = fund_pay_sumamt_two + item.FundPaySumamt
  29898. //}
  29899. //var user_name string
  29900. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  29901. //if role.ID == 0 {
  29902. // user_name = "xxx"
  29903. //} else {
  29904. // user_name = role.UserName
  29905. //}
  29906. var res ResultSix
  29907. if config.IsOpen == 1 {
  29908. var bps []*models.BusinessParamsTwo
  29909. var bp models.BusinessParamsTwo
  29910. medfee_sumamt_str := fmt.Sprintf("%.2f", medfee_sumamt)
  29911. acct_pay_str := fmt.Sprintf("%.2f", acct_pay)
  29912. fund_pay_sumamt_str := fmt.Sprintf("%.2f", fund_pay_sumamt)
  29913. bp.MedfeeSumamt = medfee_sumamt_str
  29914. bp.AcctPay = acct_pay_str
  29915. bp.FundPaySumamt = fund_pay_sumamt_str
  29916. bp.Insutype = "390"
  29917. bp.StmtBegndate = start_time
  29918. bp.ClrType = clr_type
  29919. bp.SetlOptins = clr_org
  29920. bp.StmtEnddate = end_time
  29921. bps = append(bps, &bp)
  29922. data := make(map[string]interface{})
  29923. data["bps"] = bps
  29924. data["org_name"] = miConfig.OrgName
  29925. data["doctor"] = role.UserName
  29926. data["fixmedins_code"] = miConfig.Code
  29927. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  29928. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  29929. if miConfig.MdtrtareaAdmvs == "421300" {
  29930. client := &http.Client{}
  29931. bytesData, _ := json.Marshal(data)
  29932. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/3202b", bytes.NewReader(bytesData))
  29933. resp, _ := client.Do(req)
  29934. defer resp.Body.Close()
  29935. body, ioErr := ioutil.ReadAll(resp.Body)
  29936. if ioErr != nil {
  29937. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29938. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29939. return
  29940. }
  29941. var respJSON map[string]interface{}
  29942. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29943. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29944. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29945. return
  29946. }
  29947. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29948. userJSONBytes, _ := json.Marshal(respJSON)
  29949. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29950. utils.ErrorLog("解析失败:%v", err)
  29951. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29952. return
  29953. }
  29954. }
  29955. if miConfig.MdtrtareaAdmvs == "420200" {
  29956. client := &http.Client{}
  29957. bytesData, _ := json.Marshal(data)
  29958. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/3202b", bytes.NewReader(bytesData))
  29959. resp, _ := client.Do(req)
  29960. defer resp.Body.Close()
  29961. body, ioErr := ioutil.ReadAll(resp.Body)
  29962. if ioErr != nil {
  29963. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29964. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29965. return
  29966. }
  29967. var respJSON map[string]interface{}
  29968. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29969. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29970. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29971. return
  29972. }
  29973. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29974. userJSONBytes, _ := json.Marshal(respJSON)
  29975. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29976. utils.ErrorLog("解析失败:%v", err)
  29977. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29978. return
  29979. }
  29980. }
  29981. if miConfig.MdtrtareaAdmvs == "421182" {
  29982. client := &http.Client{}
  29983. bytesData, _ := json.Marshal(data)
  29984. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/3202b", bytes.NewReader(bytesData))
  29985. resp, _ := client.Do(req)
  29986. defer resp.Body.Close()
  29987. body, ioErr := ioutil.ReadAll(resp.Body)
  29988. if ioErr != nil {
  29989. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29990. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29991. return
  29992. }
  29993. var respJSON map[string]interface{}
  29994. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29995. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29996. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29997. return
  29998. }
  29999. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30000. userJSONBytes, _ := json.Marshal(respJSON)
  30001. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30002. utils.ErrorLog("解析失败:%v", err)
  30003. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30004. return
  30005. }
  30006. }
  30007. if res.Infcode == 0 {
  30008. c.ServeSuccessJSON(map[string]interface{}{
  30009. "msg": "发起成功",
  30010. })
  30011. } else {
  30012. c.ServeSuccessJSON(map[string]interface{}{
  30013. "failed_code": -10,
  30014. "msg": res.ErrMsg,
  30015. })
  30016. }
  30017. }
  30018. }
  30019. func (c *HisApiController) Post1608() {
  30020. start_time := c.GetString("start_time")
  30021. end_time := c.GetString("end_time")
  30022. admin_user_id, _ := c.GetInt64("admin_user_id")
  30023. adminUser := c.GetAdminUserInfo()
  30024. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  30025. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  30026. timeLayout := "2006-01-02"
  30027. loc, _ := time.LoadLocation("Local")
  30028. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  30029. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  30030. orders, _ := service.GetOrderByTimeFourfor11(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  30031. //orders_two, _ := service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, "310", "", clr_type)
  30032. fixmedins_setl_cnt := int64(len(orders))
  30033. var medfee_sumamt float64
  30034. var func_smamt float64
  30035. for _, item := range orders {
  30036. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  30037. func_smamt = func_smamt + item.FundPaySumamt + item.AcctPay
  30038. }
  30039. times := strings.Split(start_time, "-")
  30040. time_tows := strings.Split(end_time, "-")
  30041. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  30042. var res ResultSix
  30043. if config.IsOpen == 1 {
  30044. //var bps []*models.BusinessParamsTwo
  30045. //var bp models.BusinessParamsTwo
  30046. medfee_sumamt_str := fmt.Sprintf("%.2f", medfee_sumamt)
  30047. func_smamt_str := fmt.Sprintf("%.2f", func_smamt)
  30048. data := make(map[string]interface{})
  30049. data["org_name"] = miConfig.OrgName
  30050. data["doctor"] = role.UserName
  30051. data["func_smamt"] = func_smamt_str
  30052. data["fixmedins_code"] = miConfig.Code
  30053. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  30054. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  30055. data["cnt"] = strconv.FormatInt(fixmedins_setl_cnt, 10)
  30056. data["medfee_sumamt"] = medfee_sumamt_str
  30057. data["start_time"] = times[0] + times[1] + times[2]
  30058. data["end_time"] = time_tows[0] + time_tows[1] + time_tows[2]
  30059. if miConfig.MdtrtareaAdmvs == "421300" {
  30060. client := &http.Client{}
  30061. bytesData, _ := json.Marshal(data)
  30062. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/1608", bytes.NewReader(bytesData))
  30063. resp, _ := client.Do(req)
  30064. defer resp.Body.Close()
  30065. body, ioErr := ioutil.ReadAll(resp.Body)
  30066. if ioErr != nil {
  30067. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30068. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30069. return
  30070. }
  30071. var respJSON map[string]interface{}
  30072. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30073. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30074. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30075. return
  30076. }
  30077. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30078. userJSONBytes, _ := json.Marshal(respJSON)
  30079. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30080. utils.ErrorLog("解析失败:%v", err)
  30081. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30082. return
  30083. }
  30084. }
  30085. if miConfig.MdtrtareaAdmvs == "420200" {
  30086. client := &http.Client{}
  30087. bytesData, _ := json.Marshal(data)
  30088. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/1608", bytes.NewReader(bytesData))
  30089. resp, _ := client.Do(req)
  30090. defer resp.Body.Close()
  30091. body, ioErr := ioutil.ReadAll(resp.Body)
  30092. if ioErr != nil {
  30093. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30094. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30095. return
  30096. }
  30097. var respJSON map[string]interface{}
  30098. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30099. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30100. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30101. return
  30102. }
  30103. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30104. userJSONBytes, _ := json.Marshal(respJSON)
  30105. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30106. utils.ErrorLog("解析失败:%v", err)
  30107. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30108. return
  30109. }
  30110. }
  30111. if miConfig.MdtrtareaAdmvs == "421182" {
  30112. client := &http.Client{}
  30113. bytesData, _ := json.Marshal(data)
  30114. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/1608", bytes.NewReader(bytesData))
  30115. resp, _ := client.Do(req)
  30116. defer resp.Body.Close()
  30117. body, ioErr := ioutil.ReadAll(resp.Body)
  30118. if ioErr != nil {
  30119. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30120. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30121. return
  30122. }
  30123. var respJSON map[string]interface{}
  30124. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30125. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30126. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30127. return
  30128. }
  30129. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30130. userJSONBytes, _ := json.Marshal(respJSON)
  30131. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30132. utils.ErrorLog("解析失败:%v", err)
  30133. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30134. return
  30135. }
  30136. }
  30137. if res.Infcode == 0 {
  30138. c.ServeSuccessJSON(map[string]interface{}{
  30139. "msg": "发起成功",
  30140. })
  30141. } else {
  30142. c.ServeSuccessJSON(map[string]interface{}{
  30143. "failed_code": -10,
  30144. "msg": res.ErrMsg,
  30145. })
  30146. }
  30147. }
  30148. }
  30149. // 5.11.1.1【5262】结算信息按时间段查询
  30150. func Post5262(c *HisApiController, bp models.BusinessParams5262, page int64, limit int64) {
  30151. admin_user_id, _ := c.GetInt64("admin_user_id")
  30152. adminUser := c.GetAdminUserInfo()
  30153. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  30154. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  30155. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  30156. var res Result5262
  30157. if config.IsOpen == 1 {
  30158. if miConfig.MdtrtareaAdmvs == "421300" {
  30159. data := make(map[string]interface{})
  30160. data["bps"] = bp
  30161. data["org_name"] = miConfig.OrgName
  30162. data["doctor"] = role.UserName
  30163. data["fixmedins_code"] = miConfig.Code
  30164. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  30165. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  30166. data["page"] = strconv.FormatInt(page, 10)
  30167. data["limit"] = strconv.FormatInt(limit, 10)
  30168. fmt.Println(data)
  30169. client := &http.Client{}
  30170. bytesData, _ := json.Marshal(data)
  30171. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/5262", bytes.NewReader(bytesData))
  30172. resp, _ := client.Do(req)
  30173. defer resp.Body.Close()
  30174. body, ioErr := ioutil.ReadAll(resp.Body)
  30175. if ioErr != nil {
  30176. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30177. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30178. return
  30179. }
  30180. var respJSON map[string]interface{}
  30181. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30182. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30183. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30184. return
  30185. }
  30186. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30187. userJSONBytes, _ := json.Marshal(respJSON)
  30188. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30189. utils.ErrorLog("解析失败:%v", err)
  30190. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30191. return
  30192. }
  30193. }
  30194. if miConfig.MdtrtareaAdmvs == "420200" {
  30195. data := make(map[string]interface{})
  30196. data["bps"] = bp
  30197. data["org_name"] = miConfig.OrgName
  30198. data["doctor"] = role.UserName
  30199. data["fixmedins_code"] = miConfig.Code
  30200. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  30201. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  30202. data["page"] = strconv.FormatInt(page, 10)
  30203. data["limit"] = strconv.FormatInt(limit, 10)
  30204. fmt.Println(data)
  30205. client := &http.Client{}
  30206. bytesData, _ := json.Marshal(data)
  30207. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/5262", bytes.NewReader(bytesData))
  30208. resp, _ := client.Do(req)
  30209. defer resp.Body.Close()
  30210. body, ioErr := ioutil.ReadAll(resp.Body)
  30211. if ioErr != nil {
  30212. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30213. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30214. return
  30215. }
  30216. var respJSON map[string]interface{}
  30217. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30218. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30219. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30220. return
  30221. }
  30222. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30223. userJSONBytes, _ := json.Marshal(respJSON)
  30224. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30225. utils.ErrorLog("解析失败:%v", err)
  30226. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30227. return
  30228. }
  30229. }
  30230. if miConfig.MdtrtareaAdmvs == "421182" {
  30231. data := make(map[string]interface{})
  30232. data["bps"] = bp
  30233. data["org_name"] = miConfig.OrgName
  30234. data["doctor"] = role.UserName
  30235. data["fixmedins_code"] = miConfig.Code
  30236. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  30237. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  30238. data["page"] = strconv.FormatInt(page, 10)
  30239. data["limit"] = strconv.FormatInt(limit, 10)
  30240. fmt.Println(data)
  30241. client := &http.Client{}
  30242. bytesData, _ := json.Marshal(data)
  30243. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/5262", bytes.NewReader(bytesData))
  30244. resp, _ := client.Do(req)
  30245. defer resp.Body.Close()
  30246. body, ioErr := ioutil.ReadAll(resp.Body)
  30247. if ioErr != nil {
  30248. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30249. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30250. return
  30251. }
  30252. var respJSON map[string]interface{}
  30253. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30254. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30255. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30256. return
  30257. }
  30258. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30259. userJSONBytes, _ := json.Marshal(respJSON)
  30260. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30261. utils.ErrorLog("解析失败:%v", err)
  30262. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30263. return
  30264. }
  30265. }
  30266. if res.Infcode == 0 {
  30267. c.ServeSuccessJSON(map[string]interface{}{
  30268. "order": res.Output.Result,
  30269. "total": res.Output.PageInfo.RecordCounts,
  30270. })
  30271. } else {
  30272. c.ServeSuccessJSON(map[string]interface{}{
  30273. "failed_code": -10,
  30274. "msg": res.ErrMsg,
  30275. })
  30276. }
  30277. }
  30278. }
  30279. // 5.11.1.2【5267】异地结算信息时间段查询
  30280. func Post5267(c *HisApiController, bp models.BusinessParams5262, page int64, limit int64) {
  30281. admin_user_id, _ := c.GetInt64("admin_user_id")
  30282. adminUser := c.GetAdminUserInfo()
  30283. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  30284. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  30285. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  30286. var res Result5267
  30287. if config.IsOpen == 1 {
  30288. if miConfig.MdtrtareaAdmvs == "421300" {
  30289. data := make(map[string]interface{})
  30290. data["bps"] = bp
  30291. data["org_name"] = miConfig.OrgName
  30292. data["doctor"] = role.UserName
  30293. data["fixmedins_code"] = miConfig.Code
  30294. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  30295. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  30296. data["page"] = page
  30297. data["limit"] = limit
  30298. fmt.Println(data)
  30299. client := &http.Client{}
  30300. bytesData, _ := json.Marshal(data)
  30301. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/5267", bytes.NewReader(bytesData))
  30302. resp, _ := client.Do(req)
  30303. defer resp.Body.Close()
  30304. body, ioErr := ioutil.ReadAll(resp.Body)
  30305. if ioErr != nil {
  30306. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30307. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30308. return
  30309. }
  30310. var respJSON map[string]interface{}
  30311. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30312. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30313. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30314. return
  30315. }
  30316. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30317. userJSONBytes, _ := json.Marshal(respJSON)
  30318. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30319. utils.ErrorLog("解析失败:%v", err)
  30320. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30321. return
  30322. }
  30323. }
  30324. if miConfig.MdtrtareaAdmvs == "420200" {
  30325. data := make(map[string]interface{})
  30326. data["bps"] = bp
  30327. data["org_name"] = miConfig.OrgName
  30328. data["doctor"] = role.UserName
  30329. data["fixmedins_code"] = miConfig.Code
  30330. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  30331. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  30332. data["page"] = page
  30333. data["limit"] = limit
  30334. fmt.Println(data)
  30335. client := &http.Client{}
  30336. bytesData, _ := json.Marshal(data)
  30337. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/5267", bytes.NewReader(bytesData))
  30338. resp, _ := client.Do(req)
  30339. defer resp.Body.Close()
  30340. body, ioErr := ioutil.ReadAll(resp.Body)
  30341. if ioErr != nil {
  30342. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30343. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30344. return
  30345. }
  30346. var respJSON map[string]interface{}
  30347. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30348. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30349. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30350. return
  30351. }
  30352. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30353. userJSONBytes, _ := json.Marshal(respJSON)
  30354. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30355. utils.ErrorLog("解析失败:%v", err)
  30356. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30357. return
  30358. }
  30359. }
  30360. if miConfig.MdtrtareaAdmvs == "421182" {
  30361. data := make(map[string]interface{})
  30362. data["bps"] = bp
  30363. data["org_name"] = miConfig.OrgName
  30364. data["doctor"] = role.UserName
  30365. data["fixmedins_code"] = miConfig.Code
  30366. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  30367. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  30368. data["page"] = page
  30369. data["limit"] = limit
  30370. fmt.Println(data)
  30371. client := &http.Client{}
  30372. bytesData, _ := json.Marshal(data)
  30373. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/5267", bytes.NewReader(bytesData))
  30374. resp, _ := client.Do(req)
  30375. defer resp.Body.Close()
  30376. body, ioErr := ioutil.ReadAll(resp.Body)
  30377. if ioErr != nil {
  30378. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30379. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30380. return
  30381. }
  30382. var respJSON map[string]interface{}
  30383. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30384. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30385. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30386. return
  30387. }
  30388. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30389. userJSONBytes, _ := json.Marshal(respJSON)
  30390. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30391. utils.ErrorLog("解析失败:%v", err)
  30392. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30393. return
  30394. }
  30395. }
  30396. if res.Infcode == 0 {
  30397. c.ServeSuccessJSON(map[string]interface{}{
  30398. "order": res.Output.Result,
  30399. "total": res.Output.PageInfo.RecordCounts,
  30400. })
  30401. } else {
  30402. c.ServeSuccessJSON(map[string]interface{}{
  30403. "failed_code": -10,
  30404. "msg": res.ErrMsg,
  30405. })
  30406. }
  30407. }
  30408. }
  30409. func (c *HisApiController) Post3501() {
  30410. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  30411. data := make(map[string]interface{})
  30412. var struct3501s []models.Struct3501
  30413. var struct3501 models.Struct3501
  30414. struct3501.OrgName = miConfig.OrgName
  30415. struct3501.AccessKey = miConfig.AccessKey
  30416. struct3501.RequestUrl = miConfig.Url
  30417. struct3501.SecretKey = miConfig.SecretKey
  30418. struct3501.ManuDate = "2022-08-17"
  30419. struct3501.FixmedinsBchno = ""
  30420. struct3501.ManuLotnum = ""
  30421. struct3501.RxFlag = "0"
  30422. struct3501.ExpyEnd = "2022-08-17"
  30423. struct3501.Invdate = "2022-08-17"
  30424. struct3501.InvCnt = "20.25"
  30425. struct3501.Memo = ""
  30426. struct3501.MedListCodg = "XB01ABD056B002020200517"
  30427. struct3501.FixmedinsHilistId = miConfig.Code
  30428. struct3501.FixmedinsHilistName = miConfig.OrgName
  30429. struct3501s = append(struct3501s, struct3501)
  30430. data["struct_3501s"] = struct3501s
  30431. client := &http.Client{}
  30432. bytesData, _ := json.Marshal(data)
  30433. var req *http.Request
  30434. if miConfig.MdtrtareaAdmvs == "320921" {
  30435. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  30436. } else {
  30437. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  30438. }
  30439. resp, _ := client.Do(req)
  30440. defer resp.Body.Close()
  30441. body, ioErr := ioutil.ReadAll(resp.Body)
  30442. if ioErr != nil {
  30443. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30444. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30445. return
  30446. }
  30447. var respJSON map[string]interface{}
  30448. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30449. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30450. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30451. return
  30452. }
  30453. var res ResultSix
  30454. var resSix10265 ResultSix10265 //1101结果
  30455. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  30456. result, _ := json.Marshal(respJSON)
  30457. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  30458. utils.ErrorLog("解析失败:%v", err)
  30459. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30460. return
  30461. }
  30462. res.InfRefmsgid = resSix10265.InfRefmsgid
  30463. res.Output = resSix10265.Output
  30464. res.ErrMsg = resSix10265.ErrMsg
  30465. res.Cainfo = resSix10265.Cainfo
  30466. res.WarnMsg = resSix10265.WarnMsg
  30467. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  30468. res.Infcode = infocode
  30469. if infocode == 0 {
  30470. c.ServeSuccessJSON(map[string]interface{}{
  30471. "msg": "上传成功",
  30472. })
  30473. return
  30474. } else {
  30475. c.ServeSuccessJSON(map[string]interface{}{
  30476. "failed_code": -10,
  30477. "msg": res.ErrMsg,
  30478. })
  30479. return
  30480. }
  30481. }
  30482. func (c *HisApiController) Post3502() {
  30483. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  30484. data := make(map[string]interface{})
  30485. var struct3502s []models.Struct3502
  30486. var struct3502 models.Struct3502
  30487. struct3502.OrgName = miConfig.OrgName
  30488. struct3502.AccessKey = miConfig.AccessKey
  30489. struct3502.RequestUrl = miConfig.Url
  30490. struct3502.SecretKey = miConfig.SecretKey
  30491. struct3502.ManuDate = "2022-08-15"
  30492. struct3502.FixmedinsBchno = ""
  30493. struct3502.ManuLotnum = ""
  30494. struct3502.RxFlag = "0"
  30495. struct3502.ExpyEnd = "2022-08-15"
  30496. struct3502.Invdate = "2022-08-15"
  30497. struct3502.InvCnt = "20.25"
  30498. struct3502.Memo = ""
  30499. struct3502.MedListCodg = "XB01ABD056B002020200517"
  30500. struct3502.FixmedinsHilistId = miConfig.Code
  30501. struct3502.FixmedinsHilistName = miConfig.OrgName
  30502. struct3502s = append(struct3502s, struct3502)
  30503. data["struct_3502s"] = struct3502s
  30504. client := &http.Client{}
  30505. bytesData, _ := json.Marshal(data)
  30506. var req *http.Request
  30507. if miConfig.MdtrtareaAdmvs == "320921" {
  30508. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  30509. } else {
  30510. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  30511. }
  30512. resp, _ := client.Do(req)
  30513. defer resp.Body.Close()
  30514. body, ioErr := ioutil.ReadAll(resp.Body)
  30515. if ioErr != nil {
  30516. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30517. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30518. return
  30519. }
  30520. var respJSON map[string]interface{}
  30521. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30522. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30523. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30524. return
  30525. }
  30526. var res ResultSix
  30527. var resSix10265 ResultSix10265 //1101结果
  30528. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  30529. result, _ := json.Marshal(respJSON)
  30530. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  30531. utils.ErrorLog("解析失败:%v", err)
  30532. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30533. return
  30534. }
  30535. res.InfRefmsgid = resSix10265.InfRefmsgid
  30536. res.Output = resSix10265.Output
  30537. res.ErrMsg = resSix10265.ErrMsg
  30538. res.Cainfo = resSix10265.Cainfo
  30539. res.WarnMsg = resSix10265.WarnMsg
  30540. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  30541. res.Infcode = infocode
  30542. if infocode == 0 {
  30543. c.ServeSuccessJSON(map[string]interface{}{
  30544. "msg": "上传成功",
  30545. })
  30546. return
  30547. } else {
  30548. c.ServeSuccessJSON(map[string]interface{}{
  30549. "failed_code": -10,
  30550. "msg": res.ErrMsg,
  30551. })
  30552. return
  30553. }
  30554. }
  30555. func (c *HisApiController) Post3503() {
  30556. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  30557. data := make(map[string]interface{})
  30558. var struct3501s []models.Struct3501
  30559. var struct3501 models.Struct3501
  30560. struct3501.OrgName = miConfig.OrgName
  30561. struct3501.AccessKey = miConfig.AccessKey
  30562. struct3501.RequestUrl = miConfig.Url
  30563. struct3501.SecretKey = miConfig.SecretKey
  30564. struct3501.ManuDate = "2022-08-15"
  30565. struct3501.FixmedinsBchno = ""
  30566. struct3501.ManuLotnum = ""
  30567. struct3501.RxFlag = "0"
  30568. struct3501.ExpyEnd = "2022-08-15"
  30569. struct3501.Invdate = "2022-08-15"
  30570. struct3501.InvCnt = "20.25"
  30571. struct3501.Memo = ""
  30572. struct3501.MedListCodg = "XB01ABD056B002020200517"
  30573. struct3501.FixmedinsHilistId = miConfig.Code
  30574. struct3501.FixmedinsHilistName = miConfig.OrgName
  30575. struct3501s = append(struct3501s, struct3501)
  30576. data["struct_3501s"] = struct3501s
  30577. client := &http.Client{}
  30578. bytesData, _ := json.Marshal(data)
  30579. var req *http.Request
  30580. if miConfig.MdtrtareaAdmvs == "320921" {
  30581. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  30582. } else {
  30583. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  30584. }
  30585. resp, _ := client.Do(req)
  30586. defer resp.Body.Close()
  30587. body, ioErr := ioutil.ReadAll(resp.Body)
  30588. if ioErr != nil {
  30589. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30590. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30591. return
  30592. }
  30593. var respJSON map[string]interface{}
  30594. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30595. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30596. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30597. return
  30598. }
  30599. var res ResultSix
  30600. var resSix10265 ResultSix10265 //1101结果
  30601. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  30602. result, _ := json.Marshal(respJSON)
  30603. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  30604. utils.ErrorLog("解析失败:%v", err)
  30605. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30606. return
  30607. }
  30608. res.InfRefmsgid = resSix10265.InfRefmsgid
  30609. res.Output = resSix10265.Output
  30610. res.ErrMsg = resSix10265.ErrMsg
  30611. res.Cainfo = resSix10265.Cainfo
  30612. res.WarnMsg = resSix10265.WarnMsg
  30613. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  30614. res.Infcode = infocode
  30615. if infocode == 0 {
  30616. c.ServeSuccessJSON(map[string]interface{}{
  30617. "msg": "上传成功",
  30618. })
  30619. return
  30620. } else {
  30621. c.ServeSuccessJSON(map[string]interface{}{
  30622. "failed_code": -10,
  30623. "msg": res.ErrMsg,
  30624. })
  30625. return
  30626. }
  30627. }
  30628. func (c *HisApiController) Post3504() {
  30629. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  30630. data := make(map[string]interface{})
  30631. var struct3501s []models.Struct3501
  30632. var struct3501 models.Struct3501
  30633. struct3501.OrgName = miConfig.OrgName
  30634. struct3501.AccessKey = miConfig.AccessKey
  30635. struct3501.RequestUrl = miConfig.Url
  30636. struct3501.SecretKey = miConfig.SecretKey
  30637. struct3501.ManuDate = "2022-08-15"
  30638. struct3501.FixmedinsBchno = ""
  30639. struct3501.ManuLotnum = ""
  30640. struct3501.RxFlag = "0"
  30641. struct3501.ExpyEnd = "2022-08-15"
  30642. struct3501.Invdate = "2022-08-15"
  30643. struct3501.InvCnt = "20.25"
  30644. struct3501.Memo = ""
  30645. struct3501.MedListCodg = "XB01ABD056B002020200517"
  30646. struct3501.FixmedinsHilistId = miConfig.Code
  30647. struct3501.FixmedinsHilistName = miConfig.OrgName
  30648. struct3501s = append(struct3501s, struct3501)
  30649. data["struct_3501s"] = struct3501s
  30650. client := &http.Client{}
  30651. bytesData, _ := json.Marshal(data)
  30652. var req *http.Request
  30653. if miConfig.MdtrtareaAdmvs == "320921" {
  30654. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  30655. } else {
  30656. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  30657. }
  30658. resp, _ := client.Do(req)
  30659. defer resp.Body.Close()
  30660. body, ioErr := ioutil.ReadAll(resp.Body)
  30661. if ioErr != nil {
  30662. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30663. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30664. return
  30665. }
  30666. var respJSON map[string]interface{}
  30667. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30668. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30669. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30670. return
  30671. }
  30672. var res ResultSix
  30673. var resSix10265 ResultSix10265 //1101结果
  30674. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  30675. result, _ := json.Marshal(respJSON)
  30676. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  30677. utils.ErrorLog("解析失败:%v", err)
  30678. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30679. return
  30680. }
  30681. res.InfRefmsgid = resSix10265.InfRefmsgid
  30682. res.Output = resSix10265.Output
  30683. res.ErrMsg = resSix10265.ErrMsg
  30684. res.Cainfo = resSix10265.Cainfo
  30685. res.WarnMsg = resSix10265.WarnMsg
  30686. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  30687. res.Infcode = infocode
  30688. if infocode == 0 {
  30689. c.ServeSuccessJSON(map[string]interface{}{
  30690. "msg": "上传成功",
  30691. })
  30692. return
  30693. } else {
  30694. c.ServeSuccessJSON(map[string]interface{}{
  30695. "failed_code": -10,
  30696. "msg": res.ErrMsg,
  30697. })
  30698. return
  30699. }
  30700. }
  30701. func (c *HisApiController) Post3505() {
  30702. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  30703. data := make(map[string]interface{})
  30704. var struct3501s []models.Struct3501
  30705. var struct3501 models.Struct3501
  30706. struct3501.OrgName = miConfig.OrgName
  30707. struct3501.AccessKey = miConfig.AccessKey
  30708. struct3501.RequestUrl = miConfig.Url
  30709. struct3501.SecretKey = miConfig.SecretKey
  30710. struct3501.ManuDate = "2022-08-15"
  30711. struct3501.FixmedinsBchno = ""
  30712. struct3501.ManuLotnum = ""
  30713. struct3501.RxFlag = "0"
  30714. struct3501.ExpyEnd = "2022-08-15"
  30715. struct3501.Invdate = "2022-08-15"
  30716. struct3501.InvCnt = "20.25"
  30717. struct3501.Memo = ""
  30718. struct3501.MedListCodg = "XB01ABD056B002020200517"
  30719. struct3501.FixmedinsHilistId = miConfig.Code
  30720. struct3501.FixmedinsHilistName = miConfig.OrgName
  30721. struct3501s = append(struct3501s, struct3501)
  30722. data["struct_3501s"] = struct3501s
  30723. client := &http.Client{}
  30724. bytesData, _ := json.Marshal(data)
  30725. var req *http.Request
  30726. if miConfig.MdtrtareaAdmvs == "320921" {
  30727. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  30728. } else {
  30729. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  30730. }
  30731. resp, _ := client.Do(req)
  30732. defer resp.Body.Close()
  30733. body, ioErr := ioutil.ReadAll(resp.Body)
  30734. if ioErr != nil {
  30735. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30736. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30737. return
  30738. }
  30739. var respJSON map[string]interface{}
  30740. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30741. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30742. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30743. return
  30744. }
  30745. var res ResultSix
  30746. var resSix10265 ResultSix10265 //1101结果
  30747. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  30748. result, _ := json.Marshal(respJSON)
  30749. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  30750. utils.ErrorLog("解析失败:%v", err)
  30751. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30752. return
  30753. }
  30754. res.InfRefmsgid = resSix10265.InfRefmsgid
  30755. res.Output = resSix10265.Output
  30756. res.ErrMsg = resSix10265.ErrMsg
  30757. res.Cainfo = resSix10265.Cainfo
  30758. res.WarnMsg = resSix10265.WarnMsg
  30759. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  30760. res.Infcode = infocode
  30761. if infocode == 0 {
  30762. c.ServeSuccessJSON(map[string]interface{}{
  30763. "msg": "上传成功",
  30764. })
  30765. return
  30766. } else {
  30767. c.ServeSuccessJSON(map[string]interface{}{
  30768. "failed_code": -10,
  30769. "msg": res.ErrMsg,
  30770. })
  30771. return
  30772. }
  30773. }
  30774. func (c *HisApiController) Post3506() {
  30775. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  30776. data := make(map[string]interface{})
  30777. var struct3501s []models.Struct3501
  30778. var struct3501 models.Struct3501
  30779. struct3501.OrgName = miConfig.OrgName
  30780. struct3501.AccessKey = miConfig.AccessKey
  30781. struct3501.RequestUrl = miConfig.Url
  30782. struct3501.SecretKey = miConfig.SecretKey
  30783. struct3501.ManuDate = "2022-08-15"
  30784. struct3501.FixmedinsBchno = ""
  30785. struct3501.ManuLotnum = ""
  30786. struct3501.RxFlag = "0"
  30787. struct3501.ExpyEnd = "2022-08-15"
  30788. struct3501.Invdate = "2022-08-15"
  30789. struct3501.InvCnt = "20.25"
  30790. struct3501.Memo = ""
  30791. struct3501.MedListCodg = "XB01ABD056B002020200517"
  30792. struct3501.FixmedinsHilistId = miConfig.Code
  30793. struct3501.FixmedinsHilistName = miConfig.OrgName
  30794. struct3501s = append(struct3501s, struct3501)
  30795. data["struct_3501s"] = struct3501s
  30796. client := &http.Client{}
  30797. bytesData, _ := json.Marshal(data)
  30798. var req *http.Request
  30799. if miConfig.MdtrtareaAdmvs == "320921" {
  30800. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  30801. } else {
  30802. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  30803. }
  30804. resp, _ := client.Do(req)
  30805. defer resp.Body.Close()
  30806. body, ioErr := ioutil.ReadAll(resp.Body)
  30807. if ioErr != nil {
  30808. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30809. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30810. return
  30811. }
  30812. var respJSON map[string]interface{}
  30813. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30814. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30815. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30816. return
  30817. }
  30818. var res ResultSix
  30819. var resSix10265 ResultSix10265 //1101结果
  30820. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  30821. result, _ := json.Marshal(respJSON)
  30822. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  30823. utils.ErrorLog("解析失败:%v", err)
  30824. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30825. return
  30826. }
  30827. res.InfRefmsgid = resSix10265.InfRefmsgid
  30828. res.Output = resSix10265.Output
  30829. res.ErrMsg = resSix10265.ErrMsg
  30830. res.Cainfo = resSix10265.Cainfo
  30831. res.WarnMsg = resSix10265.WarnMsg
  30832. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  30833. res.Infcode = infocode
  30834. if infocode == 0 {
  30835. c.ServeSuccessJSON(map[string]interface{}{
  30836. "msg": "上传成功",
  30837. })
  30838. return
  30839. } else {
  30840. c.ServeSuccessJSON(map[string]interface{}{
  30841. "failed_code": -10,
  30842. "msg": res.ErrMsg,
  30843. })
  30844. return
  30845. }
  30846. }
  30847. func (c *HisApiController) Post3507() {
  30848. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  30849. data := make(map[string]interface{})
  30850. var struct3501s []models.Struct3501
  30851. var struct3501 models.Struct3501
  30852. struct3501.OrgName = miConfig.OrgName
  30853. struct3501.AccessKey = miConfig.AccessKey
  30854. struct3501.RequestUrl = miConfig.Url
  30855. struct3501.SecretKey = miConfig.SecretKey
  30856. struct3501.ManuDate = "2022-08-15"
  30857. struct3501.FixmedinsBchno = ""
  30858. struct3501.ManuLotnum = ""
  30859. struct3501.RxFlag = "0"
  30860. struct3501.ExpyEnd = "2022-08-15"
  30861. struct3501.Invdate = "2022-08-15"
  30862. struct3501.InvCnt = "20.25"
  30863. struct3501.Memo = ""
  30864. struct3501.MedListCodg = "XB01ABD056B002020200517"
  30865. struct3501.FixmedinsHilistId = miConfig.Code
  30866. struct3501.FixmedinsHilistName = miConfig.OrgName
  30867. struct3501s = append(struct3501s, struct3501)
  30868. data["struct_3501s"] = struct3501s
  30869. client := &http.Client{}
  30870. bytesData, _ := json.Marshal(data)
  30871. var req *http.Request
  30872. if miConfig.MdtrtareaAdmvs == "320921" {
  30873. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  30874. } else {
  30875. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  30876. }
  30877. resp, _ := client.Do(req)
  30878. defer resp.Body.Close()
  30879. body, ioErr := ioutil.ReadAll(resp.Body)
  30880. if ioErr != nil {
  30881. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30882. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30883. return
  30884. }
  30885. var respJSON map[string]interface{}
  30886. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30887. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30888. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30889. return
  30890. }
  30891. var res ResultSix
  30892. var resSix10265 ResultSix10265 //1101结果
  30893. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  30894. result, _ := json.Marshal(respJSON)
  30895. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  30896. utils.ErrorLog("解析失败:%v", err)
  30897. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30898. return
  30899. }
  30900. res.InfRefmsgid = resSix10265.InfRefmsgid
  30901. res.Output = resSix10265.Output
  30902. res.ErrMsg = resSix10265.ErrMsg
  30903. res.Cainfo = resSix10265.Cainfo
  30904. res.WarnMsg = resSix10265.WarnMsg
  30905. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  30906. res.Infcode = infocode
  30907. if infocode == 0 {
  30908. c.ServeSuccessJSON(map[string]interface{}{
  30909. "msg": "上传成功",
  30910. })
  30911. return
  30912. } else {
  30913. c.ServeSuccessJSON(map[string]interface{}{
  30914. "failed_code": -10,
  30915. "msg": res.ErrMsg,
  30916. })
  30917. return
  30918. }
  30919. }
  30920. func GetjxELeInfo(code string, operator_id string, operator_name string, md string) (string, string) {
  30921. // WebSocket服务器地址
  30922. serverURL := "ws://127.0.0.1:8899"
  30923. // 解析WebSocket服务器地址
  30924. u, err := url.Parse(serverURL)
  30925. if err != nil {
  30926. }
  30927. // 建立WebSocket连接
  30928. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  30929. if err != nil {
  30930. }
  30931. defer conn.Close()
  30932. input2 := make(map[string]interface{})
  30933. input := make(map[string]interface{})
  30934. inputData := make(map[string]interface{})
  30935. inputData["orgId"] = code
  30936. inputData["businessType"] = "01101"
  30937. inputData["operatorId"] = operator_id
  30938. inputData["operatorName"] = operator_name
  30939. inputData["officeId"] = "001"
  30940. inputData["officeName"] = "血透室"
  30941. inputData["deviceType"] = ""
  30942. input["data"] = inputData
  30943. input["orgId"] = code
  30944. input["transType"] = "ec.query"
  30945. //if md == ""
  30946. if md[:4] == "4403" {
  30947. input2["url"] = "http://hosp-sz.gd.hsip.gov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  30948. } else if md[:4] == "4401" {
  30949. input2["url"] = "http://hosp-sz.gd.hsip.gov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  30950. } else {
  30951. input2["url"] = "http://hosp.gd.hsip.gov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  30952. }
  30953. input2["indata"] = input
  30954. fmt.Println(input2)
  30955. bytesData, _ := json.Marshal(input2)
  30956. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  30957. if err != nil {
  30958. fmt.Println(err)
  30959. }
  30960. // 接收消息
  30961. _, receivedMessage, err := conn.ReadMessage()
  30962. if err != nil {
  30963. fmt.Println(err)
  30964. }
  30965. return "", string(receivedMessage)
  30966. }
  30967. func GetjxELeInfoaaa(code string, operator_id string, operator_name string) (string, string) {
  30968. // WebSocket服务器地址
  30969. serverURL := "ws://127.0.0.1:8899"
  30970. // 解析WebSocket服务器地址
  30971. u, err := url.Parse(serverURL)
  30972. if err != nil {
  30973. }
  30974. // 建立WebSocket连接
  30975. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  30976. if err != nil {
  30977. }
  30978. defer conn.Close()
  30979. input2 := make(map[string]interface{})
  30980. input := make(map[string]interface{})
  30981. inputData := make(map[string]interface{})
  30982. inputData["orgId"] = code
  30983. inputData["businessType"] = "01103"
  30984. inputData["operatorId"] = operator_id
  30985. inputData["operatorName"] = operator_name
  30986. inputData["officeId"] = "001"
  30987. inputData["officeName"] = "血透室"
  30988. inputData["deviceType"] = ""
  30989. input["data"] = inputData
  30990. input["orgId"] = code
  30991. input["transType"] = "ec.query"
  30992. //if md ==
  30993. input2["url"] = "http://10.77.211.236/1.0.0/localQrCodeQuery"
  30994. input2["indata"] = input
  30995. fmt.Println(input2)
  30996. bytesData, _ := json.Marshal(input2)
  30997. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  30998. if err != nil {
  30999. fmt.Println(err)
  31000. }
  31001. // 接收消息
  31002. _, receivedMessage, err := conn.ReadMessage()
  31003. if err != nil {
  31004. fmt.Println(err)
  31005. }
  31006. return "", string(receivedMessage)
  31007. }
  31008. func GetELeInfo(code string, operator_id string, operator_name string, md string) (string, string) {
  31009. // WebSocket服务器地址
  31010. serverURL := "ws://127.0.0.1:8899"
  31011. // 解析WebSocket服务器地址
  31012. u, err := url.Parse(serverURL)
  31013. if err != nil {
  31014. }
  31015. // 建立WebSocket连接
  31016. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  31017. if err != nil {
  31018. }
  31019. defer conn.Close()
  31020. input2 := make(map[string]interface{})
  31021. input := make(map[string]interface{})
  31022. inputData := make(map[string]interface{})
  31023. inputData["orgId"] = code
  31024. inputData["businessType"] = "01101"
  31025. inputData["operatorId"] = operator_id
  31026. inputData["operatorName"] = operator_name
  31027. inputData["officeId"] = "001"
  31028. inputData["officeName"] = "血透室"
  31029. inputData["deviceType"] = ""
  31030. input["data"] = inputData
  31031. input["orgId"] = code
  31032. input["transType"] = "ec.query"
  31033. //if md == ""
  31034. if md[:4] == "4403" {
  31035. input2["url"] = "http://igb.hsa.gdgov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  31036. } else if md[:4] == "4401" {
  31037. input2["url"] = "http://igb.hsa.gdgov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  31038. } else {
  31039. input2["url"] = "http://hosp.gd.hsip.gov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  31040. }
  31041. input2["indata"] = input
  31042. fmt.Println(input2)
  31043. bytesData, _ := json.Marshal(input2)
  31044. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  31045. if err != nil {
  31046. fmt.Println(err)
  31047. }
  31048. // 接收消息
  31049. _, receivedMessage, err := conn.ReadMessage()
  31050. if err != nil {
  31051. fmt.Println(err)
  31052. }
  31053. return "", string(receivedMessage)
  31054. }
  31055. func GetELeInfoThree(code string, operator_id string, operator_name string) (string, string) {
  31056. // WebSocket服务器地址
  31057. serverURL := "ws://127.0.0.1:8899"
  31058. // 解析WebSocket服务器地址
  31059. u, err := url.Parse(serverURL)
  31060. if err != nil {
  31061. }
  31062. // 建立WebSocket连接
  31063. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  31064. if err != nil {
  31065. }
  31066. defer conn.Close()
  31067. input2 := make(map[string]interface{})
  31068. input := make(map[string]interface{})
  31069. inputData := make(map[string]interface{})
  31070. inputData["orgId"] = code
  31071. inputData["businessType"] = "01301"
  31072. inputData["operatorId"] = operator_id
  31073. inputData["operatorName"] = operator_name
  31074. inputData["officeId"] = "001"
  31075. inputData["officeName"] = "血透室"
  31076. inputData["deviceType"] = ""
  31077. input["data"] = inputData
  31078. input["orgId"] = code
  31079. input["transType"] = "ec.query"
  31080. input2["url"] = "http://igb.hsa.gdgov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  31081. input2["indata"] = input
  31082. bytesData, _ := json.Marshal(input2)
  31083. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  31084. if err != nil {
  31085. fmt.Println(err)
  31086. }
  31087. // 接收消息
  31088. _, receivedMessage, err := conn.ReadMessage()
  31089. if err != nil {
  31090. fmt.Println(err)
  31091. }
  31092. return "", string(receivedMessage)
  31093. }
  31094. func RemoveRepeatedPurviewElement2(arr []string) (newArr []string) {
  31095. newArr = make([]string, 0)
  31096. for i := 0; i < len(arr); i++ {
  31097. repeat := false
  31098. for j := i + 1; j < len(arr); j++ {
  31099. if arr[i] == arr[j] {
  31100. repeat = true
  31101. break
  31102. }
  31103. }
  31104. if !repeat {
  31105. newArr = append(newArr, arr[i])
  31106. }
  31107. }
  31108. return
  31109. }
  31110. func getBirthdateAndAge(idNumber string) (string, int, error) {
  31111. if len(idNumber) != 18 {
  31112. return "", 0, fmt.Errorf("invalid ID number length. It should be 18 digits")
  31113. }
  31114. // 提取出生日期
  31115. year, err := strconv.Atoi(idNumber[6:10])
  31116. if err != nil {
  31117. return "", 0, err
  31118. }
  31119. month, err := strconv.Atoi(idNumber[10:12])
  31120. if err != nil {
  31121. return "", 0, err
  31122. }
  31123. day, err := strconv.Atoi(idNumber[12:14])
  31124. if err != nil {
  31125. return "", 0, err
  31126. }
  31127. // 格式化生日字符串
  31128. birthdate := time.Date(year, time.Month(month), day, 0, 0, 0, 0, time.UTC)
  31129. birthdateFormatted := birthdate.Format("2006-01-02")
  31130. // 计算年龄
  31131. today := time.Now()
  31132. age := today.Year() - birthdate.Year()
  31133. if today.YearDay() < birthdate.YearDay() {
  31134. age--
  31135. }
  31136. return birthdateFormatted, age, nil
  31137. }